RE: [PHP-DB] Select Query--Need help urgently
| From: | Katie Evans-Young | Date: | Sat, 27 Mar 2004 15:53:25 +0000 |
| Subject: | RE: [PHP-DB] Select Query--Need help urgently | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-33668@lists.php.net to get a copy of this message | ||
Irin said:
> $sql = mysql_query("SELECT * FROM class where timetable_day='Monday'");
>
> $row = mysql_fetch_array($sql);
> $result = $db->query($sql);
> $numofrows = mysql_num_rows($sql);
From the PHP manual:
array mysql_fetch_array ( resource result [, int result_type])
You can't send the function mysql_fetch_array a string as a parameter. It
needs a result resource.
Assuming that your $db class returns a result resource, you can try this:
$sql = "SELECT * FROM table";
$result = $db->query($sql);
$row = mysql_fetch_array($result);
$numofrows = mysql_num_rows($result);
If for some reason you don't know what that class function "query" is
returning, you can do it this way and it will work for sure:
$sql = "SELECT * FROM table";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$numofrows = mysql_num_rows($result);
HTH,
Katie Dewees
Web Developer
E-mail: kdewees@bellsouth.net