Page 1 of 1

Beginner Question

Posted: Tue Oct 21, 2003 9:24 am
by AliasBDI
This may be stupid but I've never had to do it. So now that I do need it, I cannot figure it out.

I need to query the database for a particular record with WHERE. Then I need to take the particular fields (stated in the query) and turn them into constants to be used elsewhere in the page below.

Here is my code so far:

Code: Select all

<?php
$result = mysql_query("SELECT first_name, last_name, email_address, username, decrypted_password, dl, birth FROM users WHERE dl='16638868' AND birth='10-28-1978' ") or die (mysql_error());
if (!$result) &#123;
    print mysql_error()." ERROR - browse query failed.";
    exit();
&#125;
while ( $row = mysql_fetch_array($result) )
 &#123;    
echo ($row&#1111;"username"]);  
echo $row&#1111;"first_name"];
&#125;
?>
Now, as you can see I can only echo the field results. But I need them to be constants. I tried doing the basic "$username = echo ($row["username"])" but it did not work.

Any ideas?

Posted: Tue Oct 21, 2003 9:26 am
by twigletmac
Instead of

Code: Select all

$username = echo ($row["username"]);
try

Code: Select all

$username = $row['username'];
Mac

thanks

Posted: Tue Oct 21, 2003 9:41 am
by AliasBDI
WORKED great!

Thanks.

Posted: Tue Oct 21, 2003 9:43 am
by markl999
$username = $row['username']; <-- you are missing the ;

THanks

Posted: Tue Oct 21, 2003 9:44 am
by AliasBDI
thanks markl999,

I noticed that and changed my post in an attempt to save anyone else from being bothered with it....thanks though.

Posted: Wed Oct 22, 2003 3:10 am
by twigletmac
markl999 wrote:$username = $row['username']; <-- you are missing the ;
Copy and paste error, oops.

Mac