| | |
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2009
Posts: 2
Reputation:
Solved Threads: 0
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
0
#1 Apr 10th, 2009
hi im a newbie at this but im getting a error message that says:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/pickurau/public_html/classes/Lib/Query.php on line 27
and line 27 starts with the if(!mysql_affected_rows() || mysql_num_rows($this->rs) < 1)
return false;
does anyone know how can i fix this error?
heres the script code:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/pickurau/public_html/classes/Lib/Query.php on line 27
and line 27 starts with the if(!mysql_affected_rows() || mysql_num_rows($this->rs) < 1)
return false;
does anyone know how can i fix this error?
heres the script code:
php Syntax (Toggle Plain Text)
<?php class Lib_Query extends Lib_DbConnect { var $rs; var $totrows; var $records; /** * Enter description here... * * @param string $sql * @param array $fields * @return boolean */ function executeQuery($sql, $fields = array()) { //echo $sql,"<br/>"; if(substr_count($sql,'#')!=count($fields)) return false; if(count($fields)>0) $sql = $this->makeQuery($sql,$fields); // Security::makeQuery(); $i=0; $this->rs = mysql_query($sql); if(!mysql_affected_rows() || mysql_num_rows($this->rs) < 1) return false; else { $this->totrows = mysql_num_rows($this->rs); while($fetch = mysql_fetch_array($this->rs)) { $this->records[$i] = $fetch; $i++; } for($i=0;$i<count($this->records);$i++) { foreach ($this->records[$i] as $key=>$item) { if(is_numeric($key)) unset($this->records[$i][$key]); } } return true; } } /** * @param string $sql * @return boolean */ function updateQuery($sql, $fields=array()) { if(substr_count($sql,'#')!=count($fields)) return false; if(count($fields)>0) $sql = $this->makeQuery($sql,$fields); // Security::makeQuery(); $this->rs = mysql_query($sql); if(!$this->rs) return false; else return true; } } ?>
Last edited by peter_budo; Apr 12th, 2009 at 8:45 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
0
#2 Apr 10th, 2009
The query is failing, post the query and we might be able to fix it.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
•
•
Join Date: Apr 2009
Posts: 2
Reputation:
Solved Threads: 0
Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
0
#3 Apr 10th, 2009
what do you mean by post the query? this is the query.php file where its saying the error is its
php Syntax (Toggle Plain Text)
<?php class Lib_Query extends Lib_DbConnect { var $rs; var $totrows; var $records; /** * Enter description here... * * @param string $sql * @param array $fields * @return boolean */ function executeQuery($sql, $fields = array()) { //echo $sql,"<br/>"; if(substr_count($sql,'#')!=count($fields)) return false; if(count($fields)>0) $sql = $this->makeQuery($sql,$fields); // Security::makeQuery(); $i=0; $this->rs = mysql_query($sql); if(!mysql_affected_rows() || mysql_num_rows($this->rs) < 1) return false; else { $this->totrows = mysql_num_rows($this->rs); while($fetch = mysql_fetch_array($this->rs)) { $this->records[$i] = $fetch; $i++; } for($i=0;$i<count($this->records);$i++) { foreach ($this->records[$i] as $key=>$item) { if(is_numeric($key)) unset($this->records[$i][$key]); } } return true; } } /** * @param string $sql * @return boolean */ function updateQuery($sql, $fields=array()) { if(substr_count($sql,'#')!=count($fields)) return false; if(count($fields)>0) $sql = $this->makeQuery($sql,$fields); // Security::makeQuery(); $this->rs = mysql_query($sql); if(!$this->rs) return false; else return true; } } ?>
Last edited by peter_budo; Apr 12th, 2009 at 8:45 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
0
#4 Apr 10th, 2009
I mean post the query. There is a query being passed to the 'executeQuery' function that is incorrect, that is why the function is failing.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
0
#5 Apr 10th, 2009
mysql_num_rows:
Retrieves the number of rows from a result set. This command is only valid for statements like SELECT or SHOW that return an actual result set. To retrieve the number of rows affected by a INSERT, UPDATE, REPLACE or DELETE query, use mysql_affected_rows().
My guess would be that you're passing a fetched result like an array of the query.
Retrieves the number of rows from a result set. This command is only valid for statements like SELECT or SHOW that return an actual result set. To retrieve the number of rows affected by a INSERT, UPDATE, REPLACE or DELETE query, use mysql_affected_rows().
My guess would be that you're passing a fetched result like an array of the query.
•
•
Join Date: Jan 2007
Posts: 164
Reputation:
Solved Threads: 10
Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
0
#6 Apr 11th, 2009
•
•
Join Date: Jan 2007
Posts: 164
Reputation:
Solved Threads: 10
Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
0
#7 Apr 13th, 2009
![]() |
Similar Threads
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in (PHP)
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource (PHP)
Other Threads in the PHP Forum
- Previous Thread: problems with the ids ($_GET)
- Next Thread: displaying query results in a generated pdf doc
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql navigation number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white xml youtube






