Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2011
    Posts
    140
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Row results not echoing

    row results not echoing correctly
    PHP Code:
    <?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>

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    "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.
    OracleGuy

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    This makes no sense:
    Code:
    $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:
    Code:
    <?php 
    session_start('$id'); ?>
    Again, you have no variable named $id.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •