php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25210 Invalid resource when using query with derived tables
Submitted: 2003-08-22 09:29 UTC Modified: 2003-08-22 18:51 UTC
From: jack at vanzanen dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.3.2 OS: United Linux 1.0
Private report: No CVE-ID: None
 [2003-08-22 09:29 UTC] jack at vanzanen dot com
Description:
------------
I have installed MYSQL 4.1 with support for derived tables. If I query Mysql with a query that has a subquery in the from clause it works fine. If I now load this query in PHP I get invalid resource error. If I change the select for another select w/o the subquery it works fine (So my php script must be correct).
I have tried PHP 4.3.2/4.3.3 & 5.0

TIA


Jack




Reproduce code:
---------------
http://www.vanzanen.com/source.txt

Expected result:
----------------
I expect the query to produce data that is shown on the screen as a html table

Actual result:
--------------
$result is not a valid resource 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-22 11:05 UTC] magnus@php.net
Use the MySQLi extension which is available in PHP5, dunno about PHP4.
 [2003-08-22 12:04 UTC] georg@php.net
Magnus, 
thats not a problem of ext/mysql or ext/mysqli.  
 
mysql_query returns false, if an error occured (as described in the 
manua!). Check your error with mysql_error or errno. 
 [2003-08-22 16:44 UTC] jack at vanzanen dot com
My err:
I set mysql_error to find out that it was a rights issue. I had to grant the user more rights globally on mysql instead of full rights on it's own database. Apparantly for derived tables a temp table is being created and the user did not have read rights on this one since it was not in his own database.
 [2003-08-22 18:51 UTC] sniper@php.net
Not PHP bug -> bogus. (no more comments please)

 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Feb 11 20:00:02 2026 UTC