Jump to content

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?
Link to comment
https://forums.phpfreaks.com/topic/14096-mysql-query-not-returning-as-a-resource/
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!
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.