SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    philmont
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    something wierd happened..

    Something really odd happened to my codes...
    I had these codes working last week and when I went to enter something tonight, they caused a string of errors.
    If you know how to fix these codes and errors I would appreciate it.


    addnews.php
    <form action="postnews.php" method="post">
    Name: <input type="text" name="name"><br>
    Email: <input type="text" name="email"><br>
    Title: <input type="text" name="title"><br>
    Textbr>
    <textarea name="text" cols="50" rows="10"></textarea><br>
    <input type="submit" value=" Post News ">
    </form>

    postnews.php

    <?php

    $name= $_POST['name'];
    $email="$POST['email'];
    $title = $_POST['title'];
    $text = $_POST['text'];
    $date = date("F j, Y", time());

    if ( ! is_dir("news/") )
    {
    mkdir("news/");
    }

    if ( $handle = opendir("news/") )
    {
    while ( ( $file = readdir( $handle ) ) !== false )
    {
    if ( $file != "." && $file != ".." )
    {
    $news_array[] = $file;
    }
    }
    closedir( $handle );
    }

    $num_news = ( count( $news_array ) + 1 );
    touch("news/$num_news.txt");

    $final = "$date\n$title\n$author\n$email\n$text";

    $fp = fopen("news/$num_news.txt", "w");
    flock( $fp, LOCK_EX );
    fputs( $fp, $final );
    flock( $fp, LOCK_UN );
    fclose( $fp );

    echo '<center><b>Your news article has been posted!</b></center>';

    ?>

    ../news.php
    <?php

    $display = 10;

    if ( $handle = opendir("./News/news/") )
    {
    while ( ( $file = readdir( $handle ) ) !== false )
    {
    if ( $file != "." && $file != ".." )
    {
    $news_array[] = $file;
    }
    }
    closedir( $handle );
    }

    array_multisort( $news_array, SORT_NUMERIC, SORT_DESC );
    array_splice( $news_array, $display );

    $num_news = ( count( $news_array ) );

    foreach ( $news_array as $val )
    {
    $news_file = file("./News/news/$val");


    $date = $news_file[0];
    $title = $news_file[1];
    $name= $news_file[2];
    $email= $news_file[3];
    $text = $news_file[4];


    echo "<font color='white'><b>".$date."</b><br>";
    echo '<font size="+1"><i>'.$title.'</i></font><br>';
    echo '<small>Written by: '.$name.'</small><br>';
    echo $email
    echo $text;
    echo ' </font><body vlink="#BABABA"><a href="#beginning"><font size="-2" color="#BABABA">Top</font></a><br><br>';
    }

    ?>


    my errors
    Warning: mkdir(news/): Permission denied on line 11

    Warning: opendir(news/): failed to open dir: Invalid argument on line 14

    Notice: Undefined variable: news_array on line 26

    Warning: touch(): Unable to create file news/1.txt because No such file or directory on line 27

    Warning: fopen(news/1.txt): failed to open stream: No such file or directory on line 31

    Warning: flock(): supplied argument is not a valid stream resource on line 32

    Warning: fputs(): supplied argument is not a valid stream resource on line 33

    Warning: flock(): supplied argument is not a valid stream resource on line 34

    Warning: fclose(): supplied argument is not a valid stream resource on line 35

  2. #2
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    philmont
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just a side note::

    all of my pages that use similar codes (only a few inputs and locations differ) are having the same problems.

  3. #3
    SitePoint Member
    Join Date
    Jan 2005
    Location
    San Francisco
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you check to make sure that the permissions on the directory and files are set so that the webserver can modify them?

  4. #4
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    philmont
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like I said, I had these pages working a week earlier and did nothing to them whastoever. All I know is that yesterday I went to post something and I was denied permissions.

    I know that I have the ability to write to files and create them as I did last week.

  5. #5
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    It looks like you don't have the right permissions anymore. Maybe you should contact your host and ask them what happened.

  6. #6
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    philmont
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    somehow or other, the host/server that Im using "lost" my permissions....
    I got them to reset my permissions. Thanks, I thought for a bit that there was something wrong with the codes I was using and it started to really "freak" me out as I've been using those for a bit.

    Thanks again.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •