469,904 Members | 2,452 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

syntax error

anfetienne
424 256MB
Hi, I have mysql 5.045 installed on my server and i've written a code to insert values into the database. it keeps coming up with this error

Error in query: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 's within 7 working days of receipt, if the item is not as described.

', ' at line 66


there is nothing wrong with the coding as it's been used and tested on other servers and works perfectly fine....i don't understand why this error is showing. My code is below

Expand|Select|Wrap|Line Numbers
  1. <?PHP error_reporting(E_ALL);
  2. $username="tempsUser";
  3. $password="auction";
  4. $database="auctionTemps";
  5.  
  6.  
  7. $htmlcss=$_POST['htmlcss'];
  8. $header=$_POST['header'];
  9. $nav=$_POST['nav'];
  10. $titleWrap01=$_POST['titleWrap01'];
  11. $title=$_POST['title'];
  12. $titleWrap02=$_POST['titleWrap02'];
  13. $subheadWrap01=$_POST['subheadWrap01'];
  14. $subheading=$_POST['subheading'];
  15. $subheadWrap02=$_POST['subheadWrap02'];
  16. $flashWrap01=$_POST['flashWrap01'];
  17. $flashWrap02=$_POST['flashWrap02'];
  18. $flash01=$_POST['flash01'];
  19. $flashVar=$_POST['flashVar'];
  20. $flash02=$_POST['flash02'];
  21. $flashWrap03=$_POST['flashWrap03'];
  22. $descriptionWrap01=$_POST['descriptionWrap01'];
  23. $description=$_POST['description'];
  24. $descriptionWrap02=$_POST['descriptionWrap02'];
  25. $generalWrap01=$_POST['generalWrap01'];
  26. $general=$_POST['general'];
  27. $generalWrap02=$_POST['generalWrap02'];
  28. $aboutWrap01=$_POST['aboutWrap01'];
  29. $about=$_POST['about'];
  30. $aboutWrap02=$_POST['aboutWrap02'];
  31. $paymentWrap01=$_POST['paymentWrap01'];
  32. $payment01=$_POST['payment01'];
  33. $payment02=$_POST['payment02'];
  34. $paymentWrap02=$_POST['paymentWrap02'];
  35. $termsWrap01=$_POST['termsWrap01'];
  36. $terms=$_POST['terms'];
  37. $termsWrap02=$_POST['termsWrap02'];
  38. $footer=$_POST['footer'];
  39.  
  40.  
  41. // OPEN CONNECTION ---> 
  42. $connection=mysql_connect("localhost","$username", "$password") or die("Unable to connect!");
  43.  
  44. mysql_select_db("$database") or die("Unable to select database!");
  45.  
  46.  
  47. //  EXECUTE QUERY ---> 
  48. $query="INSERT templates (
  49.  
  50.             htmlcss, 
  51.             header, 
  52.             nav, 
  53.             titleWrap01, 
  54.             title,
  55.             titleWrap02,
  56.             subheadWrap01, 
  57.             subheading,
  58.             subheadWrap02, 
  59.             flashWrap01,     
  60.             flashWrap02, 
  61.             flash01, 
  62.             flashVar,
  63.             flash02, 
  64.             flashWrap03,
  65.             descriptionWrap01,
  66.             description, 
  67.             descriptionWrap02,
  68.             generalWrap01, 
  69.             general, 
  70.             generalWrap02, 
  71.             aboutWrap01,
  72.             about, 
  73.             aboutWrap02,
  74.             paymentWrap01, 
  75.             payment01, 
  76.             payment02, 
  77.             paymentWrap02,
  78.             termsWrap01, 
  79.             terms, 
  80.             termsWrap02,
  81.             footer)
  82.  
  83.         VALUES(    
  84.             '".$htmlcss."', 
  85.             '".$header."', 
  86.             '".$nav."', 
  87.             '".$titleWrap01."', 
  88.             '".$title."',
  89.             '".$titleWrap02."',
  90.             '".$subheadWrap01."', 
  91.             '".$subheading."',
  92.             '".$subheadWrap02."', 
  93.             '".$flashWrap01."',     
  94.             '".$flashWrap02."', 
  95.             '".$flash01."', 
  96.             '".$flashVar."', 
  97.             '".$flash02."', 
  98.             '".$flashWrap03."',
  99.             '".$descriptionWrap01."',
  100.             '".$description."', 
  101.             '".$descriptionWrap02."',
  102.             '".$generalWrap01."', 
  103.             '".$general."', 
  104.             '".$generalWrap02."', 
  105.             '".$aboutWrap01."',
  106.             '".$about."', 
  107.             '".$aboutWrap02."',
  108.             '".$paymentWrap01."', 
  109.             '".$payment01."', 
  110.             '".$payment02."', 
  111.             '".$paymentWrap02."',
  112.             '".$termsWrap01."', 
  113.             '".$terms."', 
  114.             '".$termsWrap02."',
  115.             '".$footer."')";
  116.  
  117. //////-----> 
  118. $result=mysql_query($query) or die("Error in query:".mysql_error()); 
  119. //if ($result) 
  120.     //echo mysql_affected_rows()." row inserted into the database effectively."; 
  121.  
  122. //  CLOSE CONNECTION ---> 
  123. mysql_close($connection); 
  124.  
  125. /////////////////////////////////////////////////////////////////////////////////// 
  126.  
  127. ?>
  128.  
  129.  
Mar 25 '09 #1
4 1299
TheServant
1,168 Expert 1GB
If your variable string that is being stored (the one with "...within 7 working days of receipt...") has any single quotes ( ' ) it will stop the code and cause errors.

Also, I am pretty sure you don't need:
Expand|Select|Wrap|Line Numbers
  1. '".$terms."'
But:
Expand|Select|Wrap|Line Numbers
  1. ".$terms."
Or:
Expand|Select|Wrap|Line Numbers
  1. '$terms'
will be fine. I prefer the second option.
Mar 25 '09 #2
anfetienne
424 256MB
ill try that....thanks
Mar 26 '09 #3
anfetienne
424 256MB
thanks alot it worked!!!
Mar 26 '09 #4
TheServant
1,168 Expert 1GB
No worries. Glad I could help.
Mar 26 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Steve | last post: by
1 post views Thread by Donald Canton | last post: by
3 posts views Thread by Manuel | last post: by
1 post views Thread by Hari Sekhon | last post: by
7 posts views Thread by Josh | last post: by
Banfa
5 posts views Thread by Banfa | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.