#31175 [NEW]: MySQL query returns no results when run via PHP
| From: | vortexx at freemail dot hu | Date: | Sat, 18 Dec 2004 04:53:26 +0000 |
| Subject: | #31175 [NEW]: MySQL query returns no results when run via PHP | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-70584@lists.php.net to get a copy of this message | ||
From: vortexx at freemail dot hu
Operating system: Windows 2000 Server, SP4
PHP version: 5.0.3
PHP Bug Type: MySQL related
Bug description: MySQL query returns no results when run via PHP
Description:
------------
When a query containing CONCAT(...) with a string plus a reference to a
certain database field is run via PHP, no results and nop errors are
returned. The exact same query run via MySQL commandline returns results
as expected.
With 5.0.2 the exact same script (with ALL PHP configs the same, even the
same PHP.INI) returns results as expected. Thus I believe this is not
MySQL related but rather related to PHP5.0.3 and the php_mysql.dll
included with it?!
I also tried the latest PHP snapshot, but the same thing happens.
Not sure what other info might be relevant and needed, I would be glad to
provide whatever info you may find necessary.
Reproduce code:
---------------
<%
/// Omitting the mysql_connect part of the code...!
/// This returns no results under PHP5.0.3,
/// while under PHP5.0.2 it returns results as expected.
$query = "SELECT CONCAT(tel,'blabla') as tel from hotels where
id='$id'";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
print_r($row);
/// This, however, works!
/// Difference is that two ***fields*** are CONCAT-ed.
$query = "SELECT CONCAT(tel,name) as tel from hotels where id='$id'";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
print_r($row);
/// This also works!
/// This time two ***strings*** are CONCAT-ed.
$query = "SELECT CONCAT('just test','blabla') as tel from hotels where
id='$id'";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
print_r($row);
%>
Expected result:
----------------
I should get the telephone number of the hotel joined with the string
"blablabla".
Actual result:
--------------
Get no results from the MySQL query, but no errors either (MySQL or PHP).
--
Edit bug report at http://bugs.php.net/?id=31175&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31175&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31175&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31175&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31175&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31175&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31175&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31175&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31175&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31175&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31175&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=31175&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=31175&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31175&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31175&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31175&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31175&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31175&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31175&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31175&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31175&r=mysqlcfg