473,508 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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["OrderNumber"];

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

while ($row = mysql_fetch_array($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 7956
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.a u...
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["OrderNumber"];

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

while ($row = mysql_fetch_array($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.a u...
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["OrderNumber"];

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

while ($row = mysql_fetch_array($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($query);
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
3422
by: Pratchaya | last post by:
Hi Everyone ============================================================== About PHP::: Error/Problem PHP Warning: mysql_fetch_array():...
2
18890
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 -...
3
3902
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">...
1
2077
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...
4
7822
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...
2
16898
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...
1
2692
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...
11
3573
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...
2
16964
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:...
11
4715
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...
0
7227
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,...
0
7127
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...
0
7391
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...
1
7054
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...
0
7501
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...
0
4713
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...
0
3204
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...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
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 ...

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.