Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 14-04-2009
Member
 
Join Date: Nov 2005
Posts: 403
supplied argument is not a valid mysql result resource, help

I have written a code running which returns with an error "supplied argument is not a valid mysql result resource" for:

Code:
<?php
while($row = mysql_fetch_array($result))
{
?>
Can anyone help me out what is wrong here? Thank you
__________________
Don't talk unless you can improve the silence.
Reply With Quote
  #2  
Old 14-04-2009
Member
 
Join Date: Dec 2007
Posts: 1,592
Re: supplied argument is not a valid mysql result resource, help

Your SQL query is failing. Use the or die mysql_error();. This will display the problem.
Code:
<? 
$sql = "SELECT * FROM `mytable` WHERE `id` = '1'"; 

db_connect();//connecting mysql db function i wrote 

$result = mysql_query($sql) or die(mysql_error()); 

while($row = mysql_fetch_array($result)){ 

 // do some thing here 

}  

mysql_close(db_connect()); 
?>
Reply With Quote
  #3  
Old 14-04-2009
Member
 
Join Date: Dec 2007
Posts: 1,542
Re: supplied argument is not a valid mysql result resource, help

This error message indicates that an error occurred in the call to mysql_query, which is indicated by a return of FALSE. FALSE is not a valid resource identifier, and so you get the error shown. When mysql_query returns FALSE, you should echo the error message indicated by mysql_error() to find out what the real error was.
Reply With Quote
  #4  
Old 14-04-2009
Member
 
Join Date: Jun 2006
Posts: 620
Re: supplied argument is not a valid mysql result resource, help

It is possible that the query failed, or that you failed to connect to the database server. Checking for these potential problems and gracefully handling them should be the way to go.

Incidentally, use mysql_num_rows() not mysql_numrows() as the latter is deprecated.

Using "values" as a table name could create problems since values is a mysql keyword. Try changing the table name and see if it starts working.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "supplied argument is not a valid mysql result resource, help"
Thread Thread Starter Forum Replies Last Post
How to calculate cost based on resource rate? I have more than 5 rates per resource boxta Microsoft Project 8 08-05-2012 12:46 PM
The Search Result in Outlook 2007 does not show current years result Shika Windows Software 4 24-04-2012 07:53 AM
How to match MySQL result from keywords? Utpalini Windows Software 5 30-08-2011 09:28 AM
Mysql Error : Can't connect to local mysql server through socket ' var lib mysql mysql.sock' 2 roshan45 Software Development 3 07-11-2009 09:36 PM
How to combine 3 result rows in mysql HAKAN Software Development 3 20-05-2009 10:54 PM


All times are GMT +5.5. The time now is 06:41 AM.