file open error

Discussion in 'PHP' started by arunsuriindia, Mar 21, 2007.

  1. #1
    <?php


    $frow=0;
    $list = array_map("trim", file($filename));
    $list = array_map( create_function('$line', 'return split(",", $line);'), $list);
    $numrow=sizeof($list);

    for($r=1;$r<$numrow+1;$r++){
    if($list[$r-1][6]){
    $frow++;
    for($c=1;$c<8;$c++)
    $final[$frow-1][$c-1]=$list[$r-1][$c-1];
    }
    }
    $file="c:\\a.csv";

    if(file_exists($file))
    if(!fopen($file, 'w+'))
    echo "k1";


    $handle = fopen($file, 'w+');
    $a="as";
    if(!fwrite($handle, $a))
    echo "bad";
    fclose($handle);

    ?>



    this code doesn`t open the file even when the file exists what could be the problem
     
    arunsuriindia, Mar 21, 2007 IP
  2. jitesh

    jitesh Peon

    Messages:
    81
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Just for test try to open a file in read only mode
    fopen($file, 'r');
     
    jitesh, Mar 21, 2007 IP
  3. itrana123

    itrana123 Peon

    Messages:
    177
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    is it giving some sort of error or responding something else ...
     
    itrana123, Mar 21, 2007 IP
  4. arunsuriindia

    arunsuriindia Peon

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanx itranna and jitesh for taking intrest. The files open when
    fopen($file, 'r'); is written now i want to open a file and write in it
     
    arunsuriindia, Mar 21, 2007 IP
  5. jitesh

    jitesh Peon

    Messages:
    81
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Now place a file in same directory where you have placed ur script file. then try to open a file in write mode

    If It will open then you will understand what the matter is.
     
    jitesh, Mar 21, 2007 IP
  6. seolion

    seolion Active Member

    Messages:
    1,495
    Likes Received:
    97
    Best Answers:
    0
    Trophy Points:
    90
    #6
    Check the file permissions.. May be the case as well
     
    seolion, Mar 22, 2007 IP