+ 1
Sql Insert into database table using php , is not working
I have checked all the names and variable names, they all correct, its still not working. I hope i dont have to paste my entire code, as it is alot. Hopefully this is enough for you to see the problem . Please help. code: <?php $conn =mysql_connect('127.0.0.1','root','password','shop'); mysql_select_db("shop",$conn); $sql="INSERT INTO feedback (Name, Email, Subject Matter ,Message) //table name=feedback VALUES ('$first_name','$email_from ','$subjectMatter','$Message')"; $result=mysql_query($sql,$conn); ?>
5 Answers
0
Please post the error you recieved.
if you are using PHP 7 you would get a deprication error, in that case you would need to use MySQLi of PDO to connect to the database.
0
Does the query work when executed directly using sql dev environment?
0
If you have MySQL server installed, you should be able to insert the command into the console.
0
Hi, thank you for replying but i found the main error lol. In my sql database, i had a table with a column name that included a space , the column name was "Subject Matter". After i changed the name to Subject_Matter, the code worked lol. It took me the entire day, to figure that out. In addition, i changed my code many times because of that. Fortunately its solved
0
Good to know you got it sorted.