|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-12-14 09:11 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 21:00:01 2025 UTC |
Description: ------------ When sending the MySQL query through the mysql_query() function, MySQL does not send back a result set. But when echoing out the $sql statement and running it directly into the MySQL database via PHPMyAdmin or another tool, the query comes back with the intended results. Also, running a mysql_error(); outputs nothing. So this lead me to believe it was a bug in PHP. Reproduce code: --------------- define("DB_ADDY","localhost"); define("DB_USER","icesnak_eqitems"); define("DB_PW","trademasters"); define("DB_DB","icesnak_eqitems"); function find_item($types,$terms){ if((!empty($types))&&(!empty($terms))){ $types[] = "stock"; $terms[] = "instock"; $dblink = mysql_connect(DB_ADDY,DB_USER,DB_PW); mysql_select_db(DB_DB,$dblink); $sql = "SELECT * FROM `items` WHERE `". $types[0]. "` LIKE '%". $terms[0]. "%' ORDER BY `itemname` ASC"; $result = mysql_query($sql,$dblink); if(mysql_num_rows($result)){ echo 'Something'; } else { echo 'Nothing'; } } } Expected result: ---------------- I would expect to get the output of "Something" since there are multiple rows in the database that match the search criteria. I think this issue has to do with the use of the "%" wildcard character... Actual result: -------------- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mystuff/public_html/core/core/EQItems.php on line 73 Nothing