Forum Moderators: coopster
I am in dire need of some assistance and I have no idea what's wrong.
- I have searched, modified, checked, updated, checked and searched with no luck -
The code: ------------------------------------------------------------
<?php
include('dbcreds.php');
$q = $_POST['qid'];
$Contact_Person = $_POST['Contact_Person'];
$Mine = $_POST['Mine'];
$Town_District = $_POST['Town_District'];
$Position = $_POST['Position'];
$Group = $_POST['Group'];
$Land_Line = $_POST['Land_Line'];
$l2 = $_POST['l2'];
$l3 = $_POST['l3'];
$Cell_Number = $_POST['Cell_Number'];
$c2 = $_POST['c2'];
$c3 = $_POST['c3'];
$Email_Address = $_POST['Email_Address'];
$Class = $_POST['Class'];
if($q>'2')
{
$query = "UPDATE cdm SET Contact_Person='$Contact_Person',Mine='$Mine', Town_District='$Town_District',Position='$Position',Group='$Group', Land_Line='$Land_Line',l2='$l2',l3='$l3',Cell_Number='$Cell_Number',c2='$c2' ,c3='$c3',Email_Address='$Email_Address',Class='$Class' WHERE id='$q'";
mysql_query($query) or die (mysql_error());
}
else
{ echo "<meta http-equiv='REFRESH' content='10;url=http:ef.php'>Oops! If you want to add a new contact, rather use the Main Database Entry Form."
}
?>
The error: -----------------------------------------------------------
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Group='',Land_Line='',l2='',l3='',Cell_Number='',c2='',c3='',Email_Address='',Cl' at line 1
Now the question: ----------------------------------------------------
WHAT THE HELL did I do wrong?
Am I missing something?
I've been using the same (modified) script style hundreds of times with no errors and the databases have the same / similar structures and never a single problem.
(It's probably something simple -stupid- like a ' or a , that I overlooked, so please feel free to make fun of me if this is the case.)
Any assistance would be GREATLY appreciated.
Thank you.
[edited by: eelixduppy at 9:29 pm (utc) on Dec. 7, 2008]
[edit reason] fixed side scroll [/edit]
`Group` = '$Group'
and Welcome to WebmasterWorld!
Now, about that code, right....
It's giving me a whole lotta new syntax errors I find difficult to comprehend, in my fragile, frustrated state lol.
It would seem quite obvious that's the reason and as I've said, I've tried it (and variations of it, just in case), but not working - eish.
However, I've been using (and still operating the exact same script on the same site, same database, except it's a 'INSERT INTO' query) that works absolutely beautiful.
At this stage I'm considering throwing in the towel, or my laptop - which ever's nearest (or in that case, a box of tissues)
Thank you for your help though,
Much appreciated.
----------------------------------------------------------------------
BTW - Here's the working code, maybe it'll help solve this conundrum.
<?php
//clean RepCode
$Product = $_POST['Product'];
$p1 = $_POST['p1'];
$p2 = $_POST['p2'];
$p3 = $_POST['p3'];
$p4 = $_POST['p4'];
$p5 = $_POST['p5'];
$p6 = $_POST['p6'];
$p7 = $_POST['p7'];
$p8 = $_POST['p8'];
$p9 = $_POST['p9'];
$RepCode = $_POST['RepCode'];
$Date = $_POST['Date'];
$month = $_POST['month'];
$day = $_POST['day'];
$Contact_Person = $_POST['Contact_Person'];
$Mine = $_POST['Mine'];
$Town_District = $_POST['Town_District'];
$Position = $_POST['Position'];
$Group = $_POST['Group'];
$Land_Line = $_POST['Land_Line'];
$l2 = $_POST['l2'];
$l3 = $_POST['l3'];
$Cell_Number = $_POST['Cell_Number'];
$c2 = $_POST['c2'];
$c3 = $_POST['c3'];
$Email_Address = $_POST['Email_Address'];
$Quote_Required = $_POST['Quote_Required'];
$Next_App = $_POST['Next_App'];
$nmonth = $_POST['nmonth'];
$nday = $_POST['nday'];
$Type_of_Call = $_POST['Type_of_Call'];
$Comment = $_POST['Comment'];
$Time = $_POST['Time'];
$Probability = $_POST['Probability'];
$Est_Value = $_POST['Est_Value'];
$Class = $_POST['Class'];
$q=$_POST['qid'];
include('dbcreds.php');
if ($q<'2')
{
$sql = 'INSERT INTO `Sales_Call_Sheet` VALUES (NULL,"'.$RepCode.'","'.$Date.'","'.$month.'","'.$day.'","'.$Contact_Person.'", "'.$Mine.'","'.$Town_District.'","'.$Position.'","'.$Group.'","'.$Land_Line.'", "'.$l2.'","'.$l3.'","'.$Cell_Number.'","'.$c2.'","'.$c3.'","'.$Email_Address.'", "'.$Quote_Required.'","'.$Next_App.'","'.$nmonth.'","'.$nday.'","'.$Type_of_Call.'", "'.$Comment.'","'.$Product.'","'.$p1.'","'.$p2.'","'.$p3.'","'.$p4.'","'.$p5.'", "'.$p6.'","'.$p7.'","'.$p8.'","'.$p9.'","'.$Time.'","'.$Probability.'", "'.$Est_Value.'","'.$Class.'",CURRENT_TIMESTAMP())';
mysql_query($sql);
echo '<meta http-equiv="REFRESH" content="0;url=http:ef.php"><b>Data Successfully Entered.</b>';
$sqlac = 'INSERT INTO `cdm` VALUES (NULL,"'.$Contact_Person.'","'.$Mine.'","'.$Town_District.'","'.$Position.'", "'.$Group.'","'.$Land_Line.'","'.$l2.'","'.$l3.'","'.$Cell_Number.'","'.$c2.'", "'.$c3.'","'.$Email_Address.'","'.$Class.'")';
mysql_query($sqlac);
echo '<b>Contact Successfully Entered.</b>';
}
else
{
$sql = 'INSERT INTO `Sales_Call_Sheet` VALUES (NULL,"'.$RepCode.'","'.$Date.'","'.$month.'","'.$day.'","'.$Contact_Person.'", "'.$Mine.'","'.$Town_District.'","'.$Position.'","'.$Group.'","'.$Land_Line.'", "'.$l2.'","'.$l3.'","'.$Cell_Number.'","'.$c2.'","'.$c3.'","'.$Email_Address.'", "'.$Quote_Required.'","'.$Next_App.'","'.$nmonth.'","'.$nday.'","'.$Type_of_Call.'", "'.$Comment.'","'.$Product.'","'.$p1.'","'.$p2.'","'.$p3.'","'.$p4.'","'.$p5.'", "'.$p6.'","'.$p7.'","'.$p8.'","'.$p9.'","'.$Time.'","'.$Probability.'", "'.$Est_Value.'","'.$Class.'",CURRENT_TIMESTAMP())';
mysql_query($sql);
echo '<meta http-equiv="REFRESH" content="0;url=http:ef.php"><b>Data Successfully Entered. No New Contact Person Added.</b>';
}
?>
[edited by: eelixduppy at 7:10 pm (utc) on Dec. 10, 2008]
[edit reason] side scroll [/edit]