bad_brain Posted June 5, 2008 Share Posted June 5, 2008 Hi guys, I hope someone can help a total lame noob like me :-X I have been trying to make a form with the details entered into a SQL database. <?php $username= $_POST['username'] ; $offence = $_POST['offence'] ; $punishment=$_POST['punishment']; $offencetext=$_POST['offence_text']; $dbhost= 'localhost'; $dbuser = 'root'; $dbpass = 'a'; $conn=mysql_connect($dbhost,$dbuser,$dbpass) or die('Sorry T, error!'); if ($conn){ echo 'Connected to MySQL';} mysql_select_db("offender_list")or die(mysql_error()); $query=mysql_query("INSERT INTO 'watch_list' ('sername, offence,punishment,offencetext)VALUES('$username','$offence','$punishment','$offencetext')") or die(mysql_error()); if($query){echo "Your information has been successfully added to the database.";} else {echo mysql_error();} // remove mysql_error() before final version is completed ?> I keep getting an error....when I run the query through MYSQL Adminstrator, it says: "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 'mysql_query(INSERT INTO watch_list ('username', 'offence','punishment','offence_' at line 1" I really do not know what is wrong with my code....and it is driving me nuts. I am really keen to get this working, because it is (imo) a really powerful tool. Im sorry if it is something really obvious but any help will be much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/108824-help-please-phpsql-wont-work/ Share on other sites More sharing options...
TLawrence Posted June 5, 2008 Share Posted June 5, 2008 Try removing the quotes around the table name in the sql statement. Also, remove the single quote in front of sername in the sql statement. Quote Link to comment https://forums.phpfreaks.com/topic/108824-help-please-phpsql-wont-work/#findComment-558249 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.