problem with INSERT query

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 12-09-2003
Sven
 
Posts: n/a
Default Re: [PHP] problem with INSERT query

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
Reply With Quote
  #12 (permalink)  
Old 12-10-2003
David Robley
 
Posts: n/a
Default Re: problem with INSERT query

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?
Reply With Quote
  #13 (permalink)  
Old 12-10-2003
irinchiang@justeducation.com
 
Posts: n/a
Default Re: [PHP] problem with INSERT query



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.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:50 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0