sno Posted August 18, 2006 Share Posted August 18, 2006 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?? Quote Link to comment https://forums.phpfreaks.com/topic/17951-help-with-something-like-matchphpid1/ Share on other sites More sharing options...
cmgmyr Posted August 18, 2006 Share Posted August 18, 2006 try global $id; at the top. Quote Link to comment https://forums.phpfreaks.com/topic/17951-help-with-something-like-matchphpid1/#findComment-76779 Share on other sites More sharing options...
onlyican Posted August 18, 2006 Share Posted August 18, 2006 $global[pre]_results???Thats the table name, stick it in a varIf your trying to get to global version for itglobal $preand use $_GET["id"];to get the ID from the address bar Quote Link to comment https://forums.phpfreaks.com/topic/17951-help-with-something-like-matchphpid1/#findComment-76796 Share on other sites More sharing options...
craygo Posted August 18, 2006 Share Posted August 18, 2006 put this on top$id = $_GET['id'];Ray Quote Link to comment https://forums.phpfreaks.com/topic/17951-help-with-something-like-matchphpid1/#findComment-76801 Share on other sites More sharing options...
wildteen88 Posted August 18, 2006 Share Posted August 18, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/17951-help-with-something-like-matchphpid1/#findComment-76843 Share on other sites More sharing options...
sno Posted August 19, 2006 Author Share Posted August 19, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/17951-help-with-something-like-matchphpid1/#findComment-77293 Share on other sites More sharing options...
onlyican Posted August 19, 2006 Share Posted August 19, 2006 if ur using $_GETthe format is string, not inteven if the string contains 56It is a string"56" is different to 56 Quote Link to comment https://forums.phpfreaks.com/topic/17951-help-with-something-like-matchphpid1/#findComment-77294 Share on other sites More sharing options...
wildteen88 Posted August 19, 2006 Share Posted August 19, 2006 @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? Quote Link to comment https://forums.phpfreaks.com/topic/17951-help-with-something-like-matchphpid1/#findComment-77311 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.