almightyegg Posted October 24, 2006 Share Posted October 24, 2006 i use $mem[row_name] to pull up my information from a database but i want to show other peoples so i did this...[code=php:0]$GET = $mem[id];[/code]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?? Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/ Share on other sites More sharing options...
almightyegg Posted October 24, 2006 Author Share Posted October 24, 2006 bumping it to the top :) Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113854 Share on other sites More sharing options...
marcus Posted October 24, 2006 Share Posted October 24, 2006 [code]<?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.[/code]For everything else $result2[DBFIELD];change dbfield to a field in your DB, whether it's username, email, website, or whatever Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113871 Share on other sites More sharing options...
almightyegg Posted October 24, 2006 Author Share Posted October 24, 2006 doesnt work :([code=php:0]$GET = $mem[id];$view = "SELECT * FROM user WHERE id='$GET'";$result=mysql_query($view);$player=mysql_fetch_assoc($result);[/code]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 Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113875 Share on other sites More sharing options...
marcus Posted October 24, 2006 Share Posted October 24, 2006 you need register globals onmake a file called php.iniand make the file include this: register_globals= On Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113881 Share on other sites More sharing options...
almightyegg Posted October 24, 2006 Author Share Posted October 24, 2006 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?? Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113883 Share on other sites More sharing options...
marcus Posted October 24, 2006 Share Posted October 24, 2006 you're connecting to the db right? Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113884 Share on other sites More sharing options...
marcus Posted October 24, 2006 Share Posted October 24, 2006 [code]<?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><? } ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113885 Share on other sites More sharing options...
almightyegg Posted October 24, 2006 Author Share Posted October 24, 2006 yes....am i meant to have anything else in my .ini file??all i have is register_globals= Oni never used ini before Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113887 Share on other sites More sharing options...
marcus Posted October 24, 2006 Share Posted October 24, 2006 just keep the php.ini file like that for now Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113888 Share on other sites More sharing options...
kirk112 Posted October 24, 2006 Share Posted October 24, 2006 [code]$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><? } ?>[/code]Is $member_id blank when it echos out Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113890 Share on other sites More sharing options...
almightyegg Posted October 24, 2006 Author Share Posted October 24, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113892 Share on other sites More sharing options...
marcus Posted October 24, 2006 Share Posted October 24, 2006 if no member of that id is valid it will just create blank fields Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113894 Share on other sites More sharing options...
marcus Posted October 24, 2006 Share Posted October 24, 2006 you do have the php.ini file right? with register_globals= On right? Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113897 Share on other sites More sharing options...
almightyegg Posted October 24, 2006 Author Share Posted October 24, 2006 yes...the whole document is just:register_globals= On... ??? Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113899 Share on other sites More sharing options...
knowNothing Posted October 24, 2006 Share Posted October 24, 2006 Can't it be done without enabling register_globals? Just trying to keep with the whole "Lets try to make secure code" idea... Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113901 Share on other sites More sharing options...
marcus Posted October 24, 2006 Share Posted October 24, 2006 um, could you send me a PM with the URL? Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113903 Share on other sites More sharing options...
kirk112 Posted October 24, 2006 Share Posted October 24, 2006 can you post your full source code you should not need registered globals on to get a value Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113906 Share on other sites More sharing options...
almightyegg Posted October 24, 2006 Author Share Posted October 24, 2006 [code=php:0]<?session_start(); // Session Startinclude '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>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113907 Share on other sites More sharing options...
kirk112 Posted October 24, 2006 Share Posted October 24, 2006 on the select you have been working should it be users and not userSELECT * FROM users WHERE users.id='$GET'"; Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113908 Share on other sites More sharing options...
almightyegg Posted October 24, 2006 Author Share Posted October 24, 2006 right, it no longer displays a delay, but displays my info...[code=php:0]$view = "SELECT * FROM users WHERE users.id='$GET'";$view2 = mysql_query($view);$view3 = mysql_fetch_assoc($view2);$user = $view3[username];[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113912 Share on other sites More sharing options...
kirk112 Posted October 24, 2006 Share Posted October 24, 2006 it that correct or are you still having problems Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-113916 Share on other sites More sharing options...
almightyegg Posted October 25, 2006 Author Share Posted October 25, 2006 still having problems, the page is: http://www.lordoftheabyss.com/player/view.php?id=3 so therefore should show the row with id=3 but instead it shows mine (id=1) Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-114116 Share on other sites More sharing options...
almightyegg Posted October 25, 2006 Author Share Posted October 25, 2006 i think i may know why it isnt working but i dont know how to sort it...[code=php:0]$GET = $mem[id];//$mem[id] is the thing i use to pull up my id$view = "SELECT * FROM users WHERE users.id='$GET'";//so here, it is selecting my row??$view2 = mysql_query($view);$view3 = mysql_fetch_assoc($view2);$user = $view3[username];[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-114121 Share on other sites More sharing options...
HuggieBear Posted October 25, 2006 Share Posted October 25, 2006 OK, it seems that this has been going on a while, and you've also been fed a lot of trap!Firstly, delete that php.ini file that you created and dropped into that directory. A few have mentioned register_globals but none have actually explained what it means/does. So here goes in it's simplest form:[i]Having register_globals switched on, means that you can refer to a variable in php using the name that was provided in the request object, without the need to specify where it came from.[/i]Example: If I have a form that has one field called 'name' and I use the method 'post' to send it to a php page and I want to use that variable. If register_globals is switched off (by default in newer versions of php), I have to use this...[code=php:0]echo $_POST['name'];[/code]If register_globals is on then I can use this:[code=php:0]echo $name;[/code]It automatically imports 'name' into the variable name space, meaning I don't need to specify $_POST.So for your example, you need to use the following code.[code]<?php$view = "SELECT * FROM users WHERE id = '{$_GET['id']}' LIMIT 1";$view2 = mysql_query($view);$view3 = mysql_fetch_assoc($view2);$user = $view3['username'];?>[/code]The above example assumes that the column in the table (users) that contains the unique user ID is called 'id'RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/#findComment-114128 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.