NYCPHP Meetup

NYPHP.org

[nycphp-talk] mysql_num_rows error

Bradley Baumann bradley at bestweb.net
Thu Jan 9 22:25:14 EST 2003


I have a feeling that your query isn't being executed properly.
add an "or die"... example :

$sql = 'SELECT * FROM blah';
$result = mysql_query($sql)
    or die(mysql_error());

...rest of code...

-Bradley Baumann

----- Original Message -----
From: "Phil Powell" <soazine at erols.com>
To: "NYPHP Talk" <talk at nyphp.org>
Sent: Thursday, January 09, 2003 9:48 PM
Subject: [nycphp-talk] mysql_num_rows error


> > Anyone know why this is happening? I have mySQL on Win2000 Server with
IIS
> > and PHP:
> >
> > mysql_num_rows(): supplied argument is not a valid MySQL result resource
> >
> > Here is my code:
> >
> > <?
> >   $conn = mysql_connect('localhost', "xxx", "yyy") or die('Could not
> connect
> > to db');
> >   $result = mysql_query('select * from blah');
> >   echo "Number of rows: " . mysql_num_rows($result);
> >   if (mysql_num_rows($result) > 0) {
> >    while ($row = mysql_fetch_row($result)) {
> >     for ($i = 0; $i < sizeOf($row); $i++) {
> >      echo "$i: " . $row[$i] . "<BR>";
> >     }
> >    }
> >   }
> > ?>
> >
> > It couldn't get any simpler.  I just installed mySQL on my machine and
am
> > trying to see what I can do with it giving Win2K and IIS.
> >
> > AUGH! Thanx
> > Phil
> >
>
>
>
> --- Unsubscribe at http://nyphp.org/list/ ---
>
>




More information about the talk mailing list