Mutley Posted September 18, 2006 Share Posted September 18, 2006 When I do this:<?php include("find.php?team=".$team."&subject=".$subject.""); ?>I get this error:Warning: main(find.php?team=1&subject=2006) [function.main]: failed to open stream: No such file or directory inHowever if I goto the file with my browser address, like www.mysite.com/find.php?team=1&subject=2 ...it works? Anyone know why? Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/ Share on other sites More sharing options...
AndyB Posted September 18, 2006 Share Posted September 18, 2006 You don't have a file that's [b]named[/b] find.php?team=1&subject=2000 so it can't be included. With that in the browser address bar, you're finding find.php which then processes the information in the query string. Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94046 Share on other sites More sharing options...
Daniel0 Posted September 18, 2006 Share Posted September 18, 2006 Yeah, it's because you try to include a file on the filesystem that is actually called "find.php?team=1&subject=2000", but there is not a file called that. When you type the url you tell the server to load "find.php", which exists, then the rest is parsed as GET variables.If you want the output of of what you include, then just do this: [code]<?php echo file_get_contents("http://www.mysite.com/find.php?team={$team}&subject={$subject}"); ?>[/code] or if you want to include the file, but have some variables set, then just set the variables before and then include find.php Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94048 Share on other sites More sharing options...
Mutley Posted September 18, 2006 Author Share Posted September 18, 2006 How can I do this then? Any fix of some sort?I need it to include a file with the variables in the URL. Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94050 Share on other sites More sharing options...
AndyB Posted September 18, 2006 Share Posted September 18, 2006 [quote author=Mutley link=topic=108510.msg436610#msg436610 date=1158597409]How can I do this then? Any fix of some sort?I need it to include a file with the variables in the URL.[/quote]No, you need something that works. That might be a [i]partial copy[/i] of find.php that accepts variable already declared, e.g.[code]<?php$team = 1;$subject = 2000;include("the_working_part_of_find.php");[/code] Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94054 Share on other sites More sharing options...
Mutley Posted September 18, 2006 Author Share Posted September 18, 2006 Thanks alot! I've got that to work now but I have a similar problem here in a FUNCTION:[code]{echo "<a href=\"http://www.mysite.com/galleryfind.php?team=$team&subject=2006&game={$item}\"\n>{$item}</a> <br />";}[/code]As you can see, {$item} is some variable and also $team but obviously this doesn't work, I just get a same error as before when I goto that page but I don't know how to get {$item} to work.I tried this:[code]{?><a href="http://www.mysite.com/galleryfind.php?team=<?=$team?>&subject=2006&game=<?={$item}?>"><?={$item}?></a> <br /><?php}[/code]But can't seem to get it to work at all. :( Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94061 Share on other sites More sharing options...
Orio Posted September 18, 2006 Share Posted September 18, 2006 Try:[code]<?phpecho "<a href=\"http://www.mysite.com/galleryfind.php?team=".urlencode($team)."&subject=2006&game=".urlencode($item)."\">".$item."</a><br />";?>[/code]Orio. Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94072 Share on other sites More sharing options...
Mutley Posted September 18, 2006 Author Share Posted September 18, 2006 Yep, sorted that. Now finally, one more problem. This doesn't make sense:[code]$team = $_GET['team'];$game = $_GET['game'];echo $team;echo $game;[/code]For some reason, if I do ?team=1&game=test ...it doesn't show the game? Why? It just doesn't seem to recognise it, so I can't use it when doing URLs further down:$thumbnail_folder = "./gallery/images/".urlencode($team)."/2006/".urlencode($game)."/thumbs";It just loads as gallery/images/1/2006//thumbs ???Thanks alot Orio. Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94118 Share on other sites More sharing options...
Orio Posted September 18, 2006 Share Posted September 18, 2006 Use urlencode when you are making urls with get variables.But that's a bit weird...Try:$thumbnail_folder = "./gallery/images/".stripslashes($team)."/2006/".stripslashes($game)."/thumbs";Orio. Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94128 Share on other sites More sharing options...
Mutley Posted September 18, 2006 Author Share Posted September 18, 2006 Nope, won't work, it won't find the "game" variable, if I echo it nothing appears. Heres the whole file:[code]<table align="center" cellpadding="5"><?$build = false;if(isset($HTTP_GET_VARS["b"]) || isset($HTTP_GET_VARS["build"])) $build = true;$image = ""; if(isset($HTTP_GET_VARS["image"])) $image = $HTTP_GET_VARS["image"];$team = $_GET['team'];$game = $_GET['game'];//$match = $_GET['match'];//echo $match;echo $team;echo $game;$thumbnail_folder = "./gallery/images/".stripslashes($team)."/2006/".stripslashes($game)."/thumbs";$thumbnail_width = 160; $thumbnail_height = 120;$image_folder = "./gallery/images/".stripslashes($team)."/2006/".stripslashes($game)."";$image_width = 640; $image_height = 480;$source_folder = "./gallery/images/".stripslashes($team)."/2006/".stripslashes($game)."";//The number of thumbs in a row,//followed by the number of rows in a page.$row_size = 3; $page_size = 5;$row = $HTTP_GET_VARS["row"];if($row == "") $row = 0;if(is_dir($thumbnail_folder) == false) mkdir($thumbnail_folder, 0755); if(is_dir($image_folder) == false) mkdir($image_folder, 0755); if(is_dir($source_folder) == false) mkdir($source_folder, 0755);if($build == true) { //Get an array of all the jpg files in the current source directory. $source_files = glob($source_folder . "/*.JPG"); for($index = 0; $index < count($source_files); $index++) { $original_jpg = imagecreatefromjpeg($source_files[$index]); $original_size = getimagesize($source_files[$index]); $original_width = $original_size[0]; $original_height = $original_size[1]; $source_file_name = substr($source_files[$index], strrpos($source_files[$index], "/") + 1); $thumbnail_jpg = imagecreatetruecolor($thumbnail_width, $thumbnail_height); imagecopyresized($thumbnail_jpg, $original_jpg, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $original_width, $original_height); imagejpeg($thumbnail_jpg, $thumbnail_folder . "/" . $source_file_name); imagedestroy($thumbnail_jpg); $image_jpg = imagecreatetruecolor($image_width, $image_height); imagecopyresized($image_jpg, $original_jpg, 0, 0, 0, 0, $image_width, $image_height, $original_width, $original_height); imagejpeg($image_jpg, $image_folder . "/" . $source_file_name); imagedestroy($image_jpg); imagedestroy($original_jpeg); } }?><?//Get an array of all the jpg files in the current thumbnail directory.$thumbnail_files = glob($thumbnail_folder . "/*.JPG");$first_index = $row * $row_size;$last_index = $first_index + $page_size * $row_size;if($last_index > sizeof($thumbnail_files)) $last_index = sizeof($thumbnail_files);for($index = $first_index; $index < $last_index; $index++) {?><? if($index == $first_index) { ?><tr><? } ?><? if($index != 0 && $index % $row_size == 0 && $image == "") { ?></tr><tr><? } ?><?$image_file = substr($thumbnail_files[$index], strrpos($thumbnail_files[$index], "/") + 1);$image_url = "gallerytest.php?row=" . $row . "&image=" . $image_file;?><? if ($image == "") { ?><td><a onclick="window.open(this.href, 'popupwindow', 'width=700,height=600,scrollbars,resizable'); return false;" href="<?= $image_url ?>"><img src="<?= $thumbnail_files[$index] ?>" border="3" style="border-color:aa5500;" /></a></td><? } ?><?$next_index = $index + 1;if($next_index >= $last_index) $next_index = $first_index;$next_image_file = substr($thumbnail_files[$next_index], strrpos($thumbnail_files[$next_index], "/") + 1);?><!--^ Get Next Image ^--><? if($image == $image_file) { ?><td colspan="2"><a href="gallerytest.php?row=<?= $row ?>&image=<?= $next_image_file ?>"><img src="<?= $image_folder . "/" . $image_file ?>" border="3" style="border-color:aa5500;" /></a><br /><center><a href="javascript:window.close();">Click here to close this Window</a></center></td></tr><!--^ Image full size pop-up ^--><?$previous_index = $index - 1;if($previous_index < $first_index) $previous_index = $last_index - 1;$previous_image_file = substr($thumbnail_files[$previous_index], strrpos($thumbnail_files[$previous_index], "/") + 1);?><!--^ Get Previous Image ^--><tr><td><a href="gallerytest.php?row=<?= $row ?>&image=<?= $previous_image_file ?>"><b>Previous Image</b></a></td><td align="right"><a href="gallerytest.php?row=<?= $row ?>&image=<?= $next_image_file ?>"><b>Next Image</b></a></td><? } ?><? if($index == count($thumbnail_files) - 1) { ?></tr><? } ?><? } ?><? if($image == "") { ?><tr><td colspan="<?= $row_size ?>"><table cellspacing="0" cellpadding="0" width="100%"><tr><td><?$previous_row = $row - $page_size;$last_page_size = ceil(sizeof($thumbnail_files) / $row_size) % $page_size;if($last_page_size == 0) $last_page_size = $page_size;if($previous_row < 0) $previous_row = ceil(sizeof($thumbnail_files) / $row_size) - $last_page_size;?><a href="gallerytest.php?row=<?= $previous_row ?>">Previous Page</a></td><td align="right"><?$next_row = $row + $page_size;if($next_row >= ceil(sizeof($thumbnail_files) / $row_size)) $next_row = 0;?><a href="gallerytest.php?row=<?= $next_row ?>">Next Page</a></td></tr></table></td></tr><? } ?></table>[/code]If I goto ?team=1&game=testIt will load the team variable but not game. Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94133 Share on other sites More sharing options...
Orio Posted September 18, 2006 Share Posted September 18, 2006 Try changing $_GET['game'] with $HTTP_GET_VARS['game']$_GET is only supported from php4.1 or greater.(run phpversion() to know your php version)Orio. Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94135 Share on other sites More sharing options...
Mutley Posted September 18, 2006 Author Share Posted September 18, 2006 Same problem, $team works but the $game variable doesn't? ??? It makes no sense. Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94138 Share on other sites More sharing options...
Orio Posted September 18, 2006 Share Posted September 18, 2006 I have no idea...If game is a number it does work?If you switch the places so it'll become "?game=test&team=1" will game pass and team won't?Orio. Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94142 Share on other sites More sharing options...
Mutley Posted September 18, 2006 Author Share Posted September 18, 2006 Even if switched, the $game variable doesn't work, lol. It is confusing the hell out of me, can you try it? Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94143 Share on other sites More sharing options...
Orio Posted September 18, 2006 Share Posted September 18, 2006 This:[code]<?$build = false;if(isset($HTTP_GET_VARS["b"]) || isset($HTTP_GET_VARS["build"])) $build = true;$image = ""; if(isset($HTTP_GET_VARS["image"])) $image = $HTTP_GET_VARS["image"];$team = $_GET['team'];$game = $_GET['game'];//$match = $_GET['match'];//echo $match;echo $team."<br>";echo $game;?>[/code]Gives me the output as it should be... See for yourself:http://www.oriosriddle.com/test.php?team=1&game=test (EDIT- deleted test.php)Orio. Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94147 Share on other sites More sharing options...
Mutley Posted September 18, 2006 Author Share Posted September 18, 2006 Fixed it, damn that was annoying.I included it but forgot to carry the variable. So it couldn't find it. Thanks so much Orio. Means alot. Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94150 Share on other sites More sharing options...
Orio Posted September 18, 2006 Share Posted September 18, 2006 lolNo problem at all :)Orio. Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94151 Share on other sites More sharing options...
karthikeyan_coder Posted September 18, 2006 Share Posted September 18, 2006 hmm.. try to change the name "game" to "Kame" and check it for a while... just for debugging process... Quote Link to comment https://forums.phpfreaks.com/topic/21163-include-with-_get-variables-wont-find-file/#findComment-94154 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.