Hi Alex,
mySQL doesn't return normal PHP values. You need to use mysql functions to
convert the mySQL resulting data into an array, like so:
// mySQL Table:
// --------------------------------
// field1 | field2 | stuff |
// --------------------------------
// Florida | Ferrari | George |
// --------------------------------
// Detroit | Honda | Raymond |
// --------------------------------
// Kansas | Porsche | Betsy |
// --------------------------------
$Link = mysql_connect("server","username","password");
$Query = "SELECT field2,stuff FROM table;";
$Result = mysql_db_query("database",$Query,$Link);
while($ResultRow = mysql_fetch_array($Result))
{
// Now we're in a loop that cycles 3 times (there are 3 records)
// The first time, $ResultRow will be an array that looks like:
// $ResultRow["field2"] => "Ferrari"
// $ResultRow["stuff"] => "George"
// The next cycle through the loop, $ResultRow will look like:
// $ResultRow["field2"] => "Honda"
// $ResultRow["stuff"] => "Raymond"
// The last cycle through the loop, $ResultRow will be:
// $ResultRow["field2"] => "Porsche"
// $ResultRow["stuff"] => "Betsy"
print $ResultRow["stuff"] . " owns a " . $ResultRow["field2"] . "<BR>";
}
// The above script will write the following to your screen:
// George owns a Ferrari
// Raymond owns a Honda
// Betsy owns a Porsche
Hope this helps.
- Jonathan
"Default" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi,
>
> I'm using PHP 4 and mysql. I'm trying to do just a simple query from a
> database table, but every time it returns the value, it returns
> "Resource id #2" and results like that. Any ideas? Thanks.
>
> Alex
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]