On Monday, April 1, 2002, at 11:08 AM, Denis L. Menezes wrote:
> $query="INSERT INTO news (newsid,title, author, body, posted)
> VALUES($newsid,$title, $author, $body, UNIX_TIMESTAMP())";
> IF (mysql_query($query)){
> print "Row added to table";
> } else {
> print "error adding row";
> }
> ?>
>
>
> It gives the link ID. But then gives "error adding row"
If you are inserting a value into a string-type column, then it must be
quoted. I recommend you change your query to look like this:
$query = "INSERT INTO news (newsid,
title,
author,
body,
posted)
VALUES ($newsid,
'$title',
'$author',
'$body',
UNIX_TIMESTAMP()
)";
I've made the (possibly incorrect) assumption that your newsid column is
not a string-type column, so I didn't quote the variable -- but you
could, and it should still insert as normal.
And yes, you can structure your query this way for legibility since
whitespace is ignored (if you want).
Erik
----
Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php