Re: [PHP] $_POST in MySQL query issue...

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

 





Adam Reiswig wrote:


$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"]'";

I see you can achieve this by two ways:


1. Take out all the inside quotes (single or double) like the following:

$sql="insert into $table set Name = $_POST[elementName]";

2. Use a temporary variable for $_POST[elementName], like $elementName = $_POST[elementName], then continute use your original SQL sentence when the register_globals was on.

Best

Bao

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:

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