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? Quote Link to comment Share on other sites More sharing options...
taith Posted December 12, 2006 Share Posted December 12, 2006 what errors are you getting? Quote Link to comment 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 Quote Link to comment 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] Quote Link to comment 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] Quote Link to comment 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 Quote Link to comment 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] Quote Link to comment 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] Quote Link to comment 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.