Page 1 of 1

call index.php with variables

Posted: Tue May 18, 2010 3:19 pm
by markosjal
I have a need to call index.php with some variables from another file
Like index.php/?cat=18

I have tried an include and this did not work.


From what I understand I need a block variable


I am looking for some sample code if anyone knows how to do this

Re: call index.php with variables

Posted: Tue May 18, 2010 4:11 pm
by JakeJ
Actually, that would be index.php?cat=18. You have an extra slash in there.

Have you though about using sessions?

What happened when you tried to use an include?

Post some code and any error messages.

Re: call index.php with variables

Posted: Tue May 18, 2010 4:33 pm
by markosjal
I am using this almost exactly on another site
Except for the second line which on the other site needs no URL Variable. Because it does not work on this site I looked around on the web and found various references to this inability to pass url variables this way in an include.

Code: Select all

<?php include 'header.php' ; ?>
<?php include 'index.php?cat=4' ; ?>
<?php include 'footer.php' ; ?>

the error is that it can not open that file / stream

Re: call index.php with variables

Posted: Tue May 18, 2010 6:49 pm
by JakeJ
It sees ?cat=4 as part of the file name.

Check out this URL, it will probably work for you: http://inkgrass.lazymoon.org/2007/11/12 ... p-include/

Re: call index.php with variables

Posted: Sat May 22, 2010 11:54 pm
by markosjal
Yes that worked and thanks so much!

Re: call index.php with variables

Posted: Sun May 23, 2010 1:45 am
by JakeJ
I ask my fair share of questions on here, it's nice to be able to help out someone else.