473,696 Members | 1,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htd ocs\tockholes\i ncludes\menu.in c.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($qu ery);
$num_results = mysql_num_rows( $result); <--- HERE!
for ($i=0; $i <$num_results ; $i++)
{
$row = mysql_fetch_arr ay($result);
echo '<tr>
<td align="left" nowrap="nowrap" >';
if (($row['sub']) == 'no') {
echo '<a href="';
echo ($row['url']);
echo '">';
echo ($row['name']);
echo '</a>';
}
else {
echo '- <a style="font-size:11px" href="';
echo ($row['url']);
echo '">';
echo ($row['name']);
echo '</a>';
}
echo '</td></tr>';
}
?>
</div>


Please help. I keep getting that error message.

Code previously worked, and now isn't. Racking my brains, and can't seem to find a fault.

Thanks

Pete
Jan 8 '07 #1
3 3910
ronverdonk
4,258 Recognized Expert Specialist
Warning: you must enclose your code within the appropriate php, code or html tags! Please read the Posting Guidelines at the top of this forum before you post anything again.

To answer your question: you better find out first whether the SELECT generated an error, so change you mysql_query to the following and see what error message it throws.[php]$result = mysql_query($qu ery)
or die ("SELECT error: ".mysql_error() );
[/php]
Ronald :cool:
Jan 8 '07 #2
khalidbaloch
61 New Member
this might be syntax error ,add die mysql_error() function in every
mysql_query ,to figure out the mistake

you should also add this mysql_connect and dl_select in db_conn_ini.php
this code might

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //load the db_conn_ini file
  3. require ('includes/db_conn.inc.php');
  4. $query = "select * from menu order by item_order";
  5. $result = mysql_query($query) OR die(mysql_error());
  6. $num_results = mysql_num_rows($result) OR die(mysql_error());  // 
  7. while ($row = mysql_fetch_array($result))
  8. while ($row = mysql_fetch_array($result))
  9. {
  10. echo '<tr>
  11. <td align="left" nowrap="nowrap">';
  12.  if ($row['sub'] == 'no') {
  13. echo '<a href="',$row['url'],$row['name'],'"</a>'; 
  14. }
  15. else {
  16. echo '- <a style="font-size:11px" href="',$row['url'],$row['name'],'</a>';          
  17. }
  18.  
  19. echo '</td></tr>';
  20. ?>
the code for db_conn_ini.php

Expand|Select|Wrap|Line Numbers
  1. <?
  2. // SET MYSQL INFORMATION
  3. $db_host = "localhost";
  4. $database = "database";
  5. $db_user = "root";
  6. $db_pass = "dbpasswd";
  7.  
  8. // CONNECT TO MYSQL DATABASE
  9. $db = mysql_connect($db_host, $db_user, $db_pass) OR die(mysql_error()) ;
  10. mysql_select_db("$database") Or die(mysql_error());
  11. ?>
  12.  
i made some changes to code so that it look better and i hope this will help you
Jan 8 '07 #3
petemaxi
2 New Member
Thank you for your help, all working now!
Jan 9 '07 #4

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

Similar topics

2
7980
by: Noel Wood | last post by:
Hello I keep getting a warning ... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in "name of my php file" when I run this query.... SELECT Menu_Item, Quantity FROM restorder_item WHERE Order_Number =58 The code I use to do it is.... $query = "select Menu_Item, Quantity from restorder_item"; $query .= " where Order_Number = ".$_REQUEST;
2
4242
by: Willem Berendsen | last post by:
Hello, I setting up my mysql-server and php on IIS6 and it works almost fine. But I got the next error: Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in file.php on line 46. But I'am sure that the code is good, because I have use the code very much. Create a connection is working, mysql_query is working but mysql_Numrows($query) is not working: $query = mysql_query("SELECT * FROM users");
3
3432
by: Pratchaya | last post by:
Hi Everyone ============================================================== About PHP::: Error/Problem PHP Warning: mysql_fetch_array(): ============================================================== In the past i use my code/script work fine with Mandrake 9.1 - 10.1 ( + apache ,mysql ) Now i move to redhat EL4 with the same code/script
9
7425
by: Petr Vileta | last post by:
Hi, I'm new here and excuse me if this question was be here earlier. I have a simple code <html><body> <?php <?php $link = mysql_connect("localhost", "user", "password") or die("Grr: " . mysql_error()); mysql_select_db("my_dbf") or die("Grr");
4
7832
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...
2
16923
by: techjohnny | last post by:
Error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/jplane/certcent/phpweb/quiz/index.php on line 20 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/jplane/certcent/phpweb/quiz/index.php on line 21 PHP CODE:
1
2705
by: lsmamadele | last post by:
I am getting the following error messages in my search: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on line 113 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on line 127 My code is below. Any help would be much appreciated. ...
4
5025
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>
2
16971
by: poreko | last post by:
I am connecting to my database using Object oriented PHP. My query is returning results but at the end of my table,at the bottom of the page I keep having this error when I run my program: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\mysql_class_2.php on line 45. Can anyone help me? The following is my PHP class: <?php class mysql {...
0
8667
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
9148
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9012
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...
0
8853
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...
1
6515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4357
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
4611
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2319
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1992
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.