View Full Version : require error...

09-21-2008, 06:12 PM
I am having a problem with the php require function. With this piece of code:

require("../forms/upload_pictures.php?number=" . $_GET['upload']);
Now I get this error

Warning: require(../forms/upload_pictures.php?number=5) [function.require]: failed to open stream: No error in C:\wamp\www\getaband.net\phpbin\edit_pictures_musician.php on line 23

Fatal error: require() [function.require]: Failed opening required '../forms/upload_pictures.php?number=5' (include_path='.;C:\php5\pear') in C:\wamp\www\getaband.net\phpbin\edit_pictures_musician.php on line 23

I have checked the link and it is the page I'm trying to reach because when I take the get variable part out ?number=" . $_GET['upload'] then it loads the page...

If someone could help me through this that would be great, thanks!

09-21-2008, 09:51 PM
When you require or include a local file, it's imported into the current script as if it had been copied and pasted. You can't send a GET variable, since it isn't accessed via HTTP. Instead, you can pass it as a variable, or modify the $_GET array so that the included page will see the modified version.

09-21-2008, 10:46 PM
I don't think I understand but I'll speak what I thought you said...

So instead of using $_Get['number']; Use $number?

Is that right?

09-21-2008, 11:44 PM
That'll do, yes. The included page has access to all global variables in the including page.

09-22-2008, 12:04 AM
Actually, it shouldn't matter. The GET variable is global on the first page, and will also be global on the second. So, you're fine-- just include/require the page as you normally would and do NOT at the ?.... part.

09-22-2008, 12:25 AM
now i'm confused...
So instead of doing this:

require("cantrememberurl.php?number=" . $_GET['number']);
I should do this

And have $url be:

cantrememberurl.php?number=" . $_GET['number']
Otherwise I have not a clue