This is a discussion on problem with INSERT query within the PHP General forums, part of the PHP Programming Forums category; irinchiang@justeducation.com schrieb: > > Thanks alot for your help!!! > It was only a spacing mistake... > There ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
irinchiang@justeducation.com schrieb:
> > Thanks alot for your help!!! > It was only a spacing mistake... > There should have no spacing in between each variables: > > VALUES ($tutor_name,$tutor_contact,$tutor_email,$tutor_pr ofile)"; hi, a space after a comma shouldn't be a problem. your problem were probably your single quotes. it's a different between " ... VALUES ('$tutor_name', ...)"; and " ... VALUES ($tutor_name, ...)"; hth SVEN |
|
|||
|
In article <1070953110.3fd57296a445b@www.justeducation.com> ,
irinchiang@justeducation.com says... > > > Hi all, > I am trying to do a simple INSERT data into the database using the following > php script but the problem here is that whenever I click "submit", the script > only insert a "NULL" value into the columns into the datadase instead the > value I enter in the forms field....SELECT query was successful but not > INSERT.. > > A snip of the code are as follow: > > <?php > //declare error variable > $err = ""; > > //set error variable > $err .= check_tutor_name(); > $err .= check_tutor_contact(); > $err .= check_tutor_email(); > $err .= check_tutor_profile(); > > //define connection string > $dsn = "mysql://root:********@localhost/table1"; > > //connect to DB > $db = DB::connect ($dsn); > //check for any DB connection errors > if (DB::isError ($db)) > die ($db->getMessage()); > > $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"]); I think your problem might be in the above lines; the superglobal variable is $_POST{'whatever'} - note the underscore in the name. <SNIP code>> > > So, what could be the problem with the code I have wriiten??? > Any help are appreciated. > > > Irin. > Cheers -- Quod subigo farinam A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? |
|
|||
|
irinchiang@justeducation.com schrieb: > > Thanks alot for your help!!! > It was only a spacing mistake... > There should have no spacing in between each variables: > > VALUES ($tutor_name,$tutor_contact,$tutor_email,$tutor_pr ofile)"; hi, a space after a comma shouldn't be a problem. your problem were probably your single quotes. it's a different between " ... VALUES ('$tutor_name', ...)"; and " ... VALUES ($tutor_name, ...)"; hth SVEN ------------------------------------------------------------------------------- - So what was actually the difference between having "single quotes" for my string and without single quotes ??? Irin. |