#42873 [Opn->Bgs]: mysql query is not getting executed when i'm using a variable in query
| From: | johannes@php.net | Date: | Sat, 06 Oct 2007 10:06:03 +0000 |
| Subject: | #42873 [Opn->Bgs]: mysql query is not getting executed when i'm using a variable in query | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-118255@lists.php.net to get a copy of this message | ||
ID: 42873
Updated by: johannes@php.net
Reported By: pankaj_rohtas at yahoo dot co dot in
-Status: Open
+Status: Bogus
Bug Type: MySQL related
Operating System: windows xp
PHP Version: 5.2.4
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Check mysql_error() and learn about the difference between double and
single quotes.
Previous Comments:
------------------------------------------------------------------------
[2007-10-06 06:39:06] pankaj_rohtas at yahoo dot co dot in
Description:
------------
$query = 'SELECT * FROM emp WHERE empid="$empid"' ;
query is not getting executed if i'm using $empid as variable.
if i'm providing direct empid which i have defined as INT then it is
working good.
Reproduce code:
---------------
$empid=FALSE;
$ename=FALSE;
$dept=FALSE;
$sal=FALSE;
$empid=$_POST["empid"];
$ename=$_POST["ename"];
$dept=$_POST["dept"];
$sal=$_POST["salary"];
If ($empid==TRUE)
{
$query = 'SELECT * FROM emp WHERE empid="$empid"' ;
$result = mysql_query($query) or die('Query failed: ' .
mysql_error());
//echo "$result";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "\t<tr>\n";
foreach ($line as $col_value)
{
echo "\t\t<td align=center>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
//Free resultset
mysql_free_result($result);
Expected result:
----------------
full details about that row...
Actual result:
--------------
getting blank page
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42873&edit=1