it is giving me headache to write data from a php file to mysql( i can read from the table but cant write) here is my connect.php which connects to mysql:
it is giving me headache to write data from a php file to mysql( i can read from the table but cant write) here is my connect.php which connects to mysql:
[php]
$result = mysql_query("INSERT INTO shoutbox (id,ip,name,url,message,date) VALUES('','$ip','$name','$url','$message','$date')") or die('Error inserting into DB.');
if ($result) {
// ok
echo "Mysql Insert ok";
} else {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
[/php]
the mysql_query() will return false if the query fails, and the last error for your mysql session/connection will be returned by mysql_error()
digital-ether: i tried the error checking but no error is output in meanwhile no data is entered either.
jbennet: that was a good set of files for beginners. I did change the dbinfo.inc.php file, it did create the table when running the php file, but again i cannot insert any data to the table using the dataentry.html file...
I dont know what else to do, do you guys think it is something to do with the mysql version or it is a php error or mine :) ....as it retrieves data from table and creates table but not write any data...