1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need help: PHP include alternative

Discussion in 'PHP' started by _vlada_, May 24, 2008.

  1. #1
    Hello!

    I moved last night to another web host and they do not allow php include I used, like this:

    1 - my index.php was like this:

    <?PHP
      include ("http://www.sitename.com/product_list.php?affiliate_id=1");
    ?>
    Code (markup):
    2 - I had pages like: cheap-medicine.php where all code was like this:

    <?PHP
      include ("http://www.site.com/search.php?search=medicine&searchb=Search");
    ?>
    Code (markup):

    Can someone, please, help me to find alternative for those two problems?

    Thanks!
     
    _vlada_, May 24, 2008 IP
  2. julien_santini

    julien_santini Active Member

    Messages:
    184
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Hello,

    I'm not a php whiz yet, but here are the reasons that pop up to my mind:

    1) Passing an url into include() may return an error because what you actually want to include is a file (source code), that is include('search.php?etc ...)

    2) With respect to the above, I guess the $_GET variables won't get through as this method is more like a http protocol but what you want to refer to here is a file.

    3) Why not try to first define two variables $search and $searchb (containing the appropriate inputs) and *then* call the include('search.php') ?

    But then again im a php newbie so ...
     
    julien_santini, May 24, 2008 IP
    _vlada_ likes this.
  3. cbn81

    cbn81 Peon

    Messages:
    160
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What do you mean they don't allow php include? Can you use PHP?
     
    cbn81, May 24, 2008 IP
  4. _vlada_

    _vlada_ Peon

    Messages:
    743
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes, I can :) But php ini says

    allow_url_include Off Off

    I presume that is reason why I cant use "external" - http include.
     
    _vlada_, May 24, 2008 IP
  5. cbn81

    cbn81 Peon

    Messages:
    160
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I would follow the 3 suggestion from julien_santini
     
    cbn81, May 24, 2008 IP
    _vlada_ likes this.
  6. _vlada_

    _vlada_ Peon

    Messages:
    743
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I am complete newbie for php :(


    Anyway, rep adding for any constructive answer! :)
     
    _vlada_, May 24, 2008 IP
  7. _vlada_

    _vlada_ Peon

    Messages:
    743
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    0
    #7
    function get_content($url) {
    	$ch = curl_init();
    	curl_setopt ($ch, CURLOPT_URL, $url);
    	curl_setopt ($ch, CURLOPT_HEADER, 0);		
    	ob_start();
    	curl_exec ($ch);
    	curl_close ($ch);
    	$string = ob_get_contents();
    	ob_end_clean();  
    	return $string;   
    }
    			
    $content = get_content ("http://yoursite.com/wordpress/?page_id=3");
    echo ($content);
    Code (markup):
    WORKING! :)
     
    _vlada_, May 24, 2008 IP