newbie question: my script doesn't work

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
thomasd1
Forum Commoner
Posts: 80
Joined: Sat Nov 22, 2003 2:48 pm
Location: Belgium

newbie question: my script doesn't work

Post 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";
?>
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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')";
User avatar
thomasd1
Forum Commoner
Posts: 80
Joined: Sat Nov 22, 2003 2:48 pm
Location: Belgium

Post by thomasd1 »

thanks it works now :oops:
Post Reply