By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,040 Members | 1,815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,040 IT Pros & Developers. It's quick & easy.

Saving data error: Parse error: syntax error, unexpected ')'

P: 35
hi im having a problem in saving data in my database and i try everything i know but still im having this error message in my page..please help me thanks guys

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. /*$cs = mysql_connect ('localhost')or die ("not connect .". mysql_error());
  3. $ds = mysql_select_db ('dbase')or die ("no data .". mysql_error());
  4.  
  5. $host = 'localhost';
  6. $username = 'globaml6';
  7. $password = 'Gwd_2011';
  8.  
  9. $conn = mysql_connect($host, $username, $password) or die('Error connecting to mysql');
  10.  
  11. $dbname = 'globaml6_gwd';
  12. mysql_select_db($dbname);
  13. */
  14. $dbhost = 'localhost';
  15. $dbuser = 'root';
  16. $dbpass = '';
  17.  
  18. $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
  19.  
  20. $dbname = 'msic';
  21. mysql_select_db($dbname);
  22.  
  23.  
  24.  
  25.  
  26. $sql="INSERT INTO sd (Pickday, Pickmonth, Pickhour, Pickmin, Rday, Rmonth, Rhour, Rmin, Origin, Destination, Vehicle, Fname, Lname, Email, Contact, Address, Zip, City, Country) 
  27. VALUES ('".$_POST['txtpday']."', '".$_POST['txtpmonth']."', '".$_POST['txtphr']."', '".$_POST['txtpmin']."', '".$_POST['txtrday']."',  '".$_POST['txtrmonth']."',  '".$_POST['txtrhr']."',  '".$_POST['txtrmin']."', '".$_POST['txtorigin']."', '".$_POST['txtdestination']."',  '".$_POST['txtvehicle']."',  '".$_POST['txtfname']."', '".$_POST['txtlname']."',  '".$_POST['txtemail']."',  '".$_POST['txtcontact']."',  '".$_POST['txtadd']."', '".$_POST['txtzip']."',  '".$_POST['txtcity']."',  '".$_POST['txtcountry']);
  28.  
  29.  
  30.  
  31.  
  32. if (!mysql_query($sql,$conn))
  33.   {
  34.   die('Error: ' . mysql_error());
  35.   }
  36.     header("location:index.html");
  37.  
  38.  
  39. mysql_close($conn)
  40.  
  41.  
  42. /*
  43.     $result=mysql_query($sql);    
  44.     echo $sql;
  45.     echo $result;
  46. */
  47. ?>
  48.  
  49.  
this is the error

Parse error: syntax error, unexpected ')' in C:\xampp\htdocs\msicweb\sdsave.php on line 27
Mar 31 '12 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 1,035
Look a the code below, and try to understand what it does,
After understanding the quotes, you will know how to change your code:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.         $nl="<br>".PHP_EOL;
  3.         print 'This will only print the letter t: t'.$nl;
  4.         print 'This will print the letter t followed by a single-quoot: t\''.$nl;
  5.         print "This will print a single-quoot: '".$nl;
  6.         print "This will print two single-quotes: ''".$nl;
  7.         print 'This will print one single-quote: \''.$nl;
  8.         print 'This should print two single-quotes: \'\''.$nl;
  9.         print 'This will print a double-quoot: "'.$nl;
  10.         print "This will also print a double-quoot: \"".$nl;
  11. ?>
  12.  
Mar 31 '12 #2

P: 35
luuk can you help me pinpoint where is my error cause i already scan my code a couple of times but i still cant get it..
Mar 31 '12 #3

Expert 100+
P: 1,035
the end of line 27:
Expand|Select|Wrap|Line Numbers
  1.  '".$_POST['txtcountry']);
change it to :
Expand|Select|Wrap|Line Numbers
  1.  '".$_POST['txtcountry'].")";
Mar 31 '12 #4

Post your reply

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