Jump to content


Photo

showing other members profile


  • Please log in to reply
29 replies to this topic

#1 almightyegg

almightyegg
  • Members
  • PipPipPip
  • Advanced Member
  • 791 posts
  • LocationEngland

Posted 24 October 2006 - 08:29 PM

i use $mem[row_name] to pull up my information from a database but i want to show other peoples so i did this...
$GET = $mem[id];
then started typing $mem[this] and $mem[that] then to see it puts in my info, not the persons id page it is  ???

how would i do that??
Visit my Game - Under Construction

#2 almightyegg

almightyegg
  • Members
  • PipPipPip
  • Advanced Member
  • 791 posts
  • LocationEngland

Posted 24 October 2006 - 08:59 PM

bumping it to the top :)
Visit my Game - Under Construction

#3 marcus

marcus
  • Members
  • PipPipPip
  • Advanced Member
  • 1,842 posts
  • LocationRochester, NY

Posted 24 October 2006 - 09:17 PM

<?php
$get = $_GET[id];

$sql = "SELECT * FROM dbtable WHERE user.id='$get';";
$result=mysql_query($sql);
$result2=mysql_fetch_assoc($result);
?>
Welcome to <?=$result2[username]?> profile.

For everything else $result2[DBFIELD];

change dbfield to a field in your DB, whether it's username, email, website, or whatever

#4 almightyegg

almightyegg
  • Members
  • PipPipPip
  • Advanced Member
  • 791 posts
  • LocationEngland

Posted 24 October 2006 - 09:22 PM

doesnt work :(
$GET = $mem[id];

$view = "SELECT * FROM user WHERE id='$GET'";
$result=mysql_query($view);
$player=mysql_fetch_assoc($result);
it comes out with: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/lordofth/public_html/player/view.php on line 70

Visit my Game - Under Construction

#5 marcus

marcus
  • Members
  • PipPipPip
  • Advanced Member
  • 1,842 posts
  • LocationRochester, NY

Posted 24 October 2006 - 09:30 PM

you need register globals on

make a file called php.ini

and make the file include this: register_globals= On

#6 almightyegg

almightyegg
  • Members
  • PipPipPip
  • Advanced Member
  • 791 posts
  • LocationEngland

Posted 24 October 2006 - 09:34 PM

right i made that file and uploaded it to the same directory and it did nothing...:(

do i have to put something into the page im trying to make this think work on??
Visit my Game - Under Construction

#7 marcus

marcus
  • Members
  • PipPipPip
  • Advanced Member
  • 1,842 posts
  • LocationRochester, NY

Posted 24 October 2006 - 09:35 PM

you're connecting to the db right?

#8 marcus

marcus
  • Members
  • PipPipPip
  • Advanced Member
  • 1,842 posts
  • LocationRochester, NY

Posted 24 October 2006 - 09:37 PM

<?php
$connection = mysql_connect(localhost,dbuser,dbpass);
$db = mysql_select_db(dbname,$connection);
    $sql = "SELECT * FROM user
            WHERE user.id='$_GET[id];'";
    $result = mysql_query($sql);
    $result2 = mysql_fetch_assoc($result);
    $user = $result2[username];

?>
<?
if($_GET[id] == false){
echo "No user specify";
}else {
?>
<h3>Welcome to <?=$user?>'s profile.</h3><br>

<? } ?>


#9 almightyegg

almightyegg
  • Members
  • PipPipPip
  • Advanced Member
  • 791 posts
  • LocationEngland

Posted 24 October 2006 - 09:38 PM

yes....am i meant to have anything else in my .ini file??
all i have is register_globals= On
i never used ini before
Visit my Game - Under Construction

#10 marcus

marcus
  • Members
  • PipPipPip
  • Advanced Member
  • 1,842 posts
  • LocationRochester, NY

Posted 24 October 2006 - 09:39 PM

just keep the php.ini file like that for now

#11 kirk112

kirk112
  • Members
  • PipPipPip
  • Advanced Member
  • 98 posts
  • LocationEngland

Posted 24 October 2006 - 09:41 PM

$connection = mysql_connect(localhost,dbuser,dbpass);
$db = mysql_select_db(dbname,$connection);
 
$member_id = $_GET['id'];

echo $member_id;  //check to see if there is a value

   $sql = "SELECT * FROM user
            WHERE user.id='$member_id'";
    $result = mysql_query($sql) or die(mysql_error());
    $result2 = mysql_fetch_assoc($result);
    $user = $result2['username'];

?>
<?
if($member_id == false){
echo "No user specify";
}else {
?>
<h3>Welcome to <?=$user?>'s profile.</h3><br>

<? } ?>

Is $member_id blank when it echos out

#12 almightyegg

almightyegg
  • Members
  • PipPipPip
  • Advanced Member
  • 791 posts
  • LocationEngland

Posted 24 October 2006 - 09:43 PM

shows this still:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/lordofth/public_html/player/view.php on line 70
Visit my Game - Under Construction

#13 marcus

marcus
  • Members
  • PipPipPip
  • Advanced Member
  • 1,842 posts
  • LocationRochester, NY

Posted 24 October 2006 - 09:45 PM

if no member of that id is valid it will just create blank fields

#14 marcus

marcus
  • Members
  • PipPipPip
  • Advanced Member
  • 1,842 posts
  • LocationRochester, NY

Posted 24 October 2006 - 09:46 PM

you do have the php.ini file right? with register_globals= On right?

#15 almightyegg

almightyegg
  • Members
  • PipPipPip
  • Advanced Member
  • 791 posts
  • LocationEngland

Posted 24 October 2006 - 09:49 PM

yes...
the whole document is just:
register_globals= On

... ???
Visit my Game - Under Construction

#16 knowNothing

knowNothing
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 24 October 2006 - 09:51 PM

Can't it be done without enabling register_globals?  Just trying to keep with the whole "Lets try to make secure code" idea...

#17 marcus

marcus
  • Members
  • PipPipPip
  • Advanced Member
  • 1,842 posts
  • LocationRochester, NY

Posted 24 October 2006 - 09:52 PM

um, could you send me a PM with the URL?

#18 kirk112

kirk112
  • Members
  • PipPipPip
  • Advanced Member
  • 98 posts
  • LocationEngland

Posted 24 October 2006 - 09:53 PM

can you post your full source code you should not need registered globals on to get a value

#19 almightyegg

almightyegg
  • Members
  • PipPipPip
  • Advanced Member
  • 791 posts
  • LocationEngland

Posted 24 October 2006 - 09:55 PM

<?
session_start(); // Session Start
include 'database.php'; // Connect to DB
$email = $_SESSION['email']; 
$password = $_SESSION['password']; 
if((!$email) || (!$password)){ 
echo "Please enter ALL of the information! <br />"; 
include 'index.php'; 
exit(); 
} 
// check if the user info validates the db 
$password2 = md5($password);
if((!$email) || (!$password)){ 
echo "Please enter ALL of the information! <br />";
echo '<a href=index.html>Click here to return to the main page</a>';
exit(); 
} 
// check if the user info validates the db 
$sql = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$password2' AND activated='1'"); 
$login_check = mysql_num_rows($sql); 

if($login_check == 0){
$sql1 = mysql_query("SELECT * FROM users WHERE email='$email'");
$sql2 = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$password2'");
$sql3 = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$password2' AND activated='1'");
$c1 = mysql_num_rows($sql1); 
$c2 = mysql_num_rows($sql2); 
$c3 = mysql_num_rows($sql3);
//"Your email and password dont match or you didnt validate your account yet"
echo"The following errors were found from your login.<br>";
if($c1==0){
echo"The email you've entered was not valid. Please go back and <a href=index.php>try again</a>.";
}elseif($c2==0){
echo"The password you've entered was incorrect. Please go back and <a href=index.php>try again</a>. If you would like your password sent to you via email please <a href=lostpw.php>click here</a>";
}elseif($c3==0){
echo"You did not yet validate your account! If you would like your validation code sent to you via email please <a href=resend.php>click here</a>.";
}
}else{
$mems = mysql_query("SELECT * FROM users WHERE email='$email'") or die(mysql_error());
$mem = mysql_fetch_array($mems);
$clt = mysql_query("SELECT * FROM clutch WHERE id='$id'") or die(mysql_error());
$clutch = mysql_fetch_array($clt);
$link = mysql_query("SELECT * FROM links") or die(mysql_error());
$qlink = mysql_fetch_array($link);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="default.css"> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><? echo $clutch[name] ?></title>
</head>

<body bgcolor=black>
<center>
<?
$tags = array('{MEM_ID}', '{MEM_USERNAME}', '{MEM_CLUTCH}');
$vals = array($mem['id'], $mem['username'], $mem[clutch]);
$qlink['quicklinks'] = str_replace($tags, $vals, $qlink['quicklinks']);
echo "$qlink[quicklinks]";
?>
</center>
<table border=0 width=100% cellpadding=15>
<td width=150 valign=top>
<?
$GET = $mem[id];

$view = "SELECT * FROM user WHERE user.id='$GET'";
$result = mysql_query($view);
$result2 = mysql_fetch_assoc($result);
$user = $result2[username];


if($mem[gender] == Male){
?>
<img src=http://lordoftheabyss.com/images/male.JPG title=Male>
<?
}else{
?>
<img src=http://lordoftheabyss.com/images/female.JPG title=Female>
<?
}
if($mem[id] == ('1') || ('2') || ('3') || ('4') || ('5') || ('6') || ('7') || ('8') || ('9') || ('10')){
?>
<img src=http://www.lordoftheabyss.com/images/admin.png title=Administrator><br>
<?
}else{
}
echo "<img src=$mem[img]>";
?>
</td>
<td valign=top>
<? echo $user ?>
</tD>
</table>
<center>
<?
$tags = array('{MEM_ID}', '{MEM_USERNAME}', '{MEM_CLUTCH}');
$vals = array($mem['id'], $mem['username'], $mem[clutch]);
$qlink['quicklinks'] = str_replace($tags, $vals, $qlink['quicklinks']);
echo "$qlink[quicklinks]";
?>
</center>
<?
}
?>
</body>
</html>

Visit my Game - Under Construction

#20 kirk112

kirk112
  • Members
  • PipPipPip
  • Advanced Member
  • 98 posts
  • LocationEngland

Posted 24 October 2006 - 09:57 PM

on the select you have been working should it be users and not user

SELECT * FROM users WHERE users.id='$GET'";




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users