Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8526563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:18:26+00:00 2026-06-11T08:18:26+00:00

I seem to have some problem with my code here. It creates a file

  • 0

I seem to have some problem with my code here. It creates a file from the php file, but I get an error on the include path.

include('../include/config.php');

$name = ($_GET['createname']) ? $_GET['createname'] : $_POST['createname'];

function buildhtml($strphpfile, $strhtmlfile) {
ob_start();
include($strphpfile);
$data = ob_get_contents();
$fp = fopen ($strhtmlfile, "w");
fwrite($fp, $data);
fclose($fp);
ob_end_clean();
}

buildhtml('portfolio.php?name='.$name, "../gallery/".$name.".html");

The problem seems to be here:

'portfolio.php?name='.$name

Any way I can replace this, and still send the variable over?


Here’s the error I get when I put ?name after the php extension:

Warning: include(portfolio.php?name=hyundai) [function.include]: failed to open stream: No such file or directory in D:\Projects\Metro Web\Coding\admin\create.php on line 15

Warning: include(portfolio.php?name=hyundai) [function.include]: failed to open stream: No such file or directory in D:\Projects\Metro Web\Coding\admin\create.php on line 15

Warning: include() [function.include]: Failed opening 'portfolio.php?name=hyundai' for inclusion (include_path='.;C:\php\pear') in D:\Projects\Metro Web\Coding\admin\create.php on line 15
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:18:28+00:00Added an answer on June 11, 2026 at 8:18 am

    Now I saw your code in the comment to a previous answer I’d like to point few things out

    function buildhtml($strhtmlfile) {
        ob_start(); // redundant
        $fp = fopen ($strhtmlfile, "w"); // redundant
        file_put_contents($strhtmlfile,
                          file_get_contents("http://host/portfolio.php?name={$name}")); 
    //                                       where does $name come from?? ---^
        close($fp); // also redundant
        ob_end_clean(); // also redundant
    }
    buildhtml('../gallery/'.$name.'.html');
    

    In PHP as in many other languages you can do things in different ways. What you’ve done is you took three different ways and followed only one (which is absolutely enough). So when you use functions file_put_contents() and file_get_contents() you don’t need the buffer, that is the ob_ family of functions, because you never read anything in the buffer which you should then get with ob_get_contents(). Nor you need the file handles created and used by fopen(), fclose(), because you’ve never written to or read from the file handle i.e. with fwrite() or fread().

    If I’m guessing correctly that the purpose of your function is to copy html pages to local files, my proposal would be the following:

    function buildhtml($dest_path, $name) {
        file_put_contents($dest_path,
                      file_get_contents("http://host/portfolio.php?name={$name}"));
    }
    
    buildhtml('../gallery/'.$name.'.html', $name);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I seem to have a problem passing some strings on from one form to
I have some troubles while writing logs from log4net to the file. I seem
Okay I have seen some very similar questions here but none seem to be
I have some colors that seem to come from a Delphi TColor variable (e.g
i seem to have some problem in creating a structure defined as the topic.
i have some problems with a Query seem IN dosen't work with Group_concat, that
i seem to have some trouble installing autopy.h https://github.com/msanders/autopy/#introduction i already tried the installation
I have been looking for some time for this and I can't seem to
Here is some background to the problem. We are working with an EyeVis wall
I'm trying to add some functionality from a plugin I have made into a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.