Try this,
    $result = mysql_query($query,$dbh);
-Murugesan

----- Original Message -----
From: "Jay Blanchard" <[EMAIL PROTECTED]>
To: "Steven Kallstrom" <[EMAIL PROTECTED]>; "PHP List"
<[EMAIL PROTECTED]>
Sent: Thursday, August 14, 2003 4:50 PM
Subject: RE: [PHP] PHP - MySQL Query...


[snip]
$dbh = mysql_connect("localhost", "login", "password") or
    die('cannot connect to the database because: ' . mysql_error());
mysql_select_db("database");

$query = 'SELECT * FROM cities';
$result = mysql_query($query);

 while ($row = mysql_fetch_row($result)) {
    echo ('<tr> <td class="city">' . $row[0] . ', ' . $row[1] . '</td>
    <td>' . $row[2] . '</td> <td>' . $row[3] . "</td> </tr>\n"); }

getting this error:

*Warning*: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource in...

so... is the problem with the $query?
I don't see anything wrong (assuming my login and database selection is
correct)
what are the common errors here?
[/snip]

mysql_query needs both the query variable and the connection
variable....
mysql_query($query, $dbh);

HTH!

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



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

Reply via email to