Mutley Posted August 11, 2006 Share Posted August 11, 2006 I don't under stand this, when I goto the page and do a "?team_id=1" at the end of the URL I get this error:Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/nsnitro2/public_html/yorkrufc/site/teams/teams.php on line 15Here is the code...[code=php:0]<table border="1" cellpadding="0" cellspacing="2"><?require_once("connection.php");$id = $_GET['team_id'];if($id) { $sql = "SELECT name, surname "; $sql .= "FROM teams "; $sql .= "WHERE team_id=".$id." "; $result = mysql_query($sql); if(mysql_num_rows($result)!=0) { while(list($name, $surname) = mysql_fetch_row($result)) { ?><tr> <td> <?=$name?> <?=$surname?> </td></tr> <? } }}else { echo "Please specify a Team ID";}?></table>[/code]...Any help would be much appreciated on this error. Thank-you. Link to comment https://forums.phpfreaks.com/topic/17245-warning-mysql_num_rows-supplied-argument-is-not/ Share on other sites More sharing options...
shocker-z Posted August 11, 2006 Share Posted August 11, 2006 we need to find out what error MySQL is having so change$result = mysql_query($sql);to$result = mysql_query($sql) or die(mysql_error().' ERROR using SQL line'. $sql);RegardsLiam Link to comment https://forums.phpfreaks.com/topic/17245-warning-mysql_num_rows-supplied-argument-is-not/#findComment-73090 Share on other sites More sharing options...
Nimwei Posted August 11, 2006 Share Posted August 11, 2006 $sql .= "WHERE team_id=".$id." ";Is there a need for an extra space on that?$sql .= "WHERE team_id=".$id;shoudl work. Link to comment https://forums.phpfreaks.com/topic/17245-warning-mysql_num_rows-supplied-argument-is-not/#findComment-73092 Share on other sites More sharing options...
Mutley Posted August 11, 2006 Author Share Posted August 11, 2006 Fixed it, the ?id= part on the URL had to be a number, not a word/letters.However, I have a question with a similar subject.I want to include files with an ?id= how do I make the file include all of that number for example:[code]include('teams/teams.php?id=$id')include('scores/get_scores.php?id=$id')[/code]would include teams.php?id=1, if 1 was in the ?id=1 of the url?Can I just do:[code]$id = $_GET['id'];if($id) {[/code]Again? Not sure how to work it. Link to comment https://forums.phpfreaks.com/topic/17245-warning-mysql_num_rows-supplied-argument-is-not/#findComment-73100 Share on other sites More sharing options...
hostfreak Posted August 11, 2006 Share Posted August 11, 2006 How about:[code]$id = $_GET['id'];if(id == '$id') {//code} else {Sorry but you are not authorized to view this team}[/code] Link to comment https://forums.phpfreaks.com/topic/17245-warning-mysql_num_rows-supplied-argument-is-not/#findComment-73103 Share on other sites More sharing options...
shocker-z Posted August 11, 2006 Share Posted August 11, 2006 From how you explained it then yes that should work but you can't include it as a local file! else it looks for a file with the name 'teams.php?id=1' for example instead of passing it thru the url.. so you would have to use include("http://www.mydomain.com/includes/teams/teams.php?id=$id");for it to work sucesfulyLiam Link to comment https://forums.phpfreaks.com/topic/17245-warning-mysql_num_rows-supplied-argument-is-not/#findComment-73104 Share on other sites More sharing options...
Mutley Posted August 11, 2006 Author Share Posted August 11, 2006 [quote author=hostfreak link=topic=103863.msg413901#msg413901 date=1155306602]How about:[code]$id = $_GET['id'];if(id == '$id') {//code} else {Sorry but you are not authorized to view this team}[/code][/quote]Yep, close, I did this:[code]$id = $_GET['id'];if($id == '$id') {include "teams/teams.php?id=".$id."";include "scores/scores.php?id=".$id."";include "profiles/get_profile?id=".$id."";}else { echo'Please select a team below:'; }[/code]But it doesn't "find" the files to include using the ID, it just goes straight to the echo. Link to comment https://forums.phpfreaks.com/topic/17245-warning-mysql_num_rows-supplied-argument-is-not/#findComment-73106 Share on other sites More sharing options...
Mutley Posted August 11, 2006 Author Share Posted August 11, 2006 [quote author=shocker-z link=topic=103863.msg413902#msg413902 date=1155306730]From how you explained it then yes that should work but you can't include it as a local file! else it looks for a file with the name 'teams.php?id=1' for example instead of passing it thru the url.. so you would have to use include("http://www.mydomain.com/includes/teams/teams.php?id=$id");for it to work sucesfulyLiam[/quote]It works that way, thank-you but if anyone knows away with out the root domain path http://www.mysite.... etc, please let me know by reply. :) Link to comment https://forums.phpfreaks.com/topic/17245-warning-mysql_num_rows-supplied-argument-is-not/#findComment-73121 Share on other sites More sharing options...
hostfreak Posted August 11, 2006 Share Posted August 11, 2006 Why not just:[code]include("includes/teams/teams.php?id=$id");[/code] Link to comment https://forums.phpfreaks.com/topic/17245-warning-mysql_num_rows-supplied-argument-is-not/#findComment-73123 Share on other sites More sharing options...
shocker-z Posted August 11, 2006 Share Posted August 11, 2006 you cant because it looks for the file called 'includes/teams/teams.php?id=$id' therefore not going through the server just simply including a file.. So you have to run it through your server e.g. how i showed with the address.. can't think of any other way for it to be done using include.. Link to comment https://forums.phpfreaks.com/topic/17245-warning-mysql_num_rows-supplied-argument-is-not/#findComment-73128 Share on other sites More sharing options...
tox_yray Posted August 11, 2006 Share Posted August 11, 2006 In this case, just do that:[code]$id = (value you want);include(whatever relative path you want WITHOUT url variables);[/code]include(); will just make a big php page with ALL the code before interpreting it, so $id or the "parent" will be recognized by included pages.As easy as that. Link to comment https://forums.phpfreaks.com/topic/17245-warning-mysql_num_rows-supplied-argument-is-not/#findComment-73131 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.