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

Closed Thread

Join Date: Apr 2007
Posts: 136
Reputation: dr4g is an unknown quantity at this point 
Solved Threads: 5
dr4g's Avatar
dr4g dr4g is offline Offline
Junior Poster

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

 
0
  #11
May 6th, 2007
Recap on above Post.

If your having an error with mysq_num_rows($res).
Basically you need to verify that your query worked ok.
Code for having error checking setup is.
  1. $ret = mysql_query($query) or die(mysql_error());

This will output the error that is being caused at the query stage.
GardCMS :: Open Source CMS :: Gardcms.org
Quick reply to this message  
Join Date: Apr 2007
Posts: 136
Reputation: dr4g is an unknown quantity at this point 
Solved Threads: 5
dr4g's Avatar
dr4g dr4g is offline Offline
Junior Poster

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

 
0
  #12
May 6th, 2007
Same applies to Lexid2002.
you're getting an error on fetch_assoc(), as theres a problem at the query stage.
This can be identified by doing the above code.. adding ' or die(mysql_error()); to the end of the line.

Once you have sorted the query, the mysql_fetch_assoc, will have a valid resource, and you'll not get this error.
GardCMS :: Open Source CMS :: Gardcms.org
Quick reply to this message  
Join Date: Feb 2007
Posts: 16
Reputation: WhiteLeo is an unknown quantity at this point 
Solved Threads: 2
WhiteLeo's Avatar
WhiteLeo WhiteLeo is offline Offline
Newbie Poster

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

 
0
  #13
May 6th, 2007
I always forget about the "or die..." thing.

Hopefully it should point out whether it was just a simple sql or connection problem.
Quick reply to this message  
Join Date: May 2006
Posts: 1,580
Reputation: Infarction has a spectacular aura about Infarction has a spectacular aura about Infarction has a spectacular aura about 
Solved Threads: 52
Infarction's Avatar
Infarction Infarction is offline Offline
Battle Programmer

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

 
0
  #14
May 7th, 2007
Adding or die(mysql_error()) after a query is a poor way to back out. It would be better to call a function to handle the error than to simply kill the page (possibly even loading a separate error page and/or an automated error reporting system). Besides, do you want someone to see what table names, column names, etc.. you were using in your query?
Quick reply to this message  
Join Date: Apr 2007
Posts: 136
Reputation: dr4g is an unknown quantity at this point 
Solved Threads: 5
dr4g's Avatar
dr4g dr4g is offline Offline
Junior Poster

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

 
0
  #15
May 7th, 2007
Wow, wow Infarction calm down.
You're jumping the gun a little for these guys.
They're not ready for advanced error handling techniques.
They're just getting to grips with mySQL techniques.
Need to give them a chance to understand how things work, before you can introduce new techniques to them.

Keep plodding along guys, it will make more sense in time.
GardCMS :: Open Source CMS :: Gardcms.org
Quick reply to this message  
Join Date: Oct 2005
Posts: 7
Reputation: omick16 is an unknown quantity at this point 
Solved Threads: 0
omick16's Avatar
omick16 omick16 is offline Offline
Newbie Poster

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

 
0
  #16
May 8th, 2007
Originally Posted by lexid2002 View Post
I have this problem and i am new so please go slow...

error on page

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/loyalist/public_html/shop/pages/0.php on line 17

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/loyalist/public_html/shop/pages/0.php on line 13

--------

<?php
//
// TYPES:
//
// CDS DVDS CLOTHING KEYRINGS/BOTTLEOPENERS FLAGS OFFERS TICKETS
//
// 1 2 3 4 5 6 7
//
$query = "SELECT * FROM config WHERE id=3";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
$query = "SELECT * FROM items WHERE id=".$row['value']." ORDER BY id DESC Limit 0,1";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
$id = $row['id'];
$name = $row['name'];
$desc = $row['description'];
$price = $row['price'];
$img = $row['img'];
$menu = $row['menu'];
$frase = $desc;
$char = 180;
$desc = checklenght($frase, $char);

$content = $namet.$name.$desct.$desc.$pricet.'£'.$price;

?>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" rowspan="2" class="image" align="center"><a href="#" onclick="window.open('info.php?id=<?php print $id ?>&menu=<?php print $menu; ?>', '_info', 'HEIGHT=500,resizable=no,WIDTH=430,scrollbars=1');"><img src="images/item_enlarge.gif" border="0" /></a><br/><br/><img src="products/<?php print $img; ?>" width="95" height="95" border="0" /></td>
<td valign="top" class="item-main"><b><?php print $content; ?></b></td>
</tr>
<tr>
<td valign="top"><img src="images/item_order1.gif" border="0" /><a href="#" onclick="window.open('info.php?id=<?php print $id ?>&menu=<?php print $menu; ?>', '_info', 'HEIGHT=500,resizable=no,WIDTH=430,scrollbars=1');"><img src="images/item_order2.gif" border="0" /></a></td>
</tr>
</table>
<br />
<?php
}
}
?>
<b>Welcome...</b></span>
<br />
<br />
<span style="font-size: 14px; ">
<?php
$query = "SELECT * FROM config WHERE id=1";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
$introtext = $row['value'];
$introtext = nl2br($introtext);
print $introtext;
?>
</span></b>


hope someone can help

lexi
You forgot to setup a connection??? hehehe
Quick reply to this message  
Join Date: Apr 2007
Posts: 136
Reputation: dr4g is an unknown quantity at this point 
Solved Threads: 5
dr4g's Avatar
dr4g dr4g is offline Offline
Junior Poster

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

 
0
  #17
May 8th, 2007
GardCMS :: Open Source CMS :: Gardcms.org
Quick reply to this message  
Join Date: May 2007
Posts: 3
Reputation: acaradic@hotmai is an unknown quantity at this point 
Solved Threads: 0
acaradic@hotmai acaradic@hotmai is offline Offline
Newbie Poster

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

 
0
  #18
May 10th, 2007
Hi all,
im new 2 all this tring 2 work this 1 out but is not workin. Can u chek this and tell me why this does't enter customer and order details into mysql:

[php]
<?php
$xn = $HTTP_POST_VARS['n'];
$xd = $HTTP_POST_VARS['d'];
$xc = $HTTP_POST_VARS['c'];
$xq = $HTTP_POST_VARS['q'];
$xf = $HTTP_POST_VARS['f'];
$hostname_local = "localhost";
$database_local = "database";
$username_local = "username";
$password_local = "password";
$local = mysql_pconnect($hostname_local, $username_local, $password_local) or die(mysql_error());
mysql_select_db($database_local, $local);
$sql = "SELECT `id` FROM `customers` WHERE bname='".$HTTP_POST_VARS['BName']." and baddress='".$HTTP_POST_VARS['BStreet'];
$Recordset1 = mysql_query($sql, $local);
$id1 = mysql_result($Recordset1,0,"id");
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
if ($totalRows_Recordset1 > 0) {$sql = "INSERT INTO `customers` ( `id` , `bname` , `baddress` , `bcity` , `bstate` , `bzip` , `bcountry` ,
`bphone` , `bfax` , `bemail` , `sname` , `saddress` , `scity` , `sstate` , `szip` , `scountry` , `sphone` , `sfax` ) VALUES ( '', '".
$HTTP_POST_VARS['BName']."', '".$HTTP_POST_VARS['BStreet']."', '".$HTTP_POST_VARS['BCity']."',
'".$HTTP_POST_VARS['BState']."', '".$HTTP_POST_VARS['BZip']."', '".$HTTP_POST_VARS['BCountry']."', '".$HTTP_POST_VARS['BPhone']."',
'".$HTTP_POST_VARS['BFax']."', '".$HTTP_POST_VARS['BEmail']."', '".$HTTP_POST_VARS['Name']."', '".$HTTP_POST_VARS['Street']."',
'".$HTTP_POST_VARS['City']."', '".$HTTP_POST_VARS['State']."', '".$HTTP_POST_VARS['Zip']."', '".$HTTP_POST_VARS['Country']."',
'".$HTTP_POST_VARS['Phone']."', '".$HTTP_POST_VARS['Fax']."' )";
$Recordset1 = mysql_query($sql, $local);
}
for ($i =0; $i< $HTTP_POST_VARS['orderedtotal'];$i++){
if ($xn[$i] != "" ){$my_body .= "Product ".$xn[$i] ." ".$xd[$i]." @ cost " .$xc[$i]. " with ".$xq[$i] . " ordered\n";}
//insert into the order database
$sql = "INSERT INTO `orders` VALUES ( '','$id1', '$my_body', '".$HTTP_POST_VARS['total']."', '".$HTTP_POST_VARS['shiptotal']."', '".date("F j, Y, g:i a")."' )";
$Recordset1 = mysql_query($sql, $local);}
$my_body = "";
error_reporting(E_ALL ^ (E_NOTICE));
$my_body = "";
$MailFrom = "From:". $HTTP_POST_VARS['BEmail']."\n";
$my_body .= "****************************************************************\n";
$my_body .= "The Order is as follows (the number shown is the quantity ordered)\n";
$my_body .= "Ordered on ".date("F j, Y, g:i a") ."\n";
$my_body .= "****************************************************************\n";
for ($i =0; $i< $HTTP_POST_VARS['orderedtotal'];$i++){ if ($xn[$i] != "" )$my_body23 .= "Product ".$xn[$i] ." ".$xd[$i]." @ cost " .$xc[$i]. " with ".$xq[$i] . " ordered\n";}
$my_body .= strip_tags($my_body23);
$my_body .= "************************************\n";
$my_body .= "Sales Tax= " . $HTTP_POST_VARS['saletotal'] . "\n";
$my_body .= "Total Cost:= " . $HTTP_POST_VARS['total'] . "\n";
$my_body .= "****************************************************************\n";
$my_body .= "****************************************************************\n";
$my_body .= "Shipping Information\n";
$my_body .= "****************************************************************\n";
if( $HTTP_POST_VARS['SameAsBill'] ){$my_body .= "Same as Billing Address". "\n";}
$my_body .= "Name= " . $HTTP_POST_VARS['Name'] . "\n";
$my_body .= "Address= " . $HTTP_POST_VARS['Street'] . "\n";
$my_body .= "City= " . $HTTP_POST_VARS['City'] . "\n";
$my_body .= "State= ". $HTTP_POST_VARS['State']. "\n";
$my_body .= "Zip= " . $HTTP_POST_VARS['Zip'] . "\n";
$my_body .= "Country=" . $HTTP_POST_VARS['Country'] . "\n";
$my_body .= "Phone= " . $HTTP_POST_VARS['Phone']. "\n";
$my_body .= "Fax= " . $HTTP_POST_VARS['Fax']. "\n";
$my_body .= "****************************************************************\n";
$my_body .= "Users Comments= " . $HTTP_POST_VARS['theComments']. "\n";
$my_body .= "****************************************************************\n";
$my_body .= "Billing Information\n";
$my_body .= "****************************************************************\n";
$my_body .= "Name= " . $HTTP_POST_VARS['BName'] . "\n";
$my_body .= "Street= " . $HTTP_POST_VARS['BStreet'] . "\n";
$my_body .= "City= " . $HTTP_POST_VARS['BCity'] . "\n";
$my_body .= "State= ". $HTTP_POST_VARS['BState']. "\n";
$my_body .= "Zip= " . $HTTP_POST_VARS['BZip'] . "\n";
$my_body .= "Country=" . $HTTP_POST_VARS['BCountry']. "\n";
$my_body .= "Phone= " . $HTTP_POST_VARS['BPhone'] . "\n";
$my_body .= "Fax= " . $HTTP_POST_VARS['BFax'] . "\n";
$my_body .= "email= " . $HTTP_POST_VARS['BEmail'] . "\n";
$my_body .= "Company= " . $HTTP_POST_VARS['BCompany'] . "\n";
$my_body .= "Payment Method= " . $HTTP_POST_VARS['Bill_Type'] . "\n";
$my_body .= "Credit Card Number= " . $HTTP_POST_VARS['CCnumber'] . "\n";
$my_body .= "Credit Card Expiration= " . $HTTP_POST_VARS['CCdate'] . "\n";
$my_body .= "Credit Card Security Code= " . $HTTP_POST_VARS['CCpass'] . "\n";
$my_body .= "****************************************************************\n";
$my_body .= "This Order was created using eOrdering Professional by LAJ Design\n";
$my_body .= "****************************************************************\n";
mail("admin@mysite.com","order","$my_body", "$MailFrom" );
?>
[/php]
[html]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd">

<html>
<head>
<title>Insert title</title>
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
</head>

<body class="BodyHtml" bgcolor="#FFFFFF" text="#000000" link="#000000" vlink="#000000" Alink="#000000">


<div align="center">

<p>
<SCRIPT language="JavaScript" SRC="includes/above.js"></SCRIPT>

</div>
<br>

<p align="center">[/html][php]<?php
$my_body1 = "";
$my_body1 .= "Ordered on ".date("F j, Y, g:i a") ."\n"."<br>"."<br>";
for ($i =0; $i< $HTTP_POST_VARS['orderedtotal'];$i++){if ($xn[$i] != "" )$my_body31 .= "Product ".$xn[$i] . " ".$xd[$i]." @ cost ". $xc[$i]. " with ".$xq[$i] . " ordered"."\n<br>";}
print $my_body1. str_replace( "\\\"", "\"",$my_body31);
?>[/php][html]<br><br> Thank you for your order!<br>We will be contacting you to confirm.<br>In five seconds you will be redirected to the main page.<br>If not then <a href="index.php">Click Here</a>

<div align="center">

<p>
<SCRIPT language="JavaScript" SRC="includes/below.js"></SCRIPT>
</p>
<br>
<table class="LogoTable" border= "1" width="250" align="center"> <tr><td><a href="<A href="http://www.lajdesignsw.com"><img">http://www.lajdesignsw.com"><img src="wcreated.jpg" width="250" height="75" border="0" ></a></td>
</tr> </table>


<p>&nbsp;</p>
</div>
</body>
</html>

[/html]


I'm having error's:

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /path 2/process.php on line 29
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /path 2/process.php on line 31
Quick reply to this message  
Join Date: Dec 2006
Posts: 160
Reputation: w_3rabi is an unknown quantity at this point 
Solved Threads: 9
w_3rabi's Avatar
w_3rabi w_3rabi is offline Offline
Junior Poster

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

 
0
  #19
May 10th, 2007
try doing this dude

[PHP]
$Bname = $HTTP_POST_VARS['BName'] ;
$BStreet = $HTTP_POST_VARS['BStreet'];
$sql = "SELECT `id` FROM `customers` WHERE bname='
$Bname' and baddress='$BStreet'".;[/PHP]

programming is an art ,only for those who can understand it.
- th3 php wr3nch -
Quick reply to this message  
Join Date: May 2007
Posts: 3
Reputation: acaradic@hotmai is an unknown quantity at this point 
Solved Threads: 0
acaradic@hotmai acaradic@hotmai is offline Offline
Newbie Poster

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

 
0
  #20
May 10th, 2007
Originally Posted by w_3rabi View Post
try doing this dude

[php]
$Bname = $HTTP_POST_VARS['BName'] ;
$BStreet = $HTTP_POST_VARS['BStreet'];
$sql = "SELECT `id` FROM `customers` WHERE bname='
$Bname' and baddress='$BStreet'".;[/php]
i have done what u suggest and now i'm havin this error:

Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /path 2/process.php on line 36

and also out of all images i have had in shopping cart they all come up in mysql as one same record repeated 5 times, for instance i have 5 records of image 02.jpg instead of image 02.jpg, image 03.jpg and so on and none of the records inside customers table.
Quick reply to this message  
Closed Thread

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 177926 | Replies: 43
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC