473,394 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 1392
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

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

Similar topics

1
by: Steve | last post by:
I just spent waaaaaaaaaaaayy too much time trying to track down an error that was incorrectly reported just now, and I would like to see if someone can explain to me why it was reported that way. ...
1
by: Donald Canton | last post by:
Hi, I'm using Bjarne's book to learn C++ and am stuck on the Calc program in Section 6. Everything works fine except when I try to use istringstream to parse a token from the command line. I...
5
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by...
2
by: david | last post by:
Anyone could give me a hand about this syntax error? Thank you. David Source Code: Dim conn As New SqlConnection(strConn) Dim daAngio As New SqlDataAdapter(strSelectStatement, conn) 'Create a...
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
1
by: Hari Sekhon | last post by:
I've written an except hook into a script as shown below which works well for the most part and catches exceptions. import sys def myexcepthook(type,value,tb): do something ...
7
by: Josh | last post by:
I have a lot of except Exception, e statements in my code, which poses some problems. One of the biggest is whenever I refactor even the triviallest thing in my code. I would like python to...
7
by: bryant | last post by:
Hi all. I am new to ASP and working in Expression Web. The following query displays the information I need in the gridview for a single record. SELECT "OE_HDR"."ORD_NO", "OE_HDR"."CUST_NAM",...
6
by: muby | last post by:
Hi everybody :) I'm modifying a C++ code in VC++ 2005 my code snippet void BandwidthAllocationScheduler::insert( Message* msg, BOOL* QueueIsFull,
5
Banfa
by: Banfa | last post by:
So I have a little problem, I have a template class and that class contains a template function; now what I want to do is declare that function in the class (or indeed the entire class) as a friend...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.