Jump to content

More profile problems


Accurax

Recommended Posts

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]
<?php
session_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

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

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 29

I think the problem is that my syntax is incorrect.... but im not sure why, heres the code as of now:

[code]
<?php
session_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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.