Re: Please help with code
| From: | Erik Price | Date: | Mon, 01 Apr 2002 16:35:17 +0000 |
| Subject: | Re: Please help with code | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-90971@lists.php.net to get a copy of this message | ||
On Monday, April 1, 2002, at 11:08 AM, Denis L. Menezes wrote:
$query="INSERT INTO news (newsid,title, author, body, posted)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,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"
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
pricee@hhbrown.com