Re: $_POST in MySQL query issue...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



$sql="insert into $table set Name = '".$_POST["elementName"]."'";
or even better:
$sql="insert into ".$table." set Name = '".$_POST["elementName"]."'";

But the method both Jake and Bao suggested will also work (temporary var)...
-- 
// DvDmanDT
MSN: dvdmandt@hotmail.com
Mail: dvdmandt@telia.com
"Adam Reiswig" <lists@honorcomputers.com> skrev i meddelandet
3F8F392F.9020201@honorcomputers.com">news:3F8F392F.9020201@honorcomputers.com...
> Greetings to all.  I am trying for the life of me to place a $_POST[]
> variable in my MySQL query.  I am running the latest stable versions of
> PHP, MySQL and Apache 2 on my Win2kPro machine.  My register_globals are
> set to off in my php.ini.  My code I am attempting create is basically
> as follows:
>
> $table="elements";
> $sql="insert into $table set Name = '$elementName'";
>
> This works with register_globals set to on.  But, I want to be able to
> turn that off.  My code then, I am guessing, be something as follows:
>
> $table="elements";
> $sql="insert into $table set Name = '$_POST["elementName"]'";
>
> Unfortunately this and every other combination I can think of,
> combinations of quotes that is, does not work.  I believe the source of
> the problem is the quotes within quotes within quotes. I also tried:
>
> $sql='insert into $table set Name = '.$_POST["elementName"];
>    or
> $sql="insert into $table set Name = ".$_POST['elementName'];
>
> and several other variations.
>
> Can anyone give me some pointers to inserting $_POST[] statements inside
> of query statements?  I am sure there must be a way but I have spent a
> lot of time on this and am really stumped here.  Thanks for any help.
>
> -Adam Reiswig
>
> PS if anything here is not clear to you, please let me know and I'll
> clarify as I can.  Thanks again.

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux