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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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