I have been developing a website on localhost with xampp and everything worked perfect. so i moved to a web host for the first time. I have edited my connection string to fit the web server and it connects fine but when i tried testing the registration page i designed it doesn't insert data into the database. I tried a simple insert statement on a separate script
<!DOCTYPE html>
<html>
<body>
<?php
$conn = mysql_connect("localhost", "my_db_user_name", "my_db_password");
$db = mysql_select_db("my_db_name");
$query1 = mysql_query("INSERT INTO users firstname VALUES 'Patrick'",$conn);
if($query1) {
echo "Yes";
} else {
echo "didn't work";
}
echo mysql_error($query1);
?>
</body>
</html>
It returned the didn't work and didn't insert anything neither did it echo
any error. But when i tried a select statement and echo
the result of the query it worked so its safe to say my connection is valid.
I also went to my cpanel
phpmyadmin
interface and tried the same insert statement it didn't work but returned:
1064 - 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 '
firstname
VALUES 'Patrick'' at line 1.
I tried with and without back ticks the same thing. but i can select query.