asherinho Posted August 1, 2007 Share Posted August 1, 2007 i am havin this error and i dnt know what is its cause. 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 ') VALUES('asheri','student','[email protected]','1', 'preety good')' at line 1 here are the codes: <?php $db=mysql_connect("localhost","root"); if (!$db){ echo"Could not connect: " . mysql_error();} mysql_select_db("trials",$db); $query="INSERT INTO viewz(name,title,mail,choice,comments,) VALUES('$_POST[name]','$_POST[title]','$_POST[mail]','$_POST[choice]', '$_POST[comments]')"; $result=mysql_query($query); if(!$result){echo "error:".mysql_error();} echo "<br><a href='views.html'>back to the form</a>"; ?> Link to comment https://forums.phpfreaks.com/topic/62805-can-you-help-me-please/ Share on other sites More sharing options...
clearstatcache Posted August 1, 2007 Share Posted August 1, 2007 not sure wd ds....but try ds 1... <?php $db=mysql_connect("localhost","root"); if (!$db){ echo"Could not connect: " . mysql_error();} mysql_select_db("trials",$db); $query="INSERT INTO viewz(name,title,mail,choice,comments,) VALUES('".$_POST[name]."','".$_POST[title]."','".$_POST[mail]."','".$_POST[choice]."', '".$_POST[comments]."')"; $result=mysql_query($query); if(!$result){echo "error:".mysql_error();} echo " <a href='views.html'>back to the form[/url]"; ?> Link to comment https://forums.phpfreaks.com/topic/62805-can-you-help-me-please/#findComment-312638 Share on other sites More sharing options...
DeadEvil Posted August 1, 2007 Share Posted August 1, 2007 $query="INSERT INTO viewz(name,title,mail,choice,comments,) VALUES('{$_POST['name']}','{$_POST['title']}','{$_POST['mail']}','{$_POST['choice']}', '{$_POST['comments']}')"; to check print $query; exit; Link to comment https://forums.phpfreaks.com/topic/62805-can-you-help-me-please/#findComment-312654 Share on other sites More sharing options...
rotto Posted August 1, 2007 Share Posted August 1, 2007 There is a comma "," after "comments" in your sql query that is giving the error. Remove it and try again. Link to comment https://forums.phpfreaks.com/topic/62805-can-you-help-me-please/#findComment-312686 Share on other sites More sharing options...
asherinho Posted August 1, 2007 Author Share Posted August 1, 2007 thanks rotto it worked,thanks to others also cause i got new ways to insert data. Link to comment https://forums.phpfreaks.com/topic/62805-can-you-help-me-please/#findComment-312734 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.