jnerotrix Posted December 10, 2008 Share Posted December 10, 2008 I get this 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 'desc) VALUES ('TEST', 'TEST', 'TEST')' at line 1 TEST TEST TEST is the values i inputted into the form Heres The Code <?php include('header.php'); if (isset($_POST['action'])) { include('info.php'); $host = "$host1"; $user = "$user1"; $pass = "$pass1"; $data = "$data1"; mysql_connect("$host", "$user", "$pass") or die(mysql_error()); mysql_select_db("$data") or die(mysql_error()); $name = mysql_real_escape_string($_POST['name']); $email = mysql_real_escape_string($_POST['email']); $desc = mysql_real_escape_string($_POST['desc']); mysql_query("INSERT INTO requests (name, email, desc) VALUES ('$name', '$email', '$desc')") or die(mysql_error()); echo "<h1>Thank you For Submitting a Request</h1>"; } else { Link to comment https://forums.phpfreaks.com/topic/136287-solved-help-with-php-mysql/ Share on other sites More sharing options...
Caesar Posted December 10, 2008 Share Posted December 10, 2008 If `desc` is a column/field in your database table, you need to surround it with tics. It is a MYSQL reserved word. Link to comment https://forums.phpfreaks.com/topic/136287-solved-help-with-php-mysql/#findComment-710974 Share on other sites More sharing options...
jnerotrix Posted December 10, 2008 Author Share Posted December 10, 2008 can you change the code for me because i tried and it doesnt work Link to comment https://forums.phpfreaks.com/topic/136287-solved-help-with-php-mysql/#findComment-710979 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 mysql_query("INSERT INTO requests (name, email, `desc`) VALUES ('$name', '$email', '$desc')"); Back tcks ` are to the left of the one. Link to comment https://forums.phpfreaks.com/topic/136287-solved-help-with-php-mysql/#findComment-710983 Share on other sites More sharing options...
Caesar Posted December 10, 2008 Share Posted December 10, 2008 Edit: Beat me to it. Link to comment https://forums.phpfreaks.com/topic/136287-solved-help-with-php-mysql/#findComment-710985 Share on other sites More sharing options...
jnerotrix Posted December 10, 2008 Author Share Posted December 10, 2008 :| Now i get this 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 ''desc') VALUES ('Test', 'Test', 'test')' at line 1 Link to comment https://forums.phpfreaks.com/topic/136287-solved-help-with-php-mysql/#findComment-710987 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 :| Now i get this 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 ''desc') VALUES ('Test', 'Test', 'test')' at line 1 You are still using singlequotes ' not backticks ` There is a difference. ` is to the right of the 1 key, above the tab key and below the esc key. The other is next to the ; key and the enter key. Link to comment https://forums.phpfreaks.com/topic/136287-solved-help-with-php-mysql/#findComment-710991 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.