Jump to content

Seems like a simple problem, but frustrating nonetheless...


xenmaster

Recommended Posts

Hi all,

I'm new to Php, and I love it, despite my problem. I'm trying to add a script into a default Wordpress install on my local server. I'm basically trying to load a text file into a variable and then use it. When I load the page I get the following error:

Warning: file(page.txt) [function.file]: failed to open stream: No such file or directory in C:\xampp\htdocs\wp-content\themes\classic\index.php on line 11

Warning: join() [function.join]: Bad arguments. in C:\xampp\htdocs\wp-content\themes\classic\index.php on line 11


This is the beginning of the script:

<?php

$content_file = "page.txt";


And this is line 11:

$words = split(" ", join("", file($content_file)));


From what I've read, it seems the text file simply isn't in the correct location, or that I may have capitalised incorrectly, etc. However, I have tried every permutation of localhost address (e.g $content_file = "http://localhost/page.txt";) and drive location ($content_file = "C:\xampp\htdocs\page.txt";) and nothing seems to work. What am I missing?

Thanks in advance for your help.


Gavin.
Link to comment
Share on other sites

Hi,

Thanks for the quick reply.

I added the code so that it looks like this:

<?php

fopen('page.txt',r);

$content_file = "page.txt";



It results in this additional error:

Warning: fopen(page.txt) [function.fopen]: failed to open stream: No such file or directory in C:\xampp\htdocs\wp-content\themes\classic\index.php on line 6

Do I have to state the path to the file?

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