473,668 Members | 2,398 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 3909
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
7974
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
4241
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
3427
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
7420
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
7827
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
16920
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
2703
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
5023
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
8381
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
8658
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
7401
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
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
5681
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
4205
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
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1786
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.