Ratee Posted February 24, 2012 Share Posted February 24, 2012 I need help with this script...... i get the error... 'Undefined index: username in C:\wampnew\www\login and register\profile.php on line 28!' <?php require("include/connect.php"); if(!isset($_GET['id'])) { echo("Please enter a members profile to view."); die(); } elseif($_GET['id'] == "") { echo("Please enter a members profile to view."); die(); } $pid = mysql_real_escape_string(preg_replace("@[^a-z0-9]@i","",$_GET['id'])); $check = mysql_num_rows(mysql_query("SELECT id FROM tut_users WHERE id='{$pid}'")); if($check !="1") { echo("Member does not exist."); require("footer.php"); die(); } $sql = mysql_query("SELECT * FROM tut_users WHERE id='{$pid}'") or die(mysql_error()); $fetch = mysql_fetch_assoc($sql) or die(mysql_error()); $username = mysql_real_escape_string(preg_replace("@[^a-z0-9]@i","",$fetch['username'])); echo("Member Profile Of: {$username} <br /> " ); ?> Could someone please help me thanks... Quote Link to comment https://forums.phpfreaks.com/topic/257719-profile-help/ Share on other sites More sharing options...
Maq Posted February 24, 2012 Share Posted February 24, 2012 I can't read any of that, all I can see is a rainbow. Quote Link to comment https://forums.phpfreaks.com/topic/257719-profile-help/#findComment-1320904 Share on other sites More sharing options...
Ratee Posted February 24, 2012 Author Share Posted February 24, 2012 sorry..... I need help with this script...... i get the error... 'Undefined index: username in C:\wampnew\www\login and register\profile.php on line 28!' <?php require("include/connect.php"); if(!isset($_GET['id'])) { echo("Please enter a members profile to view."); die(); } elseif($_GET['id'] == "") { echo("Please enter a members profile to view."); die(); } $pid = mysql_real_escape_string(preg_replace("@[^a-z0-9]@i","",$_GET['id'])); $check = mysql_num_rows(mysql_query("SELECT id FROM tut_users WHERE id='{$pid}'")); if($check !="1") { echo("Member does not exist."); require("footer.php"); die(); } $sql = mysql_query("SELECT * FROM tut_users WHERE id='{$pid}'") or die(mysql_error()); $fetch = mysql_fetch_assoc($sql) or die(mysql_error()); $username = mysql_real_escape_string(preg_replace("@[^a-z0-9]@i","",$fetch['username'])); echo("Member Profile Of: {$username} <br /> " ); ?> Could someone please help me thanks... Quote Link to comment https://forums.phpfreaks.com/topic/257719-profile-help/#findComment-1320906 Share on other sites More sharing options...
Maq Posted February 24, 2012 Share Posted February 24, 2012 Where's line 28? There's only 27 lines of code there. In the future, place OR tags around your code. Quote Link to comment https://forums.phpfreaks.com/topic/257719-profile-help/#findComment-1320911 Share on other sites More sharing options...
Ratee Posted February 24, 2012 Author Share Posted February 24, 2012 there is no line 28 thats what i dont get Quote Link to comment https://forums.phpfreaks.com/topic/257719-profile-help/#findComment-1320912 Share on other sites More sharing options...
ManiacDan Posted February 24, 2012 Share Posted February 24, 2012 "Undefined index" means you used syntax $like['this'] and 'this' was not a member of $like. This code contains your only reference to ['username'] $sql = mysql_query("SELECT * FROM tut_users WHERE id='{$pid}'") or die(mysql_error()); $fetch = mysql_fetch_assoc($sql) or die(mysql_error()); $username = mysql_real_escape_string(preg_replace("@[^a-z0-9]@i","",$fetch['username'])); Clearly $fetch does not contain username. are you sure table tut_users contains a column called 'username'? Quote Link to comment https://forums.phpfreaks.com/topic/257719-profile-help/#findComment-1320913 Share on other sites More sharing options...
Ratee Posted February 24, 2012 Author Share Posted February 24, 2012 Thankyou i solved it now:D Quote Link to comment https://forums.phpfreaks.com/topic/257719-profile-help/#findComment-1320929 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.