| | |
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
0
#1 Jun 12th, 2004
[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)
<?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)
Last edited by Killer_Typo; Jun 12th, 2004 at 9:23 pm. Reason: had to include data forgotten.
Dont forget to spread the reputation to those that deserve!
Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
0
#2 Jun 12th, 2004
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.
Check out my blog at http://www.shinylight.com for more stuff about web dev.
Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
0
#3 Jun 12th, 2004
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.
Dont forget to spread the reputation to those that deserve!
•
•
Join Date: Feb 2003
Posts: 282
Reputation:
Solved Threads: 6
Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
0
#4 Jun 13th, 2004
Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
0
#5 Jun 13th, 2004
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.
i plan on posting it in the snipits area.
Last edited by Killer_Typo; Jun 13th, 2004 at 12:51 pm. Reason: :):)
Dont forget to spread the reputation to those that deserve!
Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
0
#6 Jun 13th, 2004
•
•
•
•
Originally Posted by Killer_Typo
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.
•
•
•
•
Originally Posted by Killer_Typo
i plan on posting it in the snipits area.
Check out my blog at http://www.shinylight.com for more stuff about web dev.
•
•
Join Date: Mar 2007
Posts: 1
Reputation:
Solved Threads: 0
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
0
#7 Mar 9th, 2007
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
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
•
•
Join Date: Apr 2007
Posts: 1
Reputation:
Solved Threads: 0
Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
0
#8 Apr 29th, 2007
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
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
0
#9 Apr 30th, 2007
•
•
•
•
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
0
#10 May 1st, 2007
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.
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.
![]() |
Similar Threads
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in (PHP)
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource (PHP)
Other Threads in the PHP Forum
- Previous Thread: pagination within image - IF problem
- Next Thread: Name variable after other variable
| Thread Tools | Search this Thread |
ajax apache api array arrays beginner binary broken cache cakephp checkbox class cms code confirm cron curl customizableitems database date display dynamic echo email error external file files folder form forms forum function functions google header headmethod howtowriteathesis href htaccess html iframe image include insert integration ip java javascript joomla limit link login loop mail malfunction menu method mlm multiple mysql neutrality oop paypal pdf php phpmysql play problem query question radio random recursion regex remote root script search select server sessions sms soap source space sql syntax system table tutorial update upload url validator variable video web xml youtube





