Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 11-26-2005, 07:58 PM php news script
Skilled Talker

Posts: 68
Trades: 0
Hello, i;m makeing a news script and most of it works but i am haeving trubble getting it to stop after 3 headlines have been made so i made a script that added a number to newscount.txt and when news count.txt was to big ther would be no news.
heres my code
PHP Code:
<?php session_start();?>
<meta http-equiv="refresh" content="4 ;URL=index.php" />

<?php
if (isset($_SESSION['username'])) {
$name $_SESSION["username"];

  if (
$name == "admin") {
  
$headline=$_POST['headline'];
  
$user=$_POST['user'];
  
$msg=$_POST['msg'];

  
$time=date("H:i dS F");

  
$newscount="newscount.txt";
  
$handle=fopen($newscount"r") or die("Error");
  
$c=fread($handlefilesize($newscount));
  
fclose($handle);

    if (
$c 2) {
    
$filename="news.txt";
    
$handle=fopen($filename"r") or die("Error");
    
$old_content=fread($handlefilesize($filename));
    
fclose($handle);
    
$data "<b>$headline</b><p>$msg<br /><br />Posted by $user at $time<br /><br /><br />";

    
$final_content=$data.$old_content;

    
$handle2=fopen($filename"w") or die("Error");
    
$finalwrite=fwrite($handle2$final_content);
    
fclose($handle2);
    echo 
"redirecting you.....";

    
$c++;

      if (
$c == 0) {
      
$c=1;
      }

    
$file=fopen($newscount,"w") or die("Error");
    
fwrite($newscount,$c);
    
fclose($file);
    }
  }
}
else {
echo 
"Your not a Admin and only admins can post news.";
}
?>
problem is nothign is being writen to newscount.txt, if ther is somthign in ther is it over writen with nothing and if thers not a i get a error saying
Warning: fread() [function.fread]: Length parameter must be greater than 0. in C:\Abyss Web Server\htdocs\news.php on line 17
redirecting you.....
Warning: fwrite(): supplied argument is not a valid stream resource in C:\Abyss Web Server\htdocs\news.php on line 41
mrpaul is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-27-2005, 07:43 AM
Skilled Talker

Posts: 68
Trades: 0
and i always get this error
Warning: fwrite(): supplied argument is not a valid stream resource in C:\Abyss Web Server\htdocs\news.php on line 41

anyone know what it means and how to fix it?
line 41: fwrite($newscount,$c);
mrpaul is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to php news script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09676 seconds with 12 queries