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
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]
Link to comment
Share on other sites

@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?
Link to comment
Share on other sites

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.