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
3 3909 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:
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 - <?php
-
//load the db_conn_ini file
-
require ('includes/db_conn.inc.php');
-
$query = "select * from menu order by item_order";
-
$result = mysql_query($query) OR die(mysql_error());
-
$num_results = mysql_num_rows($result) OR die(mysql_error()); //
-
while ($row = mysql_fetch_array($result))
-
while ($row = mysql_fetch_array($result))
-
{
-
echo '<tr>
-
<td align="left" nowrap="nowrap">';
-
if ($row['sub'] == 'no') {
-
echo '<a href="',$row['url'],$row['name'],'"</a>';
-
}
-
else {
-
echo '- <a style="font-size:11px" href="',$row['url'],$row['name'],'</a>';
-
}
-
-
echo '</td></tr>';
-
}
-
?>
the code for db_conn_ini.php - <?
-
// SET MYSQL INFORMATION
-
$db_host = "localhost";
-
$database = "database";
-
$db_user = "root";
-
$db_pass = "dbpasswd";
-
-
// CONNECT TO MYSQL DATABASE
-
$db = mysql_connect($db_host, $db_user, $db_pass) OR die(mysql_error()) ;
-
mysql_select_db("$database") Or die(mysql_error());
-
?>
-
i made some changes to code so that it look better and i hope this will help you
Thank you for your help, all working now!
Sign in to post your reply or Sign up for a free account.
Similar topics |
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;
|
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");
|
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
|
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");
|
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...
| |
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:
|
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.
...
|
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>
|
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 {...
|
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,...
|
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...
| |
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |