Jump to content

'Include' with more complicated links!


cjosephson

Recommended Posts

Hey all,

 

I'm looking to include a page with variables in the link, e.g. search.php?id=test&name=fun, etc.

 

The include function works for me if I have just the page (search.php), but not with the other variables.

 

A little background on what I'm trying to do. I have a main page with a search that has lots of options. It was getting really bulky to do all the coding on the same page, so I am trying  pass the variables from the form into a separate search page, where a search is performed and return the results.

 

I looked at some tutorials, and nothing is really mentioned about what I'm trying to do. Is it possible?

 

If not, does anyone have any suggestions for alternatives?

Link to comment
https://forums.phpfreaks.com/topic/91964-include-with-more-complicated-links/
Share on other sites

The simplest approuch would be to use....

 

<?php

  $id = 'foo';
  include 'search.php';

?.

 

This would make $id available within search.php

 

If not, does anyone have any suggestions for alternatives?

 

I would suggest wrapping your search functionality within a class and calling it as required.

Thanks for your reply.

 

I made a simple testing class, which takes one argument, and echoes it back. I made a new page to see if it worked, and it did.

 

When I try and require it in the page I need it in, though, it doesn't work!

 

Why would it work fine in one page, but not in another? (barring typos...)

 

here's what I typed, and put in the third line of the page:

 

require("Search2.php");

 

 

When learning php, developing php code, or debugging php code, turn on full php error reporting in php.ini, a .htaccess file, or a local php.ini file to get php to help you (otherwise you are just flying blind.) Turning on full php error reporting in your script will not help with fatal parse errors because the code never runs and error reporting won't ever get turned on.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.