Doc #60191 [Fbk->NoF]: wrong result
| From: | danbrown@php.net | Date: | Tue, 01 Nov 2011 14:56:32 +0000 |
| Subject: | Doc #60191 [Fbk->NoF]: wrong result | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-7371@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60191&edit=1
ID: 60191
Updated by: danbrown@php.net
Reported by: j dot veder at advanceu dot nl
Summary: wrong result
-Status: Feedback
+Status: No Feedback
Type: Documentation Problem
Package: *General Issues
Operating System: windows
PHP Version: Irrelevant
Assigned To: danbrown
Block user comment: N
Private report: N
New Comment:
You indicate that you were using mysql_fetch_assoc(), yet your code does not
show it anywhere. Also, if your test script is exactly as shown, you haven't
even created a database link. That said:
<?php
$result = @mysql_query('SELECT * WHERE 1=1');
die(PHP_EOL.var_dump($result).PHP_EOL);
?>
$ php kjh.php
bool(false)
What do you see when you run the code exactly as shown above?
Previous Comments:
------------------------------------------------------------------------
[2011-11-01 13:36:30] anon at anon dot anon
Tried it, and I get "false", and "Invalid query: You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
near 'WHERE 1=1' at line 1".
------------------------------------------------------------------------
[2011-11-01 13:25:39] j dot veder at advanceu dot nl
Description:
------------
---
From manual page: http://www.php.net/function.mysql-query#refsect1-function.mysql-query-examples
---
<?php
$result = mysql_query('SELECT * WHERE 1=1');
if (!$result) {//this does not return false ever!!!!!!!!! returns on fail: 'result
resource(7)' after mysql_fetch_assoc() returns bool(false)
die('Invalid query: ' . mysql_error());
}
?>
Test script:
---------------
<?php
$result = mysql_query('SELECT * WHERE 1=1');
print_r($result);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
?>
Expected result:
----------------
false
Actual result:
--------------
result resource(7)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60191&edit=1