Re: problem transferring a variable using POST
| From: | Tom Rogers | Date: | Thu, 09 Oct 2003 16:07:29 +0000 |
| Subject: | Re: problem transferring a variable using POST | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-165616@lists.php.net to get a copy of this message | ||
Hi,
Friday, October 10, 2003, 1:56:43 AM, you wrote:
DC> I am having a problem with a form. I am trying to have a form pass a
DC> variable so that I can update an item. I think the problem is that the
DC> variable (ticketed) is being read as text instead of a number. These
DC> are the tests I have run.
DC> This statement works:
DC> $sql = 'UPDATE wo SET status = 1 WHERE ticket = 1'
DC> This statement does not:
DC> $sql = 'UPDATE wo SET status = 1 WHERE ticket =
DC> $HTTP_POST_VARS[ticketed]'
DC> Any suggestions...
DC> If I do "echo "$HTTP_POST_VARS[ticketed]";
DC> It returns a 1
if you put variables in the string you need to use double quotes to get PHP to
do the substitution or get out of the string and use the dot operator.
$sql = "UPDATE wo SET status = 1 WHERE ticket = $HTTP_POST_VARS[ticketed]";
$sql = 'UPDATE wo SET status = 1 WHERE ticket = '.$HTTP_POST_VARS[ticketed];
The other good habit is to put the value in single quotes:
$sql = "UPDATE wo SET status = 1 WHERE ticket = '$HTTP_POST_VARS[ticketed]'";
$sql = "UPDATE wo SET status = 1 WHERE ticket =
'".$HTTP_POST_VARS[ticketed]."'";
--
regards,
Tom