473,772 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysql_num_rows( ): supplied argument is not a valid MySQL result resource

27 New Member
Hi! I'm completely new to all dev and trying to put a website together using MySQLI and PHP; was running fine until I try to gather the DB content with the following script:

Expand|Select|Wrap|Line Numbers
  1. <?
  2. $username="xxxxxx";
  3. $password="xxxxxx";
  4. $database="maxalien_davidloran";
  5.  
  6. mysql_connect(localhost,$username,$password);
  7. @mysql_select_db($database) or die( "Unable to select database");
  8. $query="SELECT * FROM contacts";
  9.  
  10. $result=mysql_query($query);
  11.  
  12. $num=mysql_num_rows($result);
  13.  
  14.  
  15. mysql_close();
  16.  
  17. echo "<b><center>Database Output</center></b><br><br>";
  18.  
  19. $i=0;
  20. while ($i < $num) {
  21.  
  22. $username=mysql_result($result,$i,"username");
  23. $password=mysql_result($result,$i,"password");
  24. $email=mysql_result($result,$i,"email");
  25.  
  26. echo "<b>$first $last</b><br>Phone: $phone<br>Mobile: $mobile<br>Fax: $fax<br>E-mail: $email<br>Web: $web<br><hr><br>";
  27.  
  28. $i++;
  29. }
  30.  
  31. ?>
  32.  
getting the following error mesg when running it:

Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in /home/maxalien/public_html/davidloran/test/userCake/dbresult.php on line 12
Database Output

Let me know if you need more info and thx for your help
Jan 2 '10 #1
2 3230
macdalor
27 New Member
is anyone able to help please?
Jan 3 '10 #2
code green
1,726 Recognized Expert Top Contributor
Something is failing here
Expand|Select|Wrap|Line Numbers
  1. mysql_connect(localhost,$username,$password); 
  2. @mysql_select_db($database) or die( "Unable to select database"); 
  3. $query="SELECT * FROM contacts"; 
  4.  
  5. $result=mysql_query($query); 
  6.  
  7. $num=mysql_num_rows($result); 
  8.  
You can help yourself by removing the error supression '@' and
testing the returns using if() and mysql_error().

Also, further down you are closing the database connection then continuing to use it
Jan 4 '10 #3

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

Similar topics

5
21539
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 1 2 3 4 5
4
2110
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 = mysql_query($query, $db_conn); $num = mysql_num_rows($result); echo $num;
4
1754
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 result resource in /opt2/home3/mitas/public_html/register.php on line 86 It seems to be only this function mysql_num_rows() causing a problem, and the rest of the code works ok, and it adds data correctly.
7
1918
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 server it says: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/optikara/public_html/crosun/izn/insert_form.php on line 80
3
3919
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"> <div class="boxhead" style="text-align:center;"> <strong>Menu</strong> </div> <br /> <?php require ('includes/db_conn.inc.php'); $query = "select * from menu order by item_order"; $result = mysql_query($query);
4
7836
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 fields Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 34 Sorry You failed to enter the correct old password I was wondering if anyone could help me, I have...
4
5031
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 check login details. Here is the code for the pages that i used. main_login.php <html> <body>
4
3630
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 tournament or not when they register and attempt to join. I'm doing it locally at the moment so i don't need to upload every 5 minutes. Any assistance would be appreciated. On register.php, I am receiving the following error: Warning:...
11
3720
matheussousuke
by: matheussousuke | last post by:
I'm having the following trouble: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mghosped/public_html/anuncieaki/lib/func_common.php on line 149 This is the line 149 for ($i=1; $i<mysql_num_rows($result); $i++ )
0
9621
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.