Jump to content

Archived

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

sno

help with something like match.php?id=1

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??

Share this post


Link to post
Share on other sites
$global[pre]_results???

Thats the table name, stick it in a var
If your trying to get to global version for it
global $pre

and use $_GET["id"];
to get the ID from the address bar

Share this post


Link to post
Share on other sites
put this on top

$id = $_GET['id'];

Ray

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
wildteen88, i tryied yours out and even when i put a number in it gives the invalud URL parameter part...
i got the [code]$id = $_GET['id'];[/code]in for now

Share this post


Link to post
Share on other sites
if ur using $_GET
the format is string, not int
even if the string contains 56
It is a string
"56" is different to 56

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

×

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.