![]() |
| ||
| Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource [php] <?php /* declar some relevant variables */ $Host = "localhost"; //location of mySQL on server $User = "michael"; //my username $Pass = "koolaide"; //my password $Name = "phpaccess"; //name of the database to be used $Table = "info"; //name of the table within the database mysql_connect ($Host, $User, $Pass, $Name, $Table) or die ("unable to connect to database"); mysql_select_db("$Name") or die ("unable to select DB"); $sqlquery = "SELECT * FROM $table WHERE opinion = 'is greate'"; $result = mysql_query($sqlquery); $number = mysql_num_rows($result); //LINE NUMBER 23 $i = 0; if ($number < 1) { echo "<center><p>There were no results for your search</p></center>"; } else { while ($number > $i) { $thename = mysql_result ($result, $i, "name"); $theemail = mysql_result ($result, $i, "email"); echo "<p><b>Name:</b></p> $thename<br /><b>E-Mail:</b>$theemail</p>"; $i++; } } ?>[/php] Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\www\databaseconnect.php on line 23 i get that error, ive commented line number twentythree. this is just a database tutorial that im working on and i hope that maybe someone can tell me whats goin on. o and dont worry about the username password stuff, this server will never go online, this is all practice stuff. (line twenty three is in reference to the entire php file, this is only part of it, i left out the <html> tags part) |
| ||
| Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource You defined the variable "$Table" with a capital T, yet you try to interpolate it in the querystring with a lower case "t." PHP is case sensitive for user defined variables. |
| ||
| Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource wow thanks that fixed it, but im not sure if i got the output i am supposed to get. though i plan on working on this a little more. thanks for the help i didnt even notice that. maybe from now i should just try to work with my variables in lowercase. |
| ||
| Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource That's usually best. Saves a lot of hassle. |
| ||
| Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource now im very happy! i have a submit form which writes to a database, a submitted form which displays what has just been submitted, and a database forms which displays all information that has been submitted. i plan on posting it in the snipits area. |
| ||
| Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource Quote:
Quote:
|
| ||
| Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource I am having the same problem Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\Abyss Web Server\htdocs\getrecord.inc on line 6 how ever this is my code <?php // version 1.1 $qstr = "SELECT * from members where id = '1' "; $result = mysql_query($qstr); if (mysql_num_rows($result)) // check login info is correct { $username = mysql_result($result,0, "username"); $password = mysql_result($result,0, "password"); echo "<b>The username:</b> $username<br>"; echo "<b>The password:</b> $password<br>"; } else echo "ERROR - unable to find current username and password!"; mysql_close(); ?> please someone help me |
| ||
| Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource 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 |
| ||
| Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource Quote:
you should check the id field type is it int or varchar ??? |
| ||
| Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource For those who got a error with the num rows, I suggest you add the error dispaly for the sql error message. if(!$result){die(mysql_error();} Stick that below the query, it will give a specific message about what is wrong with the query. There isn't a problem with the num_rows function usually, but with the actual query itsself. |
| All times are GMT -4. The time now is 8:44 pm. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC