473,385 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

mysql_num_rows Error. Suplied argument is not a valid MySQL resource.

Hi,

I gotta dum kweschin.

Here's muh code:
Expand|Select|Wrap|Line Numbers
  1. class dbServer{
  2. ...
  3. public function &executeDBCOMMAND($SQL=";"){
  4.  
  5. $result = mysql_query($SQL);
  6.  
  7. }
  8.  
  9.        public function connect(){
  10.                 echo 'Connecting to server ' . $this->servername . '<br>';
  11.                 $this->dbconnection = mysql_connect($this->servername,$this->username,$this->password);
  12.                 if(!$this->dbconnection){
  13.                         throw new Exception("did not connect");
  14.                 }
  15.                 return true;
  16.         }
  17.  
  18. ...
  19. }
  20.  
  21.  
  22. $s=$d=$t="x";
  23.  
  24. $s = new dbServer("localhost","__MUNGED__","__MUNGED__") or die ("no dbserver");
  25. if($s<>'x') $s->connect() or die ("no dbserver");
  26.  
  27. if($s<>'x') $d = new dbDatabase("__MUNGED__") or die ("no database");
  28. if($d<>'x') $d->connect() or die ("no database");
  29.  
  30. if($d<>'x') $t = new dbTable("Table1") or die("no table");
  31.  
  32. if($t<>'x')
  33. {
  34. try{
  35.         $result =& $s->executeDBCOMMAND("show tables;");
  36.  
  37.  
  38. ///////////////////////////////////////////////////////////////
  39. //LINE 184         (where the error is)
  40. ///////////////////////////////////////////////////////////////
  41. $num=mysql_numrows($result) or die('<hr />MySQL Error: ' 
  42. .mysql_error(). '<hr />');
  43. ///////////////////////////////////////////////////////////////
  44.  
  45. ...
  46. }
  47. catch{...}
  48. ...
  49. ?>
  50.  
So when I run it, I get the following error:

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /nfsexport/var/www/doc_root/info/no-ip/yourwebsite/jpenney/phpfiles/fieldlib.php on line 184

I think it's a problem with returning the reference, but I'm not sure. Any hints?

Thanks,

JP
Sep 8 '07 #1
4 2213
Atli
5,058 Expert 4TB
Hi JP, and welcome to TSDN!

I've changed the title of this thread to better describe it's topic.
Using good, descriptive titles that follow the Posting Guidelines will increase your chances of getting your questions answered!

Also, remember to use [code] tags when posting code. It is nearly impossible to read it without them.

Moderator
Sep 8 '07 #2
Atli
5,058 Expert 4TB
What this means is that the $result your database object is returning to you is not a valid MySQL resource.
The most common reason for this is invalid queries. If you query fails the mysql_query() function will return FALSE, which is not a valid MySQL resource.

You should always check if the $result returned by a query is valid before trying to use it.

Also, in the executeDBCOMMAND method, you should include the dbconnection as a second parameter in the mysql_query() function.

P.S. executeDBCOMMAND is a horrible method name :)
Sep 8 '07 #3
Don't return by reference in a function especially in an object(PHP online docs tell you specifically not to do it.). Change your code to return $result in your execute method. And don't assign it by reference. You are currently attempting to get the rows of a reference not a MySQL ID.
Sep 8 '07 #4
Thank you all for your help. I guess I need to hit the books a little more.

JP
Sep 9 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Arjan | last post by:
I've got the following error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/wbdfdart/public_html/wbdfforum/verwijder.php on line 13 verwijder.php ...
4
by: David Nikel | last post by:
I am attempting to create a login script. The following snippet of code: $query = "select * from auth where username='$username' and password=password('$password')"; $result =...
4
by: Fish44 | last post by:
Ive got the following code which works great on my localserver, but when i upload it to my service provider i get an error "Warning: mysql_num_rows(): supplied argument is not a valid MySQL...
7
by: Dejan | last post by:
Hi Sorry for my terreble english. On my local (win) comp i have apache+mysql+php 4.05 I'm counting rows using mysql_num_rows function, and everything works fine. When i upload php file on...
3
by: petemaxi | last post by:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\tockholes\includes\menu.inc.php on line 9 <div class="left"> <div class="menu">...
3
The1corrupted
by: The1corrupted | last post by:
Okay, this has blown my entire perception of reality way out of order. First, a page was working and not five minutes later, I get this error, Warning: mysql_num_rows(): supplied argument is...
4
by: Ryanlawrence1 | last post by:
Heya, I get these 2 errors: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 20 You have not entered all the...
4
by: fisherd | last post by:
When i run this code, i keep getting this message; Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\checklogin.php on line 26 i use this code to...
4
by: seigaku | last post by:
Hi everyone, I've recently begun learning PHP and it looks like I took on too much so soon. I'm attempting to fix a php script that detects whether or not a person is Eligible to join a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.