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
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.

Link to comment
Share on other sites

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");

 

 

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.