Page 1 of 1

newbie question: my script doesn't work

Posted: Wed Dec 24, 2003 5:43 am
by thomasd1
This is the code that "should" send my guestbook-data to my DB.
When i push the submit button everything goes normal (message succesfully entered), the data does not get inserted... (sorry for my bad english)
(i CAN on the otherhand, read data out of the DB, (data i inserted using mySQL Control center))

Code: Select all

<?php
//prepare variables:
$name = $_GET["name"];
$email = $_GET["email"];
$datetime = date("Y.m.d g:i:s");
$message = $_GET["message"];

//send to DB
$db = mysql_connect($dbhost,$dbuser);	//DB link_identifier
mysql_select_db($mydb,$db);	//Select DB
$query = "INSERT INTO guestbook(id, name, email, datetime, message VALUES(, '$name', '$email', '$datetime', '$message')";
$result = mysql_query($query);

echo "Message successfully entered";
?>

Posted: Wed Dec 24, 2003 5:51 am
by Weirdan
You missed closing parenthesis in the query:

Code: Select all

// was
$query = "INSERT INTO guestbook(id, name, email, datetime, message VALUES(, '$name', '$email', '$datetime', '$message')";
// should be
$query = "INSERT INTO guestbook(id, name, email, datetime, message) VALUES(NULL, '$name', '$email', '$datetime', '$message')";

Posted: Wed Dec 24, 2003 5:10 pm
by thomasd1
thanks it works now :oops: