Hi,
I got this strange situation here...
In the following code, I'm just normally retrieving a data from my database.
Given $first_name should be 'php' according to the database, I expected a result output:
In database
php
But instead I get:
In database
Resource id #2
Anyone know what's wrong with my code? Don't know what Resource id #2 means.
//connect server and select database
$link = mysql_connect($db_host,$db_user,$db_pass) or die ('Unable to connect to SQL server.');
mysql_select_db($db_name) or die ('Unable to locate' . $db_name . ' database');
$str='phpisgood';
$first_name = mysql_query("SELECT first_name FROM php_exercise2 WHERE username = '$str'");
if (mysql_num_rows($first_name)==0) {
echo 'News type not in database.' . "\n";
}
else{
echo "In database\n";
echo $first_name;