Re: problem with INSERT query
| From: | Jason Wong | Date: | Tue, 09 Dec 2003 07:45:27 +0000 |
| Subject: | Re: problem with INSERT query | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-172241@lists.php.net to get a copy of this message | ||
On Tuesday 09 December 2003 15:34, irinchiang@justeducation.com wrote:
> Well, I tried that and this is what i got:
>
> INSERT INTO tutor (tutor_name, tutor_contact, tutor_email, tutor_profile)
> VALUES (''irin'', ''788798878'',
> ''irin@irin.com'', ''no profile'')
> DB Error: syntax error
>
> well, when I echo again, i can successfully see the values I entered. But
> this time there's a "DB syntax error"????
That's most likely because:
$db->quote($_POST["tutor_contact"]
actually adds the single quotes around the original value of
$_POST["tutor_contact"]. Thus your sql construction statement should omit the
the single quotes:
$sql = "INSERT INTO tutor (tutor_name,
tutor_contact,tutor_email,tutor_profile)
VALUES
($tutor_name, $tutor_contact, $tutor_email,
$tutor_profile)";
> and when I went into the database to view, it stil reflect a "NULL"
> value...
Because the above query failed the record still contains its old value.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Interchangeable parts don't, leak proof seals will and self starters wont
-- Murphy's Bush Fire Brigade Laws n20
*/