Re: problem with INSERT query
| From: | Viraj Kalinga Abayarathna | Date: | Tue, 09 Dec 2003 07:46:52 +0000 |
| Subject: | Re: problem with INSERT query | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-172242@lists.php.net to get a copy of this message | ||
VALUES (''irin'', ''788798878'', ''irin@irin.com'', ''no profile'')
in above line, note the two quotes, in both side of each value.. this is
the cause to your DB syntax error.. correct the above line as follows...
($tutor_name,$tutor_contact,$tutor_email,$tutor_profile)";
and try, but investigate for "why you are getting two quotes instead of
one quote.
Viraj
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"???? and when I went into the database to view, it stil reflect a "NULL" value... ------------------------------------------------------------------------------- On Tuesday 09 December 2003 15:20, irinchiang@justeducation.com wrote:This is what I get after I "echo" my query statement: INSERT INTO tutor (tutor_name, tutor_contact, tutor_email, tutor_profile) VALUES ('NULL', 'NULL', 'NULL', 'NULL') How come the value is null??? In my INSERT query, I already state my value variable to be the name of the fields in my html. Why is it still inserting "NULL" into the database when I have entered values in the HTML fields????? $sql = "INSERT INTO tutor (tutor_name, tutor_contact,tutor_email,tutor_profile)VALUES ('$tutor_name', '$tutor_contact', '$tutor_email', '$tutor_profile')";What could be the problem??You most probably be wanting to use $_POST instead of $POST.$tutor_name = $db->quote($POST["tutor_name"]); $tutor_contact = $db->quote($POST["tutor_contact"]); $tutor_email = $db->quote($POST["tutor_email"]); $tutor_profile = $db->quote($POST["tutor_profile"]);