Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Failed to Open Stream Error

Status
Not open for further replies.

vb6novice

Programmer
Joined
Sep 23, 2002
Messages
288
Location
US
I am working on a blog page (blogview.php) which uses php to get a list of files and dates from a mySQL db and generates a table which lists the blog files and the dates they were created. The goal is that the user will click on the title of a blog and the innerhtml of a cell in another table on the page will change to include the html of the blog file. I'm trying to use js to accomplish the innerhtml change, but although the page looks correct when it opens, I get errors when the page loads, and nothing happens when I click on the blog to be displayed.

The html calling the function is:
Code:
<div onclick="change_content('bloghere','cwwblog1.txt')">

where 'bloghere' is the id of the table cell whose innerhtml is supposed to change and 'cwwblog1.txt' is the name of the file whose content will go in the cell.

The code for the js function is:
Code:
function change_content(id,blog_file) {
   if (document.getElementById || document.all) {
      var el = document.getElementById? document.getElementById(id): document.all[id];
      if (el && typeof el.innerHTML != "undefined") el.innerHTML = "<?php include(blog_file); ?>";
   }
}

When I call the page on the web, the error I get when I View Source says

<b>Warning</b>: main(blog_file): failed to open stream: No such file or directory in <b>/home/mydomain/public_html/blogview.php</b> on line <b>20</b><br />
<br />
<b>Warning</b>: main(): Failed opening 'blog_file' for inclusion (include_path='.:/usr/local/lib/php') in <b>/home/mydomain/public_html/blogview.php</b> on line <b>20</b><br />
";


It is true that the file I want to include as the innerhtml is NOT in the directory as the blogview.php directory because blogview.php isn't a driectory.

How do I get the js to correctly open and include the file?
Also, does my el.innerHTML = "<?php include(blog_file); ?>"; statement have correct syntax?

I'll appreciate any help.
 
You can't call a php function from a JavaScript action. The only way to successfully do this would be reloading the page.

Therefore, you'd have to store each of the blogs in a JavaScript array.

I suggest NOT doing this, because if you have 10 blogs each with 50 kb of text, your page will take a while to load.

Rather, I suggest maybe filling a JS array with, say, the first 150 characters of each blog (using PHP to do this) and then use your onclick to change the innerHTML of the cell, displaying just the first 150 characters.

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
cLFlaVa,

Thanks for the reply. I understand that I can't do what I'm trying to do (use JS to put a php function as innerhtml). I don't see, however, how loading 150 characters of a blog is going to help me. I want to display whatever amount of text is in the blog. If that happens to be 20kb worth of characters, then that's what needs to be in the cell.

Can you think of any other way to accomplish what I am trying to do?

How do other blog sites do it?

Thanks

 
My guess is that most blog sites use more than one page (or at least don't send all of the text in one page).

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakesperean sonnet.
 
vb6novice:

iframes.

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
Wow, I'm slow today...

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakesperean sonnet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top