Jump to content

Archived

This topic is now archived and is closed to further replies.

vnought

MySQL Query not Returning as a Resource

Recommended Posts

Hey all,

I'm having a little problem with PHP and its mysql commands, I've set up apache 2.2 with php 5, installed coldfusion on it, and datasource access worked fine. Then I went over to PHP, and I tried to recreate the exact same thing as is present in the CFML version... So far so good.

And then I get to a point where mysql_* commands beyond mysql_pconnect/connect get me a 'not a valid resource' error!

I've done some tinkering and it turns out that the mysql_* commands (with exception to the connect and pconnect functions) return a boolean rather then a resource!

[code]
$db = mysql_pconnect( $host, $user, $pass ) or die(mysql_error());
mysql_select_db( 'dbinventory', $db );

$q_INV = "SELECT * FROM tblMedia";

# Returns a boolean, but I want it to return a resource!
$rs_INV = mysql_query( $q_INV, $db );
$rs_INV_rows = mysql_num_rows( $rs_INV );
$rs_INV_cols = mysql_num_fields( $rs_INV );
[/code]

Simple no? But, as I tried our rs_INV with the is_resource and is_bool, it comes out boolean regardless of what I try.

Any suggestions?

Share this post


Link to post
Share on other sites
Try putting [code] or die(mysql_error())[/code] after the mysql_query so it becomes [code]$rs_INV = mysql_query( $q_INV, $db ) or die(mysql_error());[/code] and see if it returnss any error.

Share this post


Link to post
Share on other sites
Agreed... that bool is probably FALSE, indicating an error.

Share this post


Link to post
Share on other sites
[quote author=Daniel0 link=topic=99960.msg394006#msg394006 date=1152457437]
Try putting [code] or die(mysql_error())[/code] after the mysql_query so it becomes [code]$rs_INV = mysql_query( $q_INV, $db ) or die(mysql_error());[/code] and see if it returnss any error.
[/quote]

Thanks Daniel, silly that I didn't think of that sooner! But yea, cleared up the problem and I fixed it (user wasn't permitted to access remotely).

Thanks!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.