CodeMama Posted November 7, 2008 Share Posted November 7, 2008 I need some extra eyes, I have a script that worked fine, I then had to add some extra fields to the db and put them in the script to insert the data, and even though I tried copying the existing code that was inserting the other fields, the new ones just won't insert. I'm missing something that I am not seeing from looking at it for two days. Extra eyes please help! <?php include("inc/dbconn_open.php"); if (empty($_SESSION['AdminLogin']) OR $_SESSION['AdminLogin'] <> 'OK' ){ header ("Location: LogOut.php"); } if (isset($_POST['AdminID'])){ $AdminID = $_POST['AdminID']; } elseif (isset($_GET['AdminID'])){ $AdminID = $_GET['AdminID']; } else { header ("Location: LogOut.php"); } if (!empty($_POST['GO'])){$GO = $_POST['GO'];} else {$GO = "";} if (isset($_POST['Location'])){$Location = $_POST['Location'];} else {$Location = "";} if (isset($_POST['WorkOrderName'])){$WorkOrderName = $_POST['WorkOrderName'];} else {$WorkOrderName = "";} if (!empty($_POST['Customer'])){$Customer = $_POST['Customer'];} else {$Customer = "";} if (!empty($_POST['AccountNum'])){$AccountNum = $_POST['AccountNum'];} else {$AccountNum = "";} if (!empty($_POST['IONum'])){$IONum = $_POST['IONum'];} else {$IONum = "";} if (!empty($_POST['StartMonth']) && !empty($_POST['StartDay']) && !empty($_POST['StartYear'])){ $StartDate = $_POST['StartYear'] ."-". $_POST['StartMonth'] ."-". $_POST['StartDay']; } else { $StartDate = ""; } if (!empty($_POST['EndMonth']) && !empty($_POST['EndDay']) && !empty($_POST['EndYear'])){ $EndDate = $_POST['EndYear'] ."-". $_POST['EndMonth'] ."-". $_POST['EndDay']; } else { $EndDate = ""; } if (!empty($_POST['Headline'])){$Headline = $_POST['Headline'];} else {$Headline = "";} if (!empty($_POST['Body'])){$Body = $_POST['Body'];} else {$Body = "";} if (!empty($_POST['URL'])){$URL = $_POST['URL'];} else {$URL = "";} if (!empty($_POST['SearchTerm1'])){$SearchTerm1 = $_POST['SearchTerm1'];} else {$SearchTerm1 = "";} if (!empty($_POST['SearchTerm2'])){$SearchTerm2 = $_POST['SearchTerm2'];} else {$SearchTerm2 = "";} if (!empty($_POST['SearchTerm3'])){$SearchTerm3 = $_POST['SearchTerm3'];} else {$SearchTerm3 = "";} if (!empty($_POST['SearchTerm4'])){$SearchTerm4 = $_POST['SearchTerm4'];} else {$SearchTerm4 = "";} if (!empty($_POST['SearchTerm5'])){$SearchTerm5 = $_POST['SearchTerm5'];} else {$SearchTerm5 = "";} if (isset($_POST['Salesperson'])){$Salesperson = $_POST['Salesperson'];} else {$Salesperson = "";} if (isset($_POST['SalespersonID'])){$SalespersonID = $_POST['SalespersonID'];} else {$SalespersonID = "";} if (isset($_POST['SalespersonEmail'])){$SalespersonEmail = $_POST['SalespersonEmail'];} else {$SalespersonEmail = "";} if (isset($_POST['SalespersonExt'])){$SalespersonExt = $_POST['SalespersonExt'];} else {$SalespersonExt = "";} if (isset($_POST['Comments'])){$Comments = $_POST['Comments'];} else {$Comments = "";} if (isset($_POST['ExtraImage1Desc'])){$ExtraImage1Desc = $_POST['ExtraImage1Desc'];} else {$ExtraImage1Desc = "";} if (isset($_POST['ExtraImage2Desc'])){$ExtraImage2Desc = $_POST['ExtraImage2Desc'];} else {$ExtraImage2Desc = "";} if (isset($_POST['ExtraImage3Desc'])){$ExtraImage3Desc = $_POST['ExtraImage3Desc'];} else {$ExtraImage3Desc = "";} if (isset($_POST['ExtraImage4Desc'])){$ExtraImage4Desc = $_POST['ExtraImage4Desc'];} else {$ExtraImage4Desc = "";} if (isset($_POST['ExtraImage5Desc'])){$ExtraImage5Desc = $_POST['ExtraImage5Desc'];} else {$ExtraImage5Desc = "";} if (isset($_POST['GiftImage1Desc'])){$GiftImage1Desc = $_POST['GiftImage1Desc'];} else {$GiftImage1Desc = "";} if ($GO == "Save") { $sql = "SELECT Name FROM admin WHERE AdminID='$AdminID'"; $result = mysql_query ($sql); $row = mysql_fetch_object ($result); $Notes = "~". date("F j, Y g:i a") ." - Planet Discover Right Side Text Ad Submitted by ". $row->Name ."\n"; $sql = "INSERT INTO workorders (CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes) VALUES ("; $sql .= "Now(), '$Location', '$WorkOrderName', '$AdminID', 'PD_TextAd', 'New Order', '$Notes')"; mysql_query($sql); $WorkOrderID = mysql_insert_id(); if ($_FILES) { if (isset($_FILES['Logo'])) { if (is_uploaded_file ($_FILES['Logo']['tmp_name'])) { $ImageExt = strtolower(end(explode('.', $_FILES['Logo']['name']))); $Logo = "Artwork/". $WorkOrderID ."_Logo.". $ImageExt; move_uploaded_file($_FILES['Logo']['tmp_name'],$Logo); } } if (isset($_FILES['ExtraImage1'])) { if (is_uploaded_file ($_FILES['ExtraImage1']['tmp_name'])) { $ImageExt = strtolower(end(explode('.', $_FILES['ExtraImage1']['name']))); $ExtraImage1Name = "Artwork/". $WorkOrderID ."_Image1.". $ImageExt; move_uploaded_file($_FILES['ExtraImage1']['tmp_name'],$ExtraImage1Name); } } if (isset($_FILES['ExtraImage2'])) { if (is_uploaded_file ($_FILES['ExtraImage2']['tmp_name'])) { $ImageExt = strtolower(end(explode('.', $_FILES['ExtraImage2']['name']))); $ExtraImage2Name = "Artwork/". $WorkOrderID ."_Image2.". $ImageExt; move_uploaded_file($_FILES['ExtraImage2']['tmp_name'],$ExtraImage2Name); } } if (isset($_FILES['ExtraImage3'])) { if (is_uploaded_file ($_FILES['ExtraImage3']['tmp_name'])) { $ImageExt = strtolower(end(explode('.', $_FILES['ExtraImage3']['name']))); $ExtraImage3Name = "Artwork/". $WorkOrderID ."_Image3.". $ImageExt; move_uploaded_file($_FILES['ExtraImage3']['tmp_name'],$ExtraImage3Name); } } if (isset($_FILES['ExtraImage4'])) { if (is_uploaded_file ($_FILES['ExtraImage4']['tmp_name'])) { $ImageExt = strtolower(end(explode('.', $_FILES['ExtraImage4']['name']))); $ExtraImage4Name = "Artwork/". $WorkOrderID ."_Image4.". $ImageExt; move_uploaded_file($_FILES['ExtraImage4']['tmp_name'],$ExtraImage4Name); } } if (isset($_FILES['ExtraImage5'])) { if (is_uploaded_file ($_FILES['ExtraImage5']['tmp_name'])) { $ImageExt = strtolower(end(explode('.', $_FILES['ExtraImage5']['name']))); $ExtraImage5Name = "Artwork/". $WorkOrderID ."_Image5.". $ImageExt; move_uploaded_file($_FILES['ExtraImage5']['tmp_name'],$ExtraImage5Name); } } if (isset($_FILES['GiftImage1'])) { if (is_uploaded_file ($_FILES['GiftImage1']['tmp_name'])) { $ImageExt = strtolower(end(explode('.', $_FILES['GiftImage1']['name']))); $GiftImage1Name = "Artwork/". $WorkOrderID ."_GImage1.". $ImageExt; move_uploaded_file($_FILES['GiftImage1']['tmp_name'],$GiftImage1Name); } } } $sql = "INSERT INTO pd_textad (WorkOrderID, CreatedDate, Customer, AccountNum, IONum, StartDate, EndDate, Headline, Body, "; $sql .= "Logo, URL, SearchTerm1, SearchTerm2, SearchTerm3, SearchTerm4, SearchTerm5, Salesperson, SalespersonID, "; $sql .= "SalespersonEmail, SalespersonExt, Comments, ExtraImage1, ExtraImage1Desc, ExtraImage2, ExtraImage2Desc, "; $sql .= "GiftImage1, GiftImage1Desc,"; $sql .= "ExtraImage3, ExtraImage3Desc, ExtraImage4, ExtraImage4Desc, ExtraImage5, ExtraImage5Desc) VALUES ("; $sql .= "'". mysql_real_escape_string($WorkOrderID) ."', Now(), "; $sql .= "'". mysql_real_escape_string($Customer) ."', "; $sql .= "'". mysql_real_escape_string($AccountNum) ."', "; $sql .= "'". mysql_real_escape_string($IONum) ."', "; $sql .= "'". mysql_real_escape_string($StartDate) ."', "; $sql .= "'". mysql_real_escape_string($EndDate) ."', "; $sql .= "'". mysql_real_escape_string($Headline) ."', "; $sql .= "'". mysql_real_escape_string($Body) ."', "; $sql .= "'". mysql_real_escape_string($Logo) ."', "; $sql .= "'". mysql_real_escape_string($URL) ."', "; $sql .= "'". mysql_real_escape_string($SearchTerm1) ."', "; $sql .= "'". mysql_real_escape_string($SearchTerm2) ."', "; $sql .= "'". mysql_real_escape_string($SearchTerm3) ."', "; $sql .= "'". mysql_real_escape_string($SearchTerm4) ."', "; $sql .= "'". mysql_real_escape_string($SearchTerm5) ."', "; $sql .= "'". mysql_real_escape_string($Salesperson) ."', "; $sql .= "'". mysql_real_escape_string($SalespersonID) ."', "; $sql .= "'". mysql_real_escape_string($SalespersonEmail) ."', "; $sql .= "'". mysql_real_escape_string($SalespersonExt) ."', "; $sql .= "'". mysql_real_escape_string($Comments) ."', "; $sql .= "'". mysql_real_escape_string($GiftImage1Name) ."', "; $sql .= "'". mysql_real_escape_string($GiftImage1Desc) ."', "; $sql .= "'". mysql_real_escape_string($ExtraImage1Name) ."', "; $sql .= "'". mysql_real_escape_string($ExtraImage1Desc) ."', "; $sql .= "'". mysql_real_escape_string($ExtraImage2Name) ."', "; $sql .= "'". mysql_real_escape_string($ExtraImage2Desc) ."', "; $sql .= "'". mysql_real_escape_string($ExtraImage3Name) ."', "; $sql .= "'". mysql_real_escape_string($ExtraImage3Desc) ."', "; $sql .= "'". mysql_real_escape_string($ExtraImage4Name) ."', "; $sql .= "'". mysql_real_escape_string($ExtraImage4Desc) ."', "; $sql .= "'". mysql_real_escape_string($ExtraImage5Name) ."', "; $sql .= "'". mysql_real_escape_string($ExtraImage5Desc) ."') "; mysql_query($sql); $Message = "<HTML>"; $Message.= "<STYLE TYPE=\"text/css\">"; $Message.= "<!--"; $Message.= "body {font-size:12px; font-family:arial, sans-serif;}"; $Message.= "-->"; $Message.= "</STYLE>"; $Message.= "</HEAD>"; $Message.= "<body>"; $Message.= "A Planet Discover Right Side Text Ad form was submitted."; $Message.= "</body>"; $Message = wordwrap($Message, 70); $Subject = "Planet Discover Right Side Text Ad Form"; $Email = "[email protected]"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "To: [email protected]\r\n"; $headers .= "From: [email protected]\r\n"; @mail($Email, $Subject, $Message, $headers); ?> <script language="javascript"> alert("Your Planet Discover Right Side Text Ad form has been received. \n\nThank You."); window.location="Welcome.php?AdminID=<?php echo $AdminID; ?>"; </script> <?php exit(); } ?> Thanks in advance for the clues! Quote Link to comment https://forums.phpfreaks.com/topic/131797-insertion-problems-for-new-fields/ Share on other sites More sharing options...
CodeMama Posted November 7, 2008 Author Share Posted November 7, 2008 I just noticed that the "GiftImage1" is being inserted into the "ExtraImage1" fields in the db. Don't know if this is clue or not it wasn't for me. Quote Link to comment https://forums.phpfreaks.com/topic/131797-insertion-problems-for-new-fields/#findComment-684668 Share on other sites More sharing options...
.josh Posted November 7, 2008 Share Posted November 7, 2008 Look at the attached screenshot. You will notice that first off, you are trying to insert more values than you have columns, and 2nd, you aren't doing them in the right order. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/131797-insertion-problems-for-new-fields/#findComment-684785 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.