473,895 Members | 3,071 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

117 New Member
Warning: mysql_fetch_arr ay(): 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:
[PHP]if ($myrow = mysql_fetch_arr ay($result)) {

do {

if ($rowcolor == 1) {
$rowcolorhex = "#ffffff";
$rowcolor = 0;
} else {
$rowcolorhex = "#D6D6D6";
$rowcolor = 1;
}[/PHP]

It pops on most pages:
POSTED BY:
Warning: mysql_fetch_arr ay(): supplied argument is not a valid MySQL result resource in /home/breana/public_html/item.php on line 22
Admin
Sep 10 '07 #1
11 3622
Breana
117 New Member
I am tring to do a fix but am having trouble..
Expand|Select|Wrap|Line Numbers
  1. if ($myrow = mysql_fetch_array($result)) {
  2.   do {
  3.     if ($rowcolor == 1) {
  4.       $rowcolorhex = "#ffffff";
  5.       $rowcolor = 0;
  6.     } else {
  7.       $rowcolorhex = "#D6D6D6";
  8.       $rowcolor = 1;
  9.     }
  10. } else {
  11.   if ($myrow = ' ' {
  12.     printf (No results found);
  13.   }
  14.  
Sep 10 '07 #2
gregerly
192 Recognized Expert New Member
I am tring to do a fix but am having trouble..

if ($myrow = mysql_fetch_arr ay($result)) {

do {
if ($rowcolor == 1) {
$rowcolorhex = "#ffffff";
$rowcolor = 0;

} else {

$rowcolorhex = "#D6D6D6";
$rowcolor = 1;
}
} else {
if ($myrow = ' ' {
printf (No results found);
}
I do my row coloring a little different:

[PHP]$x=0;
//use a while loop instead of the if / do
while(list($fie ld1,$field2,$fi eld3,$field4)=@ mysql_fetch_row ($sql)){
$mod=$x%2;
$class=(!$mod)? "ws1style":"ws2 style";

echo "<div class='$class'> $filed1</div>\n";

$x++;
}[/PHP]

The code above uses the modulus operator to determine which class the div should get.

Hope that helps. Also, to suppress your mysql_fetch_arr ay() errors add an "@" in front of the call.

IE:

[PHP]@mysql_fetch_ro w($result);[/PHP]

Thanks,

Greg
Sep 10 '07 #3
Atli
5,058 Recognized Expert Expert
Hi.

I've changed the title of this thread to better describe it's topic.
Using good, descriptive titles that follow the Posting Guidelines will increase your chances of getting you questions answered!

Also, please but your code inside [code] tags!

Moderator
Sep 10 '07 #4
pbmods
5,821 Recognized Expert Expert
Heya, Breana.

If you're getting this error, then your MySQL query is generating an error.

You will not get an error if your query returns zero results; mysql_fetch_arr ay() will simply return false.

Try echoing mysql_error() to see what's going on.
Sep 11 '07 #5
Breana
117 New Member
I dont understand what you mean by error i tried it noting showed up?

But this is new..

Warning: mysql_numrows() : supplied argument is not a valid MySQL result resource in /home/breana/public_html/results.php on line 79

Warning: mysql_fetch_arr ay(): supplied argument is not a valid MySQL result resource in /home/breana/public_html/results.php on line 106

Here is how i placed the error.
echo mysql_error();

I'll put my code maybe you'll see the error..

[PHP]<?php

$pagenum = 0;

$searchtype = $_REQUEST['searchtype'];
$searchingred = $_REQUEST['searchingred'];

if ($_REQUEST['pagenum']) {$pagenum = $_REQUEST['pagenum'];}

$sql = "select * from " . SEARCH_TERMS . " where term = '$searchingred' ";

$result = mysql_query($sq l ,$db);

if (mysql_num_rows ($result) > 0) {
echo mysql_error();

$row = mysql_fetch_row ($result);
$count = $row[1];
$newcount = $count + 1;
$sql = "update " . SEARCH_TERMS . " set count = $newcount where term = '$searchingred' ";

} else {

$sql = "insert into " . SEARCH_TERMS . " (term, count) values ('$searchingred ', 1)";

}

$result = mysql_query($sq l ,$db);

?>[/PHP]
Sep 11 '07 #6
code green
1,726 Recognized Expert Top Contributor
You would help yourself a lot by using simple error trapping and echoing out the values of variables.
At the moment you are blundering about blindly.
This warning
Expand|Select|Wrap|Line Numbers
  1. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
means that $result is empty. This is because the following query has failed
[PHP]$sql = "select * from " . SEARCH_TERMS . " where term = '$searchingred' ";
$result = mysql_query($sq l ,$db);
[/PHP]You cannot use mysql_functions on a non existent resultset.
If you echo out $result you expect to see something like '#1'
If you echo out $sql you will probably see why the query is wrong.
Sep 11 '07 #7
Breana
117 New Member
I don't understand what you mean?
Like this: echo mysql_error($sq l);

Or other?
Sep 11 '07 #8
code green
1,726 Recognized Expert Top Contributor
[PHP]echo 'searchtype'.$s earchtype;
echo 'searchingred'. $searchingred;
echo 'sql'.$sql;
//Execute the query
echo 'error'.mysql_e rrno();
echo 'errno'.mysql_e rror();

echo 'result'.$resul t;

//Execute the loop[/PHP]And let the dog see the rabbit!
Sep 11 '07 #9
Breana
117 New Member
Ok, lol here is what it said:

searchtypeIsear chingredsqlinse rt into SEARCH_TERMS (term, count) values (''free cars, 1)error1146errn oTable 'breana_cheatz9 11.SEARCH_TERMS ' doesn't existresult

I just looked the table is there!
[PHP]
--
-- Table structure for table `search_terms`
--

CREATE TABLE `search_terms` (
`term` varchar(255) default NULL,
`count` int(10) unsigned default '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `search_terms`
--

INSERT INTO `search_terms` VALUES ('zombie', 11);
INSERT INTO `search_terms` VALUES ('Code/Game', 1);
INSERT INTO `search_terms` VALUES ('1701', 1);
INSERT INTO `search_terms` VALUES ('harvest moon', 1);
INSERT INTO `search_terms` VALUES ('alarm clock', 1);
INSERT INTO `search_terms` VALUES ('delete', 1);
INSERT INTO `search_terms` VALUES ('gta', 1);
INSERT INTO `search_terms` VALUES ('harvest', 3);[/PHP]
Sep 11 '07 #10

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

Similar topics

2
8010
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;
3
3441
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
18911
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
3927
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
2114
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
7844
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...
1
2719
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. ...
2
16992
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
4774
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
9988
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
9833
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
11247
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
10841
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
10469
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
7175
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
5860
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
6066
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4282
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.