PHP Get Query Not Working?

Trying to pull data from a database and have it follow the link.

For example: game.php?GAME_ID={$row['GAME_ID']}

-----------------------------------------------------------------------------

Now the following doesn't work but if I replace it with GAME_ID=5 or something it works but I need it to be dynamic so it changes with the link's values.

$GAME_ID = $_GET['GAME_ID'];
$query = 'SELECT * FROM games WHERE GAME_ID=$GAME_ID';

How do I make the above work the problem is in the GAME_ID=$GAME_ID part any ideas on how to fix that so its dynamic and pulls the value from the link?
OMFG thanks!!!! Spent all day on it couldn't get it right ty php master:)
 
Variables are only filled into strings if you use double quotes.

$GAME_ID = $_GET['GAME_ID'];
$query = "SELECT * FROM games WHERE GAME_ID=$GAME_ID";
 
dont give the query inside single quotes (' '). always give it inside double quates (" "). Because signle quate display the string inside the quotes. but double quates displays the value of the string.

<?php

$x=20;

echo "$x"; //output 20

echo '"$x"';//output "$x"

echo '$x';//output $x

echo "'$x'";//output '20'

echo ""$x"";//output Syntax error or parser error

echo "\"$x\"";//output "20" use of escape sequence

?>
 
Back
Top