Jump to content


Photo

help with something like match.php?id=1


  • Please log in to reply
7 replies to this topic

#1 sno

sno
  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 18 August 2006 - 02:59 PM

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.


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

is there a obvious reason as to why it isnt working??

#2 cmgmyr

cmgmyr
  • Members
  • PipPipPip
  • Advanced Member
  • 1,278 posts
  • LocationUSA

Posted 18 August 2006 - 03:03 PM

try global $id; at the top.

#3 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 18 August 2006 - 03:32 PM

$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
Tell me the problem, I will try tell you the solution

#4 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 18 August 2006 - 03:40 PM

put this on top

$id = $_GET['id'];

Ray

#5 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 18 August 2006 - 04:42 PM

I'd suggest you use this instead:
// 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');
}
Add that before
$query = "SELECT * FROM $global[pre]_results WHERE match_id='$id'";


#6 sno

sno
  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 19 August 2006 - 05:30 PM

wildteen88, i tryied yours out and even when i put a number in it gives the invalud URL parameter part...
i got the
$id = $_GET['id'];
in for now

#7 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 19 August 2006 - 05:33 PM

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
Tell me the problem, I will try tell you the solution

#8 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 19 August 2006 - 06:50 PM

@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:
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 />';
}

What do you get now?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users