...

View Full Version : Row results not echoing



amcf1992
09-26-2011, 05:40 PM
row results not echoing correctly

<?php
session_start('$id'); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<LINK href="includes/css/style.css" rel="stylesheet" type="text/css">
<title>Account Dashboard</title>
</head>
<body>
<?php
include('header.php');

include('dbsettings.php');

include('navbar.php');


$con = mysql_connect("$host","$user","$password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("$db_name", $con);
$username= $_row['username']; // Editted

$sql="SELECT * FROM `user` WHERE `username`='{$username}'";

$result = mysql_query("$sql");
?>
<div class= "accountsummary">
<?php
if($row = mysql_fetch_array($result)){

echo "ID:";
echo $row['id'];
echo "<BR />";
echo "First Name:";
echo $row['firstname'];
echo "<BR />";
echo "Last Name:";
echo $row['lastname'];
echo "<BR />";
echo "Address:";
echo $row['address'];


}




?>
</div>

<p class="logout">
<a href=logout.php>Logout</a>
</p>

<p style="position: absolute; top: 100px; left: 230px; background-color: white; margin: 15px; "> Welcome, <?php echo "$username"; ?> This is your account:<br />
<br/>
Amazing, really... <br />
</p>
<?php

mysql_close($con);
include('footer.php')
?>


</body>
</html>

oracleguy
09-26-2011, 06:07 PM
"Not correctly" is a rather vague description of what is going on. Perhaps add an else case onto your if where you print the record out to see if that is the call that is failing. Or check the number of rows returned from your query to make sure a record is even being returned.

Old Pedant
09-26-2011, 09:22 PM
This makes no sense:


$username= $_row['username']; // Editted

You have no variable named $_row.


*******

This also makes no sense, though I don't think it is relevant to the problem at hand:


<?php
session_start('$id'); ?>

Again, you have no variable named $id.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum