dcole.ath.cx Posted September 2, 2007 Share Posted September 2, 2007 Is everything right here? How about this part ... talk (message, response) ... should they have $ in front? If everything is right here, I set up the MySQL wrong.... what could be the problem with that? <?php// Connect to MySQL using this data:$dbhost = 'localhost';$dbuser = 'root';$dbpass = '';$dbname = 'chat';// "talk" is name of MySQL table// Connect to MySQL and a table within it$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');mysql_select_db($dbname);// insert data into MySQL$message = 'Hey';$response = 'Hey';$query = "INSERT INTO talk (message, response) VALUES ($message, $response)";mysql_query($query) or die('Error, insert query failed');print 'Thank you, data has been learned.';?> Link to comment Share on other sites More sharing options...
Synook Posted September 2, 2007 Share Posted September 2, 2007 The string values in the $query have to have quotation marks around them: $query = "INSERT INTO talk (message, response) VALUES ('$message', '$response')"; Remember, you can always echo mysql_error(); to see what is wrong with a query. Link to comment Share on other sites More sharing options...
dcole.ath.cx Posted September 2, 2007 Author Share Posted September 2, 2007 Oops... that is the problem. The code works now, Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.