Joshua F Posted May 29, 2010 Share Posted May 29, 2010 Why doesn't the code below show what should be shown? <?php echo $list_b['username']; ?> My Full PHP Code to Select The Items From Database <? if($_GET['t'] == '') { $id="{$_GET['id']}"; ini_set('display_errors', '1'); error_reporting(E_ALL); if ($list_q = mysql_query("SELECT * FROM main WHERE id='$id'")) { if (mysql_num_rows($list_q)) { while($list_b=mysql_fetch_array($list_q)) { ?> Note: This will be getting the id from the url(user.php?t=&id=#) Quote Link to comment https://forums.phpfreaks.com/topic/203256-need-help/ Share on other sites More sharing options...
trq Posted May 29, 2010 Share Posted May 29, 2010 Why doesn't the code below show what should be shown? How should we know? You haven't exactly described your problem well. Quote Link to comment https://forums.phpfreaks.com/topic/203256-need-help/#findComment-1064924 Share on other sites More sharing options...
Joshua F Posted May 29, 2010 Author Share Posted May 29, 2010 Okay, I am wanting it to display the username of the account you are viewing. But in XAMPP, you have to have "<?php code ?>" instead of "<? ?>", and the code I started out with started with "<? ?>" therefor, I couldnt use that because It wont display anything, so I am trying to make it echo it out with "<?php echo ?>". Quote Link to comment https://forums.phpfreaks.com/topic/203256-need-help/#findComment-1064926 Share on other sites More sharing options...
trq Posted May 29, 2010 Share Posted May 29, 2010 Its never a good idea to code with short tags <? ?> because some servers have this option disabled. Always use <?php ?> Does that answer your question? Fix your problem? Quote Link to comment https://forums.phpfreaks.com/topic/203256-need-help/#findComment-1064927 Share on other sites More sharing options...
Joshua F Posted May 29, 2010 Author Share Posted May 29, 2010 No, I mean. Okay, here is the code I started out with... <?=$list_f['username'];?> I am trying to make it with with the "<?php ?>" code. But I cannot seem to figure it out. Quote Link to comment https://forums.phpfreaks.com/topic/203256-need-help/#findComment-1064928 Share on other sites More sharing options...
trq Posted May 29, 2010 Share Posted May 29, 2010 <?php echo $list_f['username'];?> Quote Link to comment https://forums.phpfreaks.com/topic/203256-need-help/#findComment-1064931 Share on other sites More sharing options...
Joshua F Posted May 29, 2010 Author Share Posted May 29, 2010 It just doesn't seem to want to show it.. Still not working. Quote Link to comment https://forums.phpfreaks.com/topic/203256-need-help/#findComment-1064934 Share on other sites More sharing options...
trq Posted May 29, 2010 Share Posted May 29, 2010 Post your actual code then. Quote Link to comment https://forums.phpfreaks.com/topic/203256-need-help/#findComment-1064935 Share on other sites More sharing options...
Joshua F Posted May 29, 2010 Author Share Posted May 29, 2010 This is my whole user.php code <?php session_start(); include "includes/connect.php"; include "includes/stat_conf.php"; echo '<center>' ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <? if($_GET['t'] == '') { $id="{$_GET['id']}"; ini_set('display_errors', '1'); error_reporting(E_ALL); if ($list_q = mysql_query("SELECT * FROM main WHERE id='$id'")) { if (mysql_num_rows($list_q)) { while($list_b=mysql_fetch_array($list_q)) { ?> <body> <div id="container"> <div id="header"> <?php require 'includes/links.php'?> </div> <div id="content"> <?php require 'includes/menus.php'?> <div id="middle"> <div class="post"> <div class="postheader"><h1><?php echo $list_b['id'];?></h1></div> <div class="postcontent"> <? } } } }?> </div> <div class="postfooter"></div> </div> </div> </div> <div id="footer"> <?php require 'includes/links.php'?> <?php require 'includes/footer.php'?> </div> </div> </body> </html>[/php Quote Link to comment https://forums.phpfreaks.com/topic/203256-need-help/#findComment-1064936 Share on other sites More sharing options...
trq Posted May 29, 2010 Share Posted May 29, 2010 If you view the source does the html content show up? I would say your query isn't finding any result. Also, if your only expecting 1 record to be returned don't use a loop. If you did have more than record returned in this case your html would be broken because you would have multiple <body> tags. Quote Link to comment https://forums.phpfreaks.com/topic/203256-need-help/#findComment-1064942 Share on other sites More sharing options...
Joshua F Posted May 29, 2010 Author Share Posted May 29, 2010 I uploaded it to a webhost, instead of my computer, and It works fine. I'll just edit that one part of the site over the webhost, and the rest of it over XAMPP. Quote Link to comment https://forums.phpfreaks.com/topic/203256-need-help/#findComment-1064943 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.