Re: PHP - MySQL Query...

From: Date: Wed, 13 Aug 2003 23:20:49 +0000
Subject: Re: PHP - MySQL Query...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-159502@lists.php.net to get a copy of this message
Steven Kallstrom wrote:
Hello all... I'm embarrassed by this one... I think it should work but it isn't... $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); 
Try this instead; $result = mysql_query($query) or die("Query died: " . mysql_error()); Cheers! -Michael
      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? Thanks, SJK **


« previous php.general (#159502) next »