Re: What is diff between SQL .... VALUES ($a.$b) and SQL .... VALUES (a,b)?
| From: | Alexander Skwar | Date: | Mon, 03 Sep 2001 19:39:04 +0000 |
| Subject: | Re: What is diff between SQL .... VALUES ($a.$b) and SQL .... VALUES (a,b)? | ||
| References: | 1 2 3 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-1424@lists.php.net to get a copy of this message | ||
So sprach »Jan Holland« am 2001-09-03 um 20:43:03 +0200 :
> A.
> $sql = "INSERT INTO messages (timestamp, n10cybername ,
> n12msgpub)";
> $sql .= "VALUES (unix_timestamp() , n10cybername ,
> n12msgpub )";
> gives
> "Your data were successfully saved."
> but ......
> empty fields in the tablerow :-(
Sure, neither MySQL nor PHP know anything about n10cybername; you forgot
the $ again.
> gives:
> MySQL Error: 1064 (You have an error in your SQL syntax
> near ' '', )' at line 1)
Well, does the string you're trying to insert contain spaces? If so,
you need to quote the string.
> $sql .= "VALUES (unix_timestamp() . $n10cybername .
> $n12msgpub )";
> gives:
> MySQL Error: 1064 (You have an error in your SQL syntax near '.
> '10 Cybername', . '', )' at line 1)
Sure, you're trying to insert the current timetamp + '.' + the value of
$n10cybername + '.' + the value of $n12msgpub into the first column, which you
named "timestamp".
You mixed up the use of , and . again, which makes mysql see only one
value, where you told it, that it has to put three columns.
> (BTW, where can i find the meaning of errorcode 1064? )
Hmm, haven't found anything, but I'd take a close look at the manual.
> I hope my cases are specific enough
> to describe my problem(s)
Yes, quite clearly. You should read some tutorials on PHP and MySQL.
Don't get me wrong, but it seems like you don't know PHP + MySQL.
Alexander Skwar
--
How to quote: http://learn.to/quote (german) http://quote.6x.to (english)
Homepage: http://www.digitalprojects.com | http://www.iso-top.de
iso-top.de - Die günstige Art an Linux Distributionen zu kommen
Uptime: 12 hours 29 minutes