Forum Moderators: coopster

Message Too Old, No Replies

fopen how set file extension

         

nanat

5:14 am on Jul 8, 2009 (gmt 0)

10+ Year Member



hi anyone how can i set file extension with my fopen statement


if (!$sql) die();

$f = @fopen(updateItemCode, 'a+');
if ($f) {
@fputs($f, date("m.d.Y g:ia")." ".$_SERVER['REMOTE_ADDR']." ".$itemscode." ".$fulname."\n");
@fclose($f);
}

result:
updateItemCode.html?

andrewsmd

2:24 pm on Jul 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What do you mean set the file extension. You are opening updateItemCode it will open whatever extension updateItemCode is. If updateItemCode is a file then it should be in quotes like
$f= fopen("updateItemCode.html", 'a+');
Also, you should remove the @ in front if that because it will ignore errors and that can create debugging nightmares. Can you paste more code? If you want to keep the @ then you need to check to see if it is successful as in
if($f = @fopen(updateItemCode, "a+"){
//then do something
}
else{
//there was an error in opening the file
//which is what I'm guessing your problem is
}