Page 1 of 1

file() function

Posted: Tue Jan 17, 2006 5:20 am
by khurram
twigletmac | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


hello all great programmers,

i m new to PHP. i m developed a simple page in which i use implode() function. this program was running fime when i was using php 4.3. but as i upgrade it to php 5.1 it is not working and giving error.

source is here

Code: Select all

<?php
$contents="";
include "config.php";
include "common.php";
$f="login.htm";
$contents = implode('',file($f));
$contents=formatPage($contents);
print $contents;
?>
it gives error.
Warning: file(login.htm): failed to open stream: No such file or directory in d:\www\currNs\login.php on line 7 Warning: implode(): Bad arguments. in d:\www\currNs\login.php on line 7

but when i provide its path on local machine

Code: Select all

$f="D:\www\curr\Ns\login.htm";
    $contents = implode('',file($f));
it runs fine.

what is this problem and how can i overcome this one i already waste a whole day on it..:(

pls email me gbuttgee@yahoo.com

thanks in advance

Khurram


twigletmac | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Tue Jan 17, 2006 5:41 am
by raghavan20
make sure login.htm and login.php are on the same page...if not you can use relative path not necessarily absolute path...

Posted: Wed Jan 18, 2006 1:39 am
by khurram
yes login.htm and login.php are in the same folder. this script was running absolutly fine on php4.3

what is relative path and absolute path? :roll:

Khurram

Posted: Wed Jan 18, 2006 2:27 am
by raghavan20
This should help you...