I've installed xampp so that I can test my pages on my comp, and am trying to get to grips with MySQL. I've created the database, and a table within the database, but it just won't write to it. Here's the code:
CODE
else {
$DBhost = "localhost";
$DBuser = "robertsworder_ro";
$DBpass = "mypassword";
$DBName = "robertsworder_gu";
$table = "guestbook";
if (mysql_connect($DBhost, $DBuser, $DBpass) === FALSE) {
$file = "failbook.html";
}
else {
$db = mysql_connect($DBhost, $DBuser, $DBpass);
mysql_select_db($DBName, $db);
$sqlquery = "INSERT INTO $table VALUES ('date('d/m/y')','$name','$comments','0')";
mysql_query($sqlquery);
mysql_close();
$file = "guestbook.html";
}
$DBhost = "localhost";
$DBuser = "robertsworder_ro";
$DBpass = "mypassword";
$DBName = "robertsworder_gu";
$table = "guestbook";
if (mysql_connect($DBhost, $DBuser, $DBpass) === FALSE) {
$file = "failbook.html";
}
else {
$db = mysql_connect($DBhost, $DBuser, $DBpass);
mysql_select_db($DBName, $db);
$sqlquery = "INSERT INTO $table VALUES ('date('d/m/y')','$name','$comments','0')";
mysql_query($sqlquery);
mysql_close();
$file = "guestbook.html";
}
Obviously there is more code above, but it's not related to MySQL at all, and I've tested it previously (This data used to go to a .txt file!).
What makes this more confusing is that I am getting the guestbook.html code (I have an include further down), so it's going through the correct path, just not writing to the database.
Hope someone can help,
swordz