php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #60191 wrong result
Submitted: 2011-11-01 13:25 UTC Modified: 2011-11-01 14:56 UTC
From: j dot veder at advanceu dot nl Assigned: danbrown (profile)
Status: No Feedback Package: *General Issues
PHP Version: Irrelevant OS: windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: j dot veder at advanceu dot nl
New email:
PHP Version: OS:

 

 [2011-11-01 13:25 UTC] 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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-01 13:36 UTC] 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 14:50 UTC] danbrown@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: danbrown
 [2011-11-01 14:56 UTC] danbrown@php.net
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?
 [2011-11-01 14:56 UTC] danbrown@php.net
-Status: Feedback +Status: No Feedback
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 07:01:30 2024 UTC