From: pankaj_rohtas at yahoo dot co dot in
Operating system: windows xp
PHP version: 5.2.4
PHP Bug Type: MySQL related
Bug description: mysql query is not getting executed when i'm using a variable
in query
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 bug report at http://bugs.php.net/?id=42873&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=42873&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=42873&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=42873&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42873&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=42873&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42873&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42873&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42873&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42873&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42873&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=42873&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=42873&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42873&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42873&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42873&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42873&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42873&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42873&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42873&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42873&r=mysqlcfg