For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > May 2006 > mysql_num_rows









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author mysql_num_rows
alexjaquet@gmail.com

2006-05-25, 3:58 am

Hi

I do the following code but I got this error : PHP Warning:
mysql_num_rows(): supplied argument is not a valid MySQL result
resource in C:\\Apache2\\htdocs\\recordz\\php\\main.php on line 36

Any idea ?

<?php
$lang = $_GET['lang'];
$link = mysql_connect("localhost", "root", "xxxx") or die ("Could not
connect");
mysql_select_db ("recordz",$link) or die ("Could not select
database");
$query="SELECT nom FROM category_$lang";
$result=mysql_query($query,$link);
$num = mysql_num_rows($result);
for ($i = 0; $i > $num;$i++) {
print "<option>$result[$i]</option>";
}
?>
:

Usenet

2006-05-25, 6:58 pm

Probably something wrong with your query (since it should die if
there's something wrong with the database connection).

I'd check that the substitution for $lang is working properly.

Mark Stanton
One small step for mankind...


Colin McKinnon

2006-05-25, 6:58 pm

alexjaquet@gmail.com wrote:

> I do the following code but I got this error : PHP Warning:
> mysql_num_rows(): supplied argument is not a valid MySQL result
> resource in C:\\Apache2\\htdocs\\recordz\\php\\main.php on line 36
>
> Any idea ?


Well first, you're machine seems to be running Microsoft Windows which is
always a handicap.

>
> <?php
> $lang = $_GET['lang'];
> $link = mysql_connect("localhost", "root", "xxxx") or die ("Could not
> connect");
> mysql_select_db ("recordz",$link) or die ("Could not select
> database");
> $query="SELECT nom FROM category_$lang";
> $result=mysql_query($query,$link);


try
print mysql_error();
here

> $num = mysql_num_rows($result);
> for ($i = 0; $i > $num;$i++) {
> print "<option>$result[$i]</option>";
> }
> ?>
> :


C.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com