PHP GET not grabbing ID [RESOLVED]

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

PHP GET not grabbing ID [RESOLVED]

Post by Epiales »

Why is it not grabbing the users ID on the attack.php?

Main page that displays the <a href> that leads to attack.php where it should GET the id passed on.

Code: Select all

<?php
$sql2 = mysql_query("SELECT username, family, strength, id FROM users ORDER BY strength DESC $limit"); 
$outputList = '';
while($row = mysql_fetch_array($sql2)){

    $get_user = "SELECT `username` FROM `users` WHERE `id`='".$row['id']."'";
    $user_query1 = mysqli_query($db_conx, $get_user);
    $numrows = mysqli_num_rows($user_query1);
    $rank_name = mysqli_fetch_assoc($user_query1);
 
    $id = $row['id'];
    $firstname = $row["username"];
    $family = $row["family"];
    $strength = $row["strength"];
    
    $outputList .= '<table border="0" bgcolor="590c02" width="99%"><td width="15%"><b><font color="white">' . $firstname . '</td><td align="left" width="15%"><b><font color="white">' . $family  . '</td><td><b><font color="white"><img src="images/strength.png">' .number_format($strength) . '</td><td width="15%"><a href="attack.php?id=".$row[id]."\"><img src="images/Handgun.png" width="30" height="30"></a> <img src="images/notification.png" width="30" height="30"> <img src="images/mail.png" width="30" height="30"></td><td width="5%"><img src="images/robber.png" width="20" height="20"></td></b></table>';
?>
My attack.php... Not much there as I want to just try and get it to pass the ID over first

Code: Select all

<?php include_once("php_includes/check_login_status.php")?>
<?php include_once("leftbar.php")?>
<?php include_once("rightbar.php");  ?>  
<?php include_once("includes/functions.php");  ?>  

<?php

$username = $_SESSION["username"];

// Select the member from the users table
$sql = "SELECT * FROM users WHERE username='$username' AND activated='1' LIMIT 1";
$user_query = mysqli_query($db_conx, $sql);
// Now make sure that user exists in the table
$numrows = mysqli_num_rows($user_query);
if($numrows < 1){
header("location: filenotfound.php");
    exit();
}
?>

<div id="pageMiddle">
<link href="style/style.css" rel="stylesheet" type="text/css" />

<?php

        $id = protect($_GET['id']);
    
$user_check = "SELECT * FROM `users` WHERE `id`='".$id."'";
$user_query = mysqli_query($db_conx, $user_check);
        
if(mysqli_num_rows($user_query) == 0){
            echo "There is no user with that ID!";
       }else{
       
       echo "works";
       }
?>
Thanks for any help/assistance :)
Last edited by Epiales on Wed Oct 08, 2014 9:41 pm, edited 1 time in total.
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
MikuzA
Posts: 395
Joined: Thu Aug 08, 2013 8:57 am

Re: PHP GET not grabbing ID

Post by MikuzA »

Code: Select all

<a href="attack.php?id=".$row[id]."\">
Should be

Code: Select all

<a href="attack.php?id='.$row[id].'\">
Why so serious?

Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: PHP GET not grabbing ID

Post by Epiales »

MikuzA wrote:

Code: Select all

<a href="attack.php?id=".$row[id]."\">
Should be

Code: Select all

<a href="attack.php?id='.$row[id].'\">
Thanks! I put the 's around the id and it works :) I knew I'd missed something somewhere grrr.
Nothing fancy, but a work in progress!

http://gameplaytoday.net
Post Reply

Return to “Beginner Help and Support”