Jump to content

problems displaying retrieved data


pcw

Recommended Posts

Hi, I have the following script and am using it to display the members username. Ideally I would like the result to be displayed in between the <h2></h2> tags next to Welcome but no matter what I try it wont work.

 

However the information is displayed in the first part of the script. I have indicated the part that correctly displays the information, but how do I display it elsewhere in the page?

 

<?php

session_start();

// This checks to make sure the session variable is registered

// WARNING: DO NOT DELETE THE FOLLOWING LINE OF TEXT

if( isset($_SESSION['username']) && isset($_SESSION['sid'])) {

// You are free to edit the following code to suit your requirements

include_once("../../data/server.php");
include_once("../../lib/userdata.php");

// THIS BIT WORKS AND DISPLAYS THE USERNAME

$data = mysql_query("SELECT * FROM members") 
or die(mysql_error()); 
Print "<table border cellpadding=3>"; 
while($info = mysql_fetch_array( $data )) 
{ 
Print "<tr>"; 
Print "<th>Username:</th> <td>".$info['username'] . "</td> "; 

////////////////////////////////////////////


PRINT <<<HOME
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>$siteName</title>
<link rel="stylesheet" href="../../userstylesheet.css" type="text/css" />

</head>

<div id="page">
  <img alt="" src="../../images/leftCurve" height="6" width="6" id="left" /> <img alt="" src="../../images/rightCurve.gif" height="6" width="6" id="right" />
  
  <div id="pageName">
    <h1>$siteName</h1>
     </div>
  <div id="pageNav">
    <div id="sectionLinks"> <a href="index.html">Home</a> <a href="register.html">Register</a> <a href="login.html">Login</a> <a href="search.html">Search</a></div>
  </div>
  <div id="content">
    <div class="feature">
      <h2>Welcome </h2>
      <p>This is the demonstration home.html template. You are free to edit this or any of the other templates to suit your own needs. </p>
      <p>This is the first page your member will see once they have logged in. </p>
      <p>For any information please visit our site http://www.membersitemaker.co.uk. User guides will be added shortly and the forum will soon be full of help. </p>
    </div>
  </div>
  <div id="information">  <a href="#">About Us</a> | <a href="#">Site Map</a> | <a href="#">Privacy Policy</a> | <a href="#">Contact Us</a> | ©2003 $siteName </div>
</div>

</body>
</html>
HOME;
}
// WARNING: DO NOT DELETE THE REST OF THE CODE BELOW

} else {

// This will redirect the user to the login page if the session variables do not exist

header( "Location: ../../../login.html" );
}
?>

 

Many Thanks

 

Paul

 

 

Link to comment
Share on other sites

and <td> is an html attribute not mysql but you can still display results between <td></td> so i believe that is irrelevant. I just need a way to display ".$info['username'] . " anywhere else on the page, but I get an error. If it is displayed between the <h2></h2> tags, I get this error:

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/tropicsb/public_html/MemberSiteMaker/templates/members/home.php on line 50

 

even happens if I end the <<<TAG at <h2>

 

And use

 

Print ".$info['username'] . ";

 

and then restart the <<<TAG at </h2>

 

I still get the same error.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.