» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > PHP Programming and Tips

PHP Programming and Tips Discuss about PHP programming and Share Tips. Ask questions about Scripting and Errors.

Reply
 
Thread Tools Display Modes
  #1  
Old 12-07-2005, 05:56 AM
johny johny is offline
OSP Starters
 
Join Date: Dec 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
johny is on a distinguished road
Default Errors with php script

Hi I am always getting these errors:::

Warning: file_get_contents(test): failed to open stream: No such file or directory in /home/prawgzn/public_html/m/remove.php on line 5

Warning: fopen(test): failed to open stream: Permission denied in /home/prawgzn/public_html/m/remove.php on line 9

Warning: fputs(): supplied argument is not a valid stream resource in /home/prawgzn/public_html/m/remove.php on line 10

Warning: fclose(): supplied argument is not a valid stream resource in /home/prawgzn/public_html/m/remove.php on line 11 with the code..

PHP Code:
<?php
$filename = 'test.txt';
$somecontent = $_GET['data'] . "\n";

$file_data = file_get_contents($filename);

$file_data = str_replace($somecontent, "", $file_data);

$file = fopen($filename, "w");
fputs($file, $file_data);
fclose($file); < -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 12-07-2005, 05:59 AM
maddy maddy is offline
OSP Starters
 
Join Date: Dec 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
maddy is on a distinguished road
Default Remedy for php script errors

All these errors are being caused by the 1st one.
if file_get_contents fails then fopen is going to fail then fputs will fail and then fclose will fail.. what you need to do is make some simple error handling methods. Error seems to be saying the file your trying to open doesnt exist.

Try Out This::
PHP Code:
if (isset($_GET['data'])) {
$filename = 'test.txt';
if (file_exsits($filename)) {

$file_data = file_get_contents($filename);
$file_data = str_replace($somecontent, "", $file_data);
$file = fopen($filename, "w");
fputs($file, $file_data);
fclose($file);

}
} -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the Best PHP Directory Script? hakkinen Directories 3 08-31-2006 03:14 PM
need PHP online test script perto PHP Programming and Tips 1 08-23-2006 01:45 PM
Can FTP sessions be carried to another script? kipper PHP Programming and Tips 1 08-12-2006 10:52 AM
Cron with Plesk and PHP Script yogesh PHP Programming and Tips 1 08-01-2006 04:58 PM
Why do I get ASP 0113 / Script timed out errors? lardy ASP forums and Tips 1 12-07-2005 08:44 AM


All times are GMT. The time now is 08:40 PM.