RE: Select Query--Need help urgently

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux