pcw Posted March 11, 2011 Share Posted March 11, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/230363-problems-displaying-retrieved-data/ Share on other sites More sharing options...
fenway Posted March 11, 2011 Share Posted March 11, 2011 <h2> is an html attribute -- not mysql. Quote Link to comment https://forums.phpfreaks.com/topic/230363-problems-displaying-retrieved-data/#findComment-1186291 Share on other sites More sharing options...
pcw Posted March 11, 2011 Author Share Posted March 11, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/230363-problems-displaying-retrieved-data/#findComment-1186301 Share on other sites More sharing options...
fenway Posted March 11, 2011 Share Posted March 11, 2011 Again, that's a PHP error. There's a PHP help forum for that. If your DB query isn't failing, you're in the wrong place. Quote Link to comment https://forums.phpfreaks.com/topic/230363-problems-displaying-retrieved-data/#findComment-1186325 Share on other sites More sharing options...
pcw Posted March 11, 2011 Author Share Posted March 11, 2011 then please move this thread to the PHP forum Thanks Paul Quote Link to comment https://forums.phpfreaks.com/topic/230363-problems-displaying-retrieved-data/#findComment-1186350 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.