Database Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesDatabase Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old February 19th, 2005, 04:52 PM
aspiring wings aspiring wings is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 1 aspiring wings User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 28 sec
Reputation Power: 0
PHP Gives Me an Invalid MySQL Resource

If someone could help me out, it would be most appreciated... I am working against a deadline, and this error is driving me crazy.

I have a simple MySQL query, as shown below:

$CreativeCalendars = mysql_pconnect($hostname_CreativeCalendars, $username_CreativeCalendars, $password_CreativeCalendars) || die(mysql_error());
mysql_select_db('ccdb1') || die(mysql_error());
$mysql_result = mysql_query("SELECT code FROM giftcertificateorders") || die(mysql_error());

The above mysql_query returns the integer 1 every time--not 'resource id #1'. So when i try and use $mysql_result in mysql_fetch_assoc() or the like, i get a 'supplied argument is not a valid MySQL result resource' every single time. Yet none of my die(mysql_error()) functions are triggered.

I have double-checked my spelling and the like about twelve times. I can even enter the exact same query into the MySQL Query Browser, and it works fine.

Someone help... please...

Reply With Quote
  #2  
Old August 20th, 2005, 08:40 AM
Saiboogu Saiboogu is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 2 Saiboogu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 17 sec
Reputation Power: 0
Question

No one ever replied? I have practically the same issue - I have the following PHP (just a snippet):
Code:
	$current_player = mysql_fetch_assoc($result);

	$lastseen = "SELECT last FROM users WHERE name='$current_player[name]'";
	$last = mysql_query($lastseen) or die(mysql_error());
	echo "$lastseen <br> $last <br>";
	if($last < time() - 30) {	


My echo statement is just for my troubleshooting purposes. The entire bit is within a for statement, looping through each item retreived via $result - when I echo $lastseen, it produces a valid MySQL query:

Code:
SELECT last FROM users WHERE name=' TheRUNaway' 


And running that query through phpMyAdmin produces the desired result: 1124544537

However, my if statement ALWAYS proves true, and the echo of $last simply shows "Resource id #8" - like the other poster said, my die statement never produces an error.

As I said, this is within a for statement - when I echo the output for troubleshooting, I just wind up with a list like:

Quote:
SELECT last FROM users WHERE name='JAKEYMONKEY'
Resource id #6
SELECT last FROM users WHERE name='Invader~Zim'
Resource id #7
SELECT last FROM users WHERE name=' TheRUNaway'
Resource id #8
SELECT last FROM users WHERE name='[DoC]1snipe'
Resource id #9
SELECT last FROM users WHERE name='JacksSpeedo'
Resource id #10
SELECT last FROM users WHERE name='WIND'
Resource id #11
SELECT last FROM users WHERE name='concon'
Resource id #12
SELECT last FROM users WHERE name='zErO%'
Resource id #13


Sorry for digging up such an old post, but this is one that really has me stumped (need I add that I am VERY new to PHP & MySQL - this is code written originally by someone else, I'm trying to add this additional query & the if statement), and all I'm finding are unanswered posts when I Google it.

Reply With Quote
  #3  
Old August 20th, 2005, 08:59 AM
Saiboogu Saiboogu is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 2 Saiboogu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 17 sec
Reputation Power: 0
As usual, the moment I give up and yell for help, I find the answer. Posting for the next person:

Everything was fine in the above code, except -
In my query, I had to "SELECT * FROM .. "
Stored the query as $last_result, then:
$last = mysql_fetch_assoc($last_result)

Then I could call the 'last' field that I needed with:

$last[last]

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesDatabase Development > PHP Gives Me an Invalid MySQL Resource


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway