Jump to content

help with something like match.php?id=1


sno

Recommended Posts

im trying to get this page to show the users information relevent the user user id which is added on at the end.
the only thing i get is no mysql errors but just blank fields.

this is what i have.

[code]

<?
$query = "SELECT * FROM $global[pre]_results WHERE match_id='$id'";

$result = mysql_query ($query) or die (mysql_error());

while ($s = mysql_fetch_array($result)) {

$id=$s["match_id"];
$against=$s["against"];
$map=$s["map"];
$results1=$s["results1"];
$results2=$s["results2"];
$info=$s["info"];
}

echo("The stuff from mysql should show up here
[/code]

is there a obvious reason as to why it isnt working??
Link to comment
https://forums.phpfreaks.com/topic/17951-help-with-something-like-matchphpid1/
Share on other sites

I'd suggest you use this instead:
[code]// if you are expecting id to be a number. Check that its a number before using it!
if(isset($_GET['id']) && is_numeric($_GET['id']))
{
    $id = $_GET['id'];
}
// id is not a number or is not set so we kill the script.
else
{
    die('Invalid URL Parameter');
}[/code]
Add that before
[code]$query = "SELECT * FROM $global[pre]_results WHERE match_id='$id'";[/code]
@onlyican - That shouldnt matter with is_numeric. As it compares whether a variable is either a number or a number string.

@sno - change my code snippet provided above to this:
[code=php:0]if(isset($_GET['id']) && is_numeric($_GET['id']))
{
    $id = $_GET['id'];
}
// id is not a number or is not set so we kill the script.
else
{
    echo 'DEBUG INFO:<br />
<br />
id - ' . $_GET['id'] . '<br />
id is: ' . gettype($_GET['id']) . '<br /><br />';
}[/code]

What do you get now?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.