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

From: Date: Mon, 05 Jul 2004 02:08:54 +0000
Subject: Re: Unable to retrieve value from database and echo on screen
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-189679@lists.php.net to get a copy of this message
Larry E . Ullman wrote: > > > /* 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 Larry: It's good to see you posting here. I'm on page 30 of your book and find it to be very helpful and extremely well written. Mike

« previous php.general (#189679) next »