Page 1 of 1

mysql Query format wrong

Posted: Mon Sep 18, 2006 2:41 pm
by danharibo

Code: Select all

$sql = "INSERT INTO guestbook (name,comment,e-mail) VALUES ('$name','$comment','$email')";
Whats wrong with it? Mysql Don't like it :( and i can't see anyhing wrong with it

Posted: Mon Sep 18, 2006 2:43 pm
by volka
Maybe mysql wants to tell you something about the query

Code: Select all

$sql = "INSERT INTO guestbook (name,comment,e-mail) VALUES ('$name','$comment','$email')";
$result = mysql_query($sql, $dblink) or die(mysql_error() . ' : ' . $sql);
see http://de2.php.net/mysql_error

My guess: dashes are not allowed in un-quoted field names. e-mail :arrow: `e-mail`

Posted: Mon Sep 18, 2006 3:01 pm
by danharibo
oh yeah, i forgot about that ( :roll: )

Posted: Mon Sep 18, 2006 3:04 pm
by danharibo
mysql_error shows nothing :?:

Posted: Mon Sep 18, 2006 3:07 pm
by volka
And this one

Code: Select all

$sql = "INSERT INTO guestbook (name,comment,e-mail) VALUES ('$name','$comment','$email')";
echo 'mysql_query: ', $sql; flush();
$result = mysql_query($sql, $dblink);
if ( false===$result) {
	die(mysql_error() . ' : ' . $sql);
}
else {
	echo 'query successful, affected rows: ', mysql_affected_rows();
}
prints ...?