problem in opening a file on server

Discussion in 'PHP' started by MSK7, Dec 26, 2009.

  1. #1
    Hello all ,

    I am creating a word file named salaryslip using php with fopen().

    
    $f=fopen("NewSalarySlip/SalarySlip_$employid.doc","w") or die("Can't open file");
    
    Code (markup):
    onrunning this above code on localhost a new word file salaryslip is creating well.

    But on running it on Server , error msg "Can't open file" is displayed .


    if i use mysql_error() like-

    
    $f=fopen("NewSalarySlip/SalarySlip_$employid.doc","w") or die(mysql_error());
    
    Code (markup):
    then no error message is alerted & blank is displayed after submit.



    Please help me to create that new word file successfully on Server also .

    any suggestions will be appreciated.


    Thanks & regards.
     
    Last edited: Dec 26, 2009
    MSK7, Dec 26, 2009 IP
  2. cshwebdev

    cshwebdev Active Member

    Messages:
    226
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    80
    #2
    mysql_error() only works when your interacting with the database, using file open is not a database interaction.

    Do you have error reporting turned on? Place this at the top of your php file and run it again and see what it says:
     
    cshwebdev, Dec 26, 2009 IP
  3. MSK7

    MSK7 Member

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    Thanks cshwebdev for attending my problem.

    on using the code
    
    ini_set('display_errors',1);
    error_reporting(E_ALL|E_STRICT);
    
    Code (markup):
    at the top of my php file i am getting error msg as :-

    Notice: Undefined variable: employid ,
    Notice: Undefined variable: employname,
    ....................
    .....................

    all the variables used for empinfo like empid,empname,etc.. are alerting as
    "Notice: Undefined variable: "

    and also some alert as "Undefined index" is also showing for some lines.


    Please help & guide ahead to resolve this problem.

    Thanks.
     
    Last edited: Dec 26, 2009
    MSK7, Dec 26, 2009 IP