Re: Unable to retrieve value from database and echo on screen

From: Date: Sun, 04 Jul 2004 16:43:58 +0000
Subject: Re: Unable to retrieve value from database and echo on screen
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-189670@lists.php.net to get a copy of this message
/* Select User's First Name From Table */ $sql = "SELECT UserFirstName FROM RegisteredMembers WHERE UserID='$_POST[TXT_UserID]'"; $result5 = mysql_query($sql) or die ("couldn't select UserID from database"); $num = mysql_num_rows($result); /* Welcome Registsred Member */ echo "welcome to the registered members area "; echo ("$result");
There are a few problems here: 1) Your query result is assigned to $result5 but then you use $result in the mysql_num_rows() function. 2) You never fetch any information. You need something like $row = mysql_fetch_array($result5). 3) You're trying to print the query result when you should be printing the fetched information like so echo $row['UserFirstName']; Hope that helps, Larry

« previous php.general (#189670) next »