Jump to content

$id = _GET ['id']; Not Working :/ Please Help.... URGENT!


Go to solution Solved by davidfattore,

Recommended Posts

Hi Guys,

 

Something strange happened, 

 

Today when I logged onto a site that I'm building, the code seemed to have errors, despite the fact that I hadn't touched it since I uploaded it initially.

 

The Code is below:

          <?php
				if((isset($_GET['id'])) && (is_numeric($_GET['id']))) { //accessed through viewusers.
					$id = $_GET['id'];
				} elseif ((isset($_POST['id'])) && (is_numeric($_POST['id']))) { //form has been subbed.
					$id = $_POST['id'];
				} else {
					print '<h2> Page Error </h2>';
					print '<p class=error> This page has been accessed in error. </p>';
				}
			?>

It's giving me the page error portion and not recognizing the $id, thereby screwing with my WHERE clause in my SQL query... see below

$query = "SELECT userID, username, password, first_name, last_name, email, gender, blurb, points, games_played, games_won, badges_earned, tournaments_won,  dob_day, dob_month, dob_year, dp, badgeID, badges, unlocked, feat_badge, feat_badge_name, feat_badge_xp, level, administration, registration_date FROM users WHERE userID = $id";
 

Is there any other way to write that $id = _GET ['id']; code as I'm not sure why it would stop working as yesterday it was working fine!

 

Is there a .htaccess file in the root of your site? and is there code like   RewriteEngine On and RewriteRules defined in that file? If there is then mod_rewrite is being used. Can you post the RewriteRules here. I have feeling the rewrite rules are not passing the query string.

Edited by Ch0cu3r
That is all that is in my .htaccess file

 

# BEGIN WordPress

<IfModule mod_rewrite.c>

SetEnv TZ Australia/Melbourne

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>

 

# END WordPress

no there isn't a second .htaccess file within the players directory.

 

It's strange because it was working 24 hours ago and that index page hasn't been altered, only the database info has and I do that remotely.  

i'm going to guess your page has a header() redirect back to itself, for just the base url without the ?query string on it and you are seeing the result of the second page request?

 

if so, your execution path probably changed due to a change in the data, combined with an error in the program logic.

 

what's the entire logic on the page?

 

and for your 'This page has been accessed in error.' condition, shouldn't you prevent execution of the remainder of the code on the page so that you don't produce follow on errors?


<?php session_start(); ?>
<!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="shortcut icon" type="image/x-icon" href="http://tournament.davidfattore.com/assets/icons/icon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Profile | Briscola Tournaments 2013</title>
<link rel="stylesheet" href="../css/main.css" type="text/css">
<link rel="stylesheet" href="../css/profile.css" type="text/css">
<script type="text/javascript">
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
</script>
<style>
#content_profile {
position: absolute;
width: 100%;
height: 1306px;
z-index: 2;
background-image: url(../assets/background_profile.jpg);
background-position:center;
}
#playerAvatar {
position: absolute;
width: 166px;
height: 222px;
z-index: 12;
left: 2px;
top: 2px;
}
#profile_header_badgeinfo {
position: absolute;
width: 268px;
height: 201px;
z-index: 2;
left: 679px;
top: 0px;
}
#profile_header_summary {
position: absolute;
width: 479px;
height: 201px;
z-index: 3;
left: 184px;
top: 2px;
}
#profile_header_username {
position: absolute;
width: 480px;
height: 50px;
z-index: 1;
font-family: Nyala;
font-size: 36px;
}
#profile_header_realname {
position: absolute;
width: 472px;
height: 43px;
z-index: 2;
left: 4px;
top: 54px;
font-family: Tahoma;
}
#profile_header_blurb {
position: absolute;
width: 473px;
height: 97px;
z-index: 3;
left: 4px;
top: 104px;
font-family: Tahoma;
}
#phpContent {
position: absolute;
width: 177px;
height: 21px;
z-index: 4;
left: 3px;
top: 178px;
}
#profile_header_level {
position: absolute;
width: 269px;
height: 46px;
z-index: 1;
font-family: Tahoma;
font-size: 24px;
left: 3px;
}
#profile_header_favBadge {
position: absolute;
width: 262px;
height: 102px;
z-index: 2;
left: 4px;
top: 66px;
background-image: url(../assets/players/favBadge.png);
}
#btnEditProfile {
position: absolute;
width: 200px;
height: 38px;
z-index: 3;
left: 4px;
top: 174px;
}
#profile_colomn_left {
position: absolute;
width: 672px;
height: 825px;
z-index: 1;
top: 5px;
left: 6px;
font-family: Tahoma;
font-size: 24px;
color: #CCC;
}
#profile_colomn_right {
position: absolute;
width: 249px;
height: 825px;
z-index: 2;
left: 683px;
top: 5px;
font-family: Tahoma;
font-size: 24px;
color: #CCC;
}
#badges_right {
position: absolute;
width: 250px;
height: 136px;
z-index: 1;
font-family: Tahoma;
}
#apDiv3 {
position: absolute;
width: 250px;
height: 295px;
z-index: 2;
top: 149px;
}
.profile_right_header_small {
font-size: 18px;
}
.playerLevel {
font-size: 20px;
color: #FFFFFF;
}
#featBadge {
position: absolute;
width: 86px;
height: 72px;
z-index: 1;
left: 9px;
top: 4px;
}
#featBadge_name {
position: absolute;
width: 153px;
height: 18px;
z-index: 2;
left: 95px;
top: 23px;
text-align: center;
font-family: Tahoma;
}
#featBadge_XP {
position: absolute;
width: 106px;
height: 20px;
z-index: 3;
left: 117px;
top: 48px;
text-align: center;
font-family: Tahoma;
}
.xp_text {
font-size: 12px;
font-family: Tahoma;
}
#innerContent_1 {
position: absolute;
width: 655px;
height: 223px;
z-index: 1;
background-image: url(../assets/players/innerContent_back.png);
left: 8px;
top: 5px;
}
#innerContent_1_header {
position: absolute;
width: 626px;
height: 45px;
z-index: 1;
left: 12px;
top: 12px;
font-family: Tahoma;
color: #4791c8;
}
.how_text {
font-size: 11px;
}
a:link {
color: #FFF;
}
a:visited {
color: #FFF;
}
a:hover {
color: #FFF;
}
a:active {
color: #FFF;
}
</style>
</head>

<body>
<div id="header">
<?php include ("../includes/header.php"); ?>
<?php include ("../menu.php"); ?>
</div>
<div id="logo">
<?php include ("../welcome.php"); ?>
<?php include ("../logo.php"); ?>
</div>
<div id="content_profile">
<div id="container_profile"><!-- BSA AdPacks code -->
<script src="http://code.jquery.com/jquery-1.6.3.min.js"></script>
<div id="profile_header">
<div id="profile_header_content">
<div id="phpContent">
<div align="center">
<?php
if((isset($_GET['id'])) && (is_numeric($_GET['id']))) { //accessed through viewusers.
$id = $_GET['id'];
} elseif ((isset($_POST['id'])) && (is_numeric($_POST['id']))) { //form has been subbed.
$id = $_POST['id'];
} else {
//print '<h2> Page Error </h2>';
//print '<p class=error> This page has been accessed in error. </p>';
}
?>
<?php
mysql_connect("localhost", "davidfat", "DsSkXq2n") or die(mysql_error());
mysql_select_db("davidfat_tournaments") or die(mysql_error());
// require ('mysql_connect.php');
//PROFILE QUERY
$query = "SELECT userID, username, password, first_name, last_name, email, gender, blurb, points, games_played, games_won, badges_earned, tournaments_won, dob_day, dob_month, dob_year, dp, badgeID, badges, unlocked, feat_badge, feat_badge_name, feat_badge_xp, level, administration, registration_date FROM users WHERE userID = $id";
$result = mysql_query($query) or die (mysql_error());
$row = mysql_fetch_array($result, MYSQL_NUM);
?>
</div>
</div>
<div id="profile_header_summary">
<div id="profile_header_username">
<?php
//USERNAME
print '"'. $row[1] .'"';
?>
</div>
<div id="profile_header_realname">
<?php print "" . $row[3] . " " . $row[4] .""; ?>
</div>
<div id="profile_header_blurb"><?php print '<i>'. $row[7] .'</i>'; ?></div>
</div>
<div id="playerAvatar"><div align="center">
<?php
//DISPLAY PICTURE
echo '<div class="style30" align="center"><img src="'. $row[16] .'"></img></div>';
?>
</div>
<div id="profile_header_badgeinfo">
<div id="profile_header_level">
<table width="269" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="83" height="41">LEVEL:</td>
<td width="42" align="center" background="../assets/players/levelCircle.png" class="playerLevel"><?php
print $row[23];
?></td>
<td width="144" align="left"><table width="139" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="98" align="right" class="how_text">How do I earn XP?</td>
<td width="27" align="right"><a href="#"><img src="../assets/help-icon.png" alt="" width="16" height="16" /></a></td>
</tr>
</table></td>
</tr>
<tr>
<td height="5" colspan="3"><img src="../assets/divider.png" width="266" height="5" alt="" /></td>
</tr>
<tr>
<td height="17" colspan="3" align="center" valign="bottom" class="xp_text">149 XP to Reach Level 11</td>
</tr>
</table>
</div>
<div id="profile_header_favBadge">
<div id="featBadge">
<div align="center">
<?php
print '<img src="' . $row[20] . '"></img>';
?>
</div></div>
<div id="featBadge_name">
<?php
print $row[21];
?>
</div>
<div id="featBadge_XP">
<?php
print $row[22];
?>
</div>
</div>
<div id="btnEditProfile"><a href="#"><img src="../assets/players/btnEditProfile.png" width="105" height="35" /></a></div>
</div>
</div>
</div>
<div id="profile_content">
<div id="profile_colomn_left">
<div id="innerContent_1">
<div id="innerContent_1_header">Recent Game Activity</div>
</div>
</div>
<div id="profile_colomn_right">
<div id="badges_right">Badges:
<?php
print $row[11];
?>
<br />
<hr width="99%" size="1" />
<?php
print $row[18];
?></div>
<div id="apDiv3">
<table width="250" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="169" height="37" class="profile_right_header_small">Games Played:</td>
<td width="67" class="profile_right_header_small"><?php
print $row[9];
?></td>
</tr>
<tr>
<td height="34" class="profile_right_header_small">Games Won:</td>
<td class="profile_right_header_small"><?php
print $row[10];
?></td>
</tr>
<tr>
<td height="35" class="profile_right_header_small">Series Won:</td>
<td class="profile_right_header_small"><?php
print $row[12];
?></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<p> </p>
</div>
</div>
<?php include("../footer.php"); ?>
</div>
</body>
</html>

Try changing index.php to

<?php
session_start();

mysql_connect("localhost", "davidfat", "DsSkXq2n") or die(mysql_error());
mysql_select_db("davidfat_tournaments") or die(mysql_error());


if((isset($_GET['id'])) && (is_numeric($_GET['id']))) { //accessed through viewusers.
    $id = $_GET['id'];
} elseif ((isset($_POST['id'])) && (is_numeric($_POST['id']))) { //form has been subbed.
    $id = $_POST['id'];
}

if(isset($id))
{
    $query = "SELECT userID, username, password, first_name, last_name, email, gender, blurb, points, games_played, games_won, badges_earned, tournaments_won,  dob_day, dob_month, dob_year, dp, badgeID, badges, unlocked, feat_badge, feat_badge_name, feat_badge_xp, level, administration, registration_date FROM users WHERE userID = $id";
    $result = mysql_query($query) or die (mysql_error());
    $row = mysql_fetch_array($result, MYSQL_NUM);
}
else
{
    print "<h2> Page Error </h2>
           <p class=error> This page has been accessed in error. </p>";
    exit;
}

?>
<!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="shortcut icon" type="image/x-icon" href="http://tournament.davidfattore.com/assets/icons/icon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Profile | Briscola Tournaments 2013</title>
<link rel="stylesheet" href="../css/main.css" type="text/css">
<link rel="stylesheet" href="../css/profile.css" type="text/css">
<script type="text/javascript">
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
</script>
<style> 
#content_profile {
    position: absolute;
    width: 100%;
    height: 1306px;
    z-index: 2;
    background-image: url(../assets/background_profile.jpg);
    background-position:center;
}
#playerAvatar {
    position: absolute;
    width: 166px;
    height: 222px;
    z-index: 12;
    left: 2px;
    top: 2px;
}
#profile_header_badgeinfo {
    position: absolute;
    width: 268px;
    height: 201px;
    z-index: 2;
    left: 679px;
    top: 0px;
}
#profile_header_summary {
    position: absolute;
    width: 479px;
    height: 201px;
    z-index: 3;
    left: 184px;
    top: 2px;
}
#profile_header_username {
    position: absolute;
    width: 480px;
    height: 50px;
    z-index: 1;
    font-family: Nyala;
    font-size: 36px;
}
#profile_header_realname {
    position: absolute;
    width: 472px;
    height: 43px;
    z-index: 2;
    left: 4px;
    top: 54px;
    font-family: Tahoma;
}
#profile_header_blurb {
    position: absolute;
    width: 473px;
    height: 97px;
    z-index: 3;
    left: 4px;
    top: 104px;
    font-family: Tahoma;
}
#phpContent {
    position: absolute;
    width: 177px;
    height: 21px;
    z-index: 4;
    left: 3px;
    top: 178px;
}
#profile_header_level {
    position: absolute;
    width: 269px;
    height: 46px;
    z-index: 1;
    font-family: Tahoma;
    font-size: 24px;
    left: 3px;
}
#profile_header_favBadge {
    position: absolute;
    width: 262px;
    height: 102px;
    z-index: 2;
    left: 4px;
    top: 66px;
    background-image: url(../assets/players/favBadge.png);
}
#btnEditProfile {
    position: absolute;
    width: 200px;
    height: 38px;
    z-index: 3;
    left: 4px;
    top: 174px;
}
#profile_colomn_left {
    position: absolute;
    width: 672px;
    height: 825px;
    z-index: 1;
    top: 5px;
    left: 6px;
    font-family: Tahoma;
    font-size: 24px;
    color: #CCC;
}
#profile_colomn_right {
    position: absolute;
    width: 249px;
    height: 825px;
    z-index: 2;
    left: 683px;
    top: 5px;
    font-family: Tahoma;
    font-size: 24px;
    color: #CCC;
}
#badges_right {
    position: absolute;
    width: 250px;
    height: 136px;
    z-index: 1;
    font-family: Tahoma;
}
#apDiv3 {
    position: absolute;
    width: 250px;
    height: 295px;
    z-index: 2;
    top: 149px;
}
.profile_right_header_small {
    font-size: 18px;
}
.playerLevel {
    font-size: 20px;
    color: #FFFFFF;
}
#featBadge {
    position: absolute;
    width: 86px;
    height: 72px;
    z-index: 1;
    left: 9px;
    top: 4px;
}
#featBadge_name {
    position: absolute;
    width: 153px;
    height: 18px;
    z-index: 2;
    left: 95px;
    top: 23px;
    text-align: center;
    font-family: Tahoma;
}
#featBadge_XP {
    position: absolute;
    width: 106px;
    height: 20px;
    z-index: 3;
    left: 117px;
    top: 48px;
    text-align: center;
    font-family: Tahoma;
}
.xp_text {
    font-size: 12px;
    font-family: Tahoma;
}
#innerContent_1 {
    position: absolute;
    width: 655px;
    height: 223px;
    z-index: 1;
    background-image: url(../assets/players/innerContent_back.png);
    left: 8px;
    top: 5px;
}
#innerContent_1_header {
    position: absolute;
    width: 626px;
    height: 45px;
    z-index: 1;
    left: 12px;
    top: 12px;
    font-family: Tahoma;
    color: #4791c8;
}
.how_text {
    font-size: 11px;
}
a:link {
    color: #FFF;
}
a:visited {
    color: #FFF;
}
a:hover {
    color: #FFF;
}
a:active {
    color: #FFF;
}
</style>
</head>

<body>
<div id="header">
  <?php include ("../includes/header.php"); ?>
  <?php include ("../menu.php"); ?>
</div>
<div id="logo">
  <?php include ("../welcome.php"); ?>
  <?php include ("../logo.php"); ?>
</div>
<div id="content_profile">
  <div id="container_profile"><!-- BSA AdPacks code -->
<script src="http://code.jquery.com/jquery-1.6.3.min.js"></script>
  <div id="profile_header">
    <div id="profile_header_content">
      <div id="profile_header_summary">
        <div id="profile_header_username">
          <?php
          //USERNAME
          print '"'. $row[1] .'"';
          ?>
        </div>
        <div id="profile_header_realname">
          <?php print "" . $row[3] . " " . $row[4] .""; ?>
        </div>
        <div id="profile_header_blurb"><?php print '<i>'. $row[7] .'</i>'; ?></div>
      </div>
      <div id="playerAvatar"><div align="center">
        <?php
          //DISPLAY PICTURE
          echo '<div class="style30" align="center"><img src="'. $row[16] .'"></img></div>';
          ?>
      </div>
      <div id="profile_header_badgeinfo">
        <div id="profile_header_level">
          <table width="269" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="83" height="41">LEVEL:</td>
              <td width="42" align="center" background="../assets/players/levelCircle.png" class="playerLevel"><?php
          print $row[23];
          ?></td>
              <td width="144" align="left"><table width="139" border="0" cellspacing="2" cellpadding="2">
                <tr>
                  <td width="98" align="right" class="how_text">How do I earn XP?</td>
                  <td width="27" align="right"><a href="#"><img src="../assets/help-icon.png" alt="" width="16" height="16" /></a></td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td height="5" colspan="3"><img src="../assets/divider.png" width="266" height="5" alt="" /></td>
              </tr>
            <tr>
              <td height="17" colspan="3" align="center" valign="bottom" class="xp_text">149 XP to Reach Level 11</td>
            </tr>
          </table>
        </div>
        <div id="profile_header_favBadge">
          <div id="featBadge">
            <div align="center">
              <?php
          print '<img src="' . $row[20] . '"></img>';
          ?>
            </div></div>
          <div id="featBadge_name">
            <?php
          print $row[21];
          ?>
          </div>
          <div id="featBadge_XP">
            <?php
          print $row[22];
          ?>
          </div>
        </div>
        <div id="btnEditProfile"><a href="#"><img src="../assets/players/btnEditProfile.png" width="105" height="35" /></a></div>
      </div>
    </div>
  </div>
  <div id="profile_content">
    <div id="profile_colomn_left">
      <div id="innerContent_1">
        <div id="innerContent_1_header">Recent Game Activity</div>
      </div>
    </div>
    <div id="profile_colomn_right">
      <div id="badges_right">Badges: 
        <?php
          print $row[11];
          ?>
        <br />
        <hr width="99%" size="1" />
        <?php
          print $row[18];
          ?></div>
      <div id="apDiv3">
        <table width="250" border="0" cellspacing="2" cellpadding="2">
          <tr>
            <td width="169" height="37" class="profile_right_header_small">Games Played:</td>
            <td width="67" class="profile_right_header_small"><?php
          print $row[9];
          ?></td>
          </tr>
          <tr>
            <td height="34" class="profile_right_header_small">Games Won:</td>
            <td class="profile_right_header_small"><?php
          print $row[10];
          ?></td>
          </tr>
          <tr>
            <td height="35" class="profile_right_header_small">Series Won:</td>
            <td class="profile_right_header_small"><?php
          print $row[12];
          ?></td>
          </tr>
        </table>
      </div>
    </div>
  </div>
  </div>
      <p> </p>
  </div>
  </div>
  <?php include("../footer.php"); ?>
</div>
</body>
</html>

I do not know what else to suggest.

 

As I have said something somewhere is causing the query string to be ignored. So when you go to players/?id=1 or even players/index.php?id=1 the $_GET['id'] variable is not being set, because that is not set then the $id variable is not set. Which is why you are getting the page error.

Ok well I've reset everything to it's initial coding and now it still gives me the the Page Error but it also gives me this:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
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.