Accurax Posted December 12, 2006 Share Posted December 12, 2006 Thanks for the help eartlier guys, i at least understand how things are meant to work now :)I now have a script which is meant to display my member's names as links to "view_profile.php", however i seem to have got things a bit messed up, and i cant figure out why.heres the script[code]<?phpsession_start();include("include.inc");if ( $_SESSION['login'] != "true" ) { header("location: hacker.php"); }else { echo "<h1 align='center'>Here is our Member List<br /></h1>"; }$connection=mysql_connect($host, $user, $passwd) or die ("Could not connect !");$db = mysql_select_db($database, $connection) or die ("Could not connect to Database");$user_query = "SELECT user_name FROM members";$result = mysql_query($user_query) or die ("no can do"); $row = mysql_fetch_array($result);echo $row['user_name'];echo "<br>";while ( $row = mysql_fetch_array($result)){echo <a href="view_profile.php?user_name<?php echo $user_array['user_name'];?>">;echo "<br>";}?>[/code]Im not sure if its the syntax, or something else that causing the errors, can anyone see the problem here? Link to comment https://forums.phpfreaks.com/topic/30343-more-profile-problems/ Share on other sites More sharing options...
taith Posted December 12, 2006 Share Posted December 12, 2006 what errors are you getting? Link to comment https://forums.phpfreaks.com/topic/30343-more-profile-problems/#findComment-139596 Share on other sites More sharing options...
liam1412 Posted December 12, 2006 Share Posted December 12, 2006 The problem is with this section[code]$row = mysql_fetch_array($result);echo $row['user_name'];echo "<br>";while ( $row = mysql_fetch_array($result)){echo <a href="view_profile.php?user_name<?php echo $user_array['user_name'];?>">;echo "<br>";}[/code]You have declared the array from the database as the variable $row. When you are echoing out you are using the variable I used $user_array - Maybe thats my fault, $user_array is not a PHP function its just I variable I declared.Also on the echo<a href ="view_profile.php"?user_name[color=red]=[/color] - Yo missed the = sign before the <?php tags so when you try to collect it using $_GET. The variable will have np value.Thanks Link to comment https://forums.phpfreaks.com/topic/30343-more-profile-problems/#findComment-139597 Share on other sites More sharing options...
Accurax Posted December 12, 2006 Author Share Posted December 12, 2006 ok i now have the following.... but im getting a parse error like this:Parse error: parse error, unexpected '<' in C:\mysite\memberlist.php on line 29I think the problem is that my syntax is incorrect.... but im not sure why, heres the code as of now:[code]<?phpsession_start();include("include.inc");if ( $_SESSION['login'] != "true" ) { header("location: hacker.php"); }else { echo "<h1 align='center'>Here is our Member List<br /></h1>"; }$connection=mysql_connect($host, $user, $passwd) or die ("Could not connect !");$db = mysql_select_db($database, $connection) or die ("Could not connect to Database");$user_query = "SELECT user_name FROM members";$result = mysql_query($user_query) or die ("no can do"); $row = mysql_fetch_array($result);echo $row['user_name'];echo "<br>";while ( $row = mysql_fetch_array($result)){echo <a href="view_profile.php?user_name=<?php echo $row['user_name'];?>"</a>;echo "<br>";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/30343-more-profile-problems/#findComment-139600 Share on other sites More sharing options...
taith Posted December 12, 2006 Share Posted December 12, 2006 well yes... you already have php open...[code]while ($row = mysql_fetch_array($result)){ echo '<a href="view_profile.php?user_name='.$user_array['user_name'].'"><br>';}[/code] Link to comment https://forums.phpfreaks.com/topic/30343-more-profile-problems/#findComment-139604 Share on other sites More sharing options...
Accurax Posted December 12, 2006 Author Share Posted December 12, 2006 Ok i think ive got it.... i can display the links.... ill go and create the actual page now and see if i can get that to work... thanks guys... you all amazing Link to comment https://forums.phpfreaks.com/topic/30343-more-profile-problems/#findComment-139609 Share on other sites More sharing options...
Accurax Posted December 12, 2006 Author Share Posted December 12, 2006 Any idea why this doesnt work?I can make the anchor text into a normal text but i can make it echo the username of the profile in question[code]echo '<a href="view_profile.php?user_name='.$row['user_name'].'">; echo "$row['user_name']</a><br>'";[/code] Link to comment https://forums.phpfreaks.com/topic/30343-more-profile-problems/#findComment-139619 Share on other sites More sharing options...
Accurax Posted December 12, 2006 Author Share Posted December 12, 2006 this works :[code]echo '<a href="view_profile.php?user_name='.$row['user_name'].'">'; echo $row['user_name']; echo "</a><br>";[/code] Link to comment https://forums.phpfreaks.com/topic/30343-more-profile-problems/#findComment-139620 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.