+ 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); ?>

21st Mar 2018, 10:32 PM
Mogammad Shameer Losper
Mogammad Shameer Losper - avatar
5 odpowiedzi
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.
22nd Mar 2018, 4:39 PM
Jean-louis du Plessis
Jean-louis du Plessis - avatar
0
Does the query work when executed directly using sql dev environment?
22nd Mar 2018, 5:01 PM
Gerge
Gerge - avatar
0
If you have MySQL server installed, you should be able to insert the command into the console.
22nd Mar 2018, 6:45 PM
Jean-louis du Plessis
Jean-louis du Plessis - avatar
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
22nd Mar 2018, 6:47 PM
Mogammad Shameer Losper
Mogammad Shameer Losper - avatar
0
Good to know you got it sorted.
23rd Mar 2018, 11:42 AM
Jean-louis du Plessis
Jean-louis du Plessis - avatar