I've been modifying a php script that inserted data into my database to include an image file upload. Previously, it inserted the data just fine. But now it goes through the motions, but doesn't put anything into the database. The new code I added for the file upload seems to be working fine, the image goes where it should and is the right size. It is connecting to the db, no error from my connection script. Triple checked form names, etc. I can't seem to see what I've done wrong and I'm sure it's something I'm missing.
Here's the offending code segment:
Like I said, no errors are thrown, just goes through the motions like it worked, but when I look at the db through mysql, there are no records in the db. Any solutions? Thanks for your time!!
Here's the offending code segment:
Code:
$msg = "";
$sname = "";
$pix = "";
$credentials = "";
$tparagraph = "";
$slogan = "";
$seminar = "";
$dorder = "";
if(isset($_POST['Submit']))
{
// This file upload section seems to work fine.
if ($pix == 'none')
{
echo "You must select your picture file to upload.<br><br>Please click the back button to go back.";
exit;
}
$upload_path = "/sitepath/";
$newname = $_FILES['pix']['name'];
$tmpfile = $_FILES['pix']['tmp_name'];
$dest = "$upload_path" . "$newname";
if (!copy ($tmpfile,$dest))
{
echo "Something went wrong with the upload.";
}
//end of file upload section - start of insertion code
$sname = $_POST['sname'];
$pix = $newname;
$credentials = $_POST['credentials'];
$tparagraph = $_POST['tparagraph'];
$slogan = $_POST['slogan'];
$seminar = $_POST['seminar'];
$dorder = $_POST['dorder'];
if(!isset($_GET['ID']))
{
$result = mysql_query("Insert into msi(sname, pix, credentials, tparagraph, slogan, seminar, dorder) values('$sname','$pix','$credentials','$tparagraph','$slogan','$seminar','$dorder')");
$msg = "New record is saved";
}
//end of insertion code. else follows from there for updates.