My current user profiles only show the private section, ie for users to change their username or password or email. I’d like it so there is a public profile other users can view, so the usual myprofile.php?id=1 public profile. Here’s the original profile code:
[php]<?php
session_start();
include(‘config.php’);
include(‘date.php’);
$sql = mysql_query( “SELECT * FROM users WHERE id=’”.$_SESSION[‘id’]."’" );
$userfinal = $_SESSION[‘id’];
$user = $userfinal;
$id = $_GET[‘id’];
echo "
Profile
ID#: | ”.$user." |
---|---|
Name: | “.$row[‘callname’].” |
Email: | “.$row[‘email’].” |
Password: | <input type=‘password’ value=’".$row[‘password’]."’ disabled=‘true’ /> |
Registered: | “.$row[‘registered’].” |
Last Login: | “.$row[‘lastlogin’].” |
";
?>
<?php include('footer.php'); ?>[/php]
And with the editprofile.php it works fine. However I tried changing it so it would display a public version others could see, here’s my revisions:
[php]<?php
session_start();
include(‘config.php’);
include(‘date.php’);
$id = $_GET[‘id’];
$sql = mysql_query(“SELECT * FROM members WHERE id = ‘$id’ LIMIT 1”);
$check = mysql_num_rows($sql);
if ($check > 1)
{
echo “No one matches that id number!”;
exit();
}
if($check == 1)
{
while($row = mysql_fetch_array($sql))
{
$user = $id;
echo "
Profile
ID#: | ”.$user." |
---|---|
Name: | “.$row[‘callname’].” |
Email: | “.$row[‘email’].” |
Password: | <input type=‘password’ value=’".$row[‘password’]."’ disabled=‘true’ /> |
Registered: | “.$row[‘registered’].” |
Last Login: | “.$row[‘lastlogin’].” |
”;
}
if($id = $_SESSION[‘id’])
{
echo "
Profile
ID#: | ”.$user." |
---|---|
Name: | “.$row[‘callname’].” |
Email: | “.$row[‘email’].” |
Password: | <input type=‘password’ value=’".$row[‘password’]."’ disabled=‘true’ /> |
Registered: | “.$row[‘registered’].” |
Last Login: | “.$row[‘lastlogin’].” |
"; } }
else {
die ();
}
?>
And that doesn’t work, the $check = mysql_num_rows($sql); failed because it gave a warning of:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given for that specific line
Any ideas on how I could fix this code to get it working, or how to revise my original code (posted first) to have public/private profiles?