I am new to PHP/MySQL and currently working on a project to learn it a little better. I have a bit of PHP code and it has a problem that I'm having a little trouble figuring out.
Basically, it is taking session data and writing it to a MySQL database. Here is the entire code:
<?php
$con = mysql_connect("localhost","my_username","mypassword");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("myserver_imaging", $con);
mysql_query ("INSERT INTO imaging (os,MAC,Model,AntiVirus,Browser,Email,Connectivity,Sound,Ports) VALUES ('".$_SESSION['imaging2']."','".$_SESSION['imaging3']."','".$_SESSION['imaging4']."','".$_SESSION['antivirus']."','".$_SESSION['browser']."','".$_SESSION['email']."','".$_SESSION['connectivity']."','".$_SESSION['sound']."','".$_SESSION['ports']."')");
OR die("Could not update: ".mysql_error());
mysql_close($con);
?>
Now here's the problem. When I remove line 12 (the OR die statement), the data gets written to the database, but it errors out. I'm using Joomla 2.5 with the Sourcerer plug-in to insert PHP into my pages, and the error messages point directly to a couple modules in my template.
When I add the statement back in, the page redirects where it is supposed to, but the data doesn't get written to the database.
I know this question would best be directed to those using Joomla, but I'm also curious to know if there is a problem with my syntax in line 12. This isn't a huge deal since it is only a project, but I would still like to know if the problem is with my syntax.
Any suggestions or comments would be very much appreciated! Thanks for checking into it with me.