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 { Quote 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. Quote 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 Quote 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. Quote 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. Quote 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 Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.