...

View Full Version : include problem



sir pannels
02-10-2006, 03:09 PM
afternoon :)

problem with a include.. code as follows ...
It looks for a file called "directory_content.php?genre=$bygenre&letter=$byletter" ... it doesnt stop at the question mark, I have tried enclosing it in ' ' and also not at all but no luck..


<? include "directory_content.php?genre=$bygenre&letter=$byletter"; ?>

Anyone know why it does not end the file name before the question mark? It just says file not found message, as there is no file called directory_content.php?genre=$bygenre&letter=$byletter.. obviously diectory_content.php is there.

cheers :)
P

fci
02-10-2006, 03:14 PM
You should be doing something like this instead:

<?php

$_GET['genre'] = $bygenre;
$_GET['letter'] = $byletter;
include "directory_content.php";

?>

sir pannels
02-10-2006, 03:34 PM
Hi fci,

Thanks for your reply.
Yeah I guess the safe/proper way to be to get the variables like that, somtimes I'm terribly lazy :$ ... though that is not what is causing the problem here. For example, I have changed the include file to just "directory_content.php?" and it thinks the question mark is part of the file name, and cannot find that file as it is not there.

I have corrected the variable laziness now too. But yeh thats the problems, any thoughts?

strange one.

degsy
02-10-2006, 03:41 PM
It looks for a file called "directory_content.php?genre=$bygenre&letter=$byletter" ... it doesnt stop at the question mark,



Anyone know why it does not end the file name before the question mark?


I don't get it. Why would it stop at the question mark when there is a query string after it?

sir pannels
02-10-2006, 03:59 PM
it would not stop, though would usally only reconise the file name as the part before the question mark, same as a href .. file.php?stuff=whatever .. that would load file.php and put stuff=whatever after the filename.. usually.. what? lol

firepages
02-10-2006, 06:14 PM
the ? is only part of the query string in HTTP
when you `include 'file.php`' you are in fact doing

include '/your/document_root/file.php';
or
include '/your/include/path/file.php';

those are filepaths not urls so the ? is taken literally and PHP is looking for the non existant file 'file.php?'

Apache knows that the '?' is the start of the query string and parses it as such , so include http;//your_domain.com/file.php?g=a would work but the code would be parsed by apache before it gets to your script.

sir pannels
02-14-2006, 11:28 AM
Firepages .. you will like this ...

I could not get my head round it .. and reading what you wrote still did not make sense... I could have SWORN I had done this exact thing before.
And then it dawned on me... OF COURSE it would not be able to deal with the question mark.. its not HTTP...I have spent the last week working on IFRAMEs for a project I had ...
Man includes are so much simpler as they can pick the vars up from their parent page.. there is no need to question mark and query after the file name!

What was I thinking!! Haha, good times.

Cheers for your time everyone :)
A very ashamed, Sir P.

srinivasm2006
02-14-2006, 11:37 AM
hi,

use this code for the include file
include "hme.php?id=".$preid;

fci
02-14-2006, 02:33 PM
hi,

use this code for the include file
include "hme.php?id=".$preid;

I'd recommend reading the thread before replying next time.

sir pannels
02-14-2006, 02:55 PM
owned :$



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum