473,387 Members | 3,684 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,387 software developers and data experts.

Error: You have an error in your SQL syntax; check the manual that corresponds to you

Hi.
I'm getting the following error over and over:
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 ')' at line 5
This is the code:
Expand|Select|Wrap|Line Numbers
  1. <?
  2. include("begin.php");
  3. SESSION_START ();
  4. ?>
  5.  
  6. <html>
  7. <body>
  8. Geef antwoord op de volgende vraag (maar 1 antwoord is goed!):<br />
  9. <b>Is kaas lekker?</b>
  10. <table>
  11. <tr><td><form name="vraag1" action="oefentoets.php" method="post"></td></tr> 
  12. <tr><td><input type="radio" name="vraag1" value="ja" />ja</td></tr>
  13. <tr><td><input type="radio" name="vraag1" value="nee" />nee</td></tr>
  14. <tr><td><input type="submit" value="Volgende" name="knop" /></td></tr>
  15. </form></table>
  16.  
  17. <!-- bovenstaande kan je voor elke vraag aanpassen-->
  18. </body>
  19. </html>
  20.  
  21. <?php
  22. $con = mysql_connect("localhost","XXXXXXXX","XXXXXX");
  23. if (!$con)
  24.   {
  25.   die('Could not connect: ' . mysql_error());
  26.   }
  27.  
  28.  mysql_select_db("zcollege_1342", $con);
  29.  
  30.  $_SESSION['email'] = $_POST['email'];
  31. //$antwoord1 = $_POST['vraag1'];
  32. $vraag1 = $_POST['vraag1'];
  33. echo $_SESSION['email'];
  34.  
  35. if(isset($_POST['knop'])) {
  36.     $sql= "UPDATE oefentoets
  37.     SET vraag1 = '$_POST[vraag1]'
  38.     WHERE id=$id";
  39. if (!mysql_query($sql,$con))
  40.     {
  41.     die('Error: ' . mysql_error());
  42.     }
  43. echo "1 record added";
  44.  
  45. mysql_close($con);
  46. }
  47. ?>
Line 5 is empty. There is nothing wrong with the brackets, and even if I remove the last adjustments I made before I started getting this error, it won't go away. So, does anyone have any idea on what's wrong here?
Kind regards,
Ellen
May 23 '12 #1
3 3536
johny10151981
1,059 1GB
Expand|Select|Wrap|Line Numbers
  1. $sql= "UPDATE oefentoets
  2. SET vraag1 = '$_POST[vraag1]'
  3. WHERE id=$id";
  4.  
here in your code you never defined $id. so your actual query is something like below:
Expand|Select|Wrap|Line Numbers
  1. UPDATE oefentoets SET vraag1 = 'testvalue'
  2. WHERE id=
  3.  
you know it must fail :)
May 24 '12 #2
I defined $id in the included page, begin.php.
The code I used for that:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. $con = mysql_connect("localhost","XXXXXXX","XXXXX");
  4. if (!$con)
  5.   {
  6.   die('Could not connect: ' . mysql_error());
  7.   }
  8.  
  9. mysql_select_db("zcollege_1342", $con);
  10.  
  11. $sql="INSERT INTO oefentoets (name, email)
  12. VALUES
  13. ('$_POST[name]',
  14. '$_POST[email]',
  15. )";
  16. $id = mysql_insert_id(); 
  17.  
  18. if (!mysql_query($sql,$con))
  19.   {
  20.   die('Error: ' . mysql_error());
  21.   }
  22. echo "Gelukt! Je bent nu geregistreerd als: ";
  23. echo $_POST[name];
  24. echo " .";
  25. mysql_close($con)
  26. ?> 
  27.  
As you can see, $id does get defined in this section. So, what else could be wrong here?
May 25 '12 #3
johny10151981
1,059 1GB
Well I would suggest you to print the query and see for yourself and then try the query on mysql itself.
May 25 '12 #4

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

Similar topics

2
by: entoone | last post by:
I'm getting the following error Parse error: parse error, expecting `','' or `';'' in /home/notarywe/public_html/php/update2.php on line 108 Here is line 108 <input type="text" name="ud_first"...
3
by: Marten van Urk | last post by:
I got the following error in my page Parse error: parse error, unexpected T_ELSE in line 25 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Club</title>...
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. ...
2
by: Krzysztof Bartosiewicz | last post by:
Hi! I have problems with editing my VBA code. It is connected with some kind of automatic-correction mechanism in Access which I cannot find. I turned off Automatic Syntax Check in Options menu...
1
by: Annie | last post by:
Hi guys, I am trying to set the connection string for my database in the web.config file however it raises the funny error message: ""Error while trying to run project: Unable to start...
0
by: Subanesh | last post by:
Hi All, Am new to using HTMLUnit.I wrote a sample code(to emulate opening of website google.com and enter a value say "html" in the text field and click the Search button) .The code is as follows...
7
by: ajos | last post by:
hi friends, i have a problem in mysql query..when i click on submit the values get enterred but i get a ever since i did some changes in my code(earlier i was getting a null pointer...
21
by: missflorenceokosun | last post by:
hi, am florence. i keep having a runtime error stating error in update query syntax. i have looked through my code over and over gain and seem to find no flaw. i need you guys to help me out! ...
4
by: FM | last post by:
Hi there: My question is about checking my sql-syntax against DB2UDB V9 throug JDBC 2.0 Is there a way to check my syntax,for example "select * from T1"? Thank you for your help. Regards,
1
by: sathishauit | last post by:
<?php require_once ("inc/dbconnection.php"); class provider_function { public $select_query; public $select_result; public $insert_query; public $insert_result; public $update_query;
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.