473,785 Members | 2,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Hello I keep getting a warning ...
Warning: mysql_fetch_arr ay(): 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["OrderNumbe r"];

$result = mysql_query($qu ery) or die($query." failed: ".mysql_error() );

while ($row = mysql_fetch_arr ay($result, MYSQL_ASSOC)) {
var_dump($row);
}
Notice to test it I did a var_dump of $row and it came back with the
expected results namely......
array(2) { ["Menu_Item"]=> string(1) "3" ["Quantity"]=> string(1) "5" }
So I can't see whats wrong. Everything seems to be working yet I get a
warning.
I have done a quick fix by putting an @ in front of the offending function
but I would really like to know what the problem is.
Thanks for your help in advance.
Noel
Jul 17 '05 #1
2 7993
Please don't er with this question. I am pretty sure I have made a mistake
in the query somewhere.
Noel
"Noel Wood" <re************ ******@optusnet .com.au> wrote in message
news:41******** *************** @news.optusnet. com.au...
Hello I keep getting a warning ...
Warning: mysql_fetch_arr ay(): 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["OrderNumbe r"];

$result = mysql_query($qu ery) or die($query." failed: ".mysql_error() );

while ($row = mysql_fetch_arr ay($result, MYSQL_ASSOC)) {
var_dump($row);
}
Notice to test it I did a var_dump of $row and it came back with the
expected results namely......
array(2) { ["Menu_Item"]=> string(1) "3" ["Quantity"]=> string(1) "5" }
So I can't see whats wrong. Everything seems to be working yet I get a
warning.
I have done a quick fix by putting an @ in front of the offending function
but I would really like to know what the problem is.
Thanks for your help in advance.
Noel

Jul 17 '05 #2
"Noel Wood" <re************ ******@optusnet .com.au> wrote in message
news:41******** *************** @news.optusnet. com.au...
Hello I keep getting a warning ...
Warning: mysql_fetch_arr ay(): 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["OrderNumbe r"];

$result = mysql_query($qu ery) or die($query." failed: ".mysql_error() );

while ($row = mysql_fetch_arr ay($result, MYSQL_ASSOC)) {
var_dump($row);
}
Notice to test it I did a var_dump of $row and it came back with the
expected results namely......
array(2) { ["Menu_Item"]=> string(1) "3" ["Quantity"]=> string(1) "5" }
So I can't see whats wrong. Everything seems to be working yet I get a
warning.
I have done a quick fix by putting an @ in front of the offending function
but I would really like to know what the problem is.
Thanks for your help in advance.


Your testing for errors leaves a lot to be disired. You only check to see if
mysql.error is set and don't check to see if a results set has been
returned, or that result set actually contains rows.

$result = mysql_query($qu ery);
if(! $result || mysql_error() || mysql_num_rows( $result) < 1)
{
echo sprintf('%s rows, [%s] , error: %s',
@mysql_num_rows ($result),
$query,
mysql_error());
exit;
}
Note the @ on the front of the second mysql_num_rows. If the result set is
empty then trying to use mysql_num_rows will generate the error that you are
seeing, so you should suppress it.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3438
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
2
18903
by: 00webman | last post by:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/html/scripts/07/view_users.php on line 15 Can anyone spot my error?!? Thanks. <?php # Script 7.6 - view_users.php (2nd version after Script 7.4) // This script retrieves all the records from the users table. $page_title = 'View the Current Users'; include ('./includes/header.html');
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);
1
2106
by: myaashik | last post by:
Hello! All I have a Error message saying that: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/rocks/public_html/colorado3.php on line 32 I have error on this code below: <html> <head> <titleColorado</title>
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...
2
16936
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
2713
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. ...
11
3609
by: Breana | last post by:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/breana/public_html/category.php on line 88 ------------------------------------------- It does this when there is no result "empty table" how can i do a quick fix to say No Results... row 88: if ($myrow = mysql_fetch_array($result)) { do { if ($rowcolor == 1) {
2
16985
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 {...
11
4757
by: chemlight | last post by:
I'm having a problem. I'm sure I'm going to kick myself over the answer... I have a table that stores vendors and their languages. This table starts out blank. I am querying the table to see if a vendor has been added to the table yet. The problem is, if they haven't been added, I can't seem to get the script to realize that. here is what I am trying to do. $testvend = SELECT language FROM vendor_details WHERE id = $vendorid ...
0
9646
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
9483
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
10157
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
8982
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
7504
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
6742
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
5386
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...
1
4055
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
3658
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.