Jump to content

Archived

This topic is now archived and is closed to further replies.

ecroskey

fopen debug help needed. Anyone have a clue on this one?

Recommended Posts

Hey gang, I have two different servers running, one using RedHat ES 3 and the other using RedHat ES 4. I have been using the following script in many different flavors for the past four years on my RH ES3 box and it works flawlessly every time. I am trying to use it on the ES4 box and when I include this particular piece of code, it tanks the page. Nothing gets displayed. Any ideas?

[code]
  $OrdDir="/var/www/telesoc/moreinfo";
  $DBAtype="dat";
  $ORDtype="tscat";
  $odate = date("Ymd");
  $adcode = "tsc";

  srand ((double) microtime() * 1000000);
  $random = (rand());


$wfileP1 = "
Request For Category Info:

Date = $odate
First Name = $_POST['fname']
Last Name = $_POST['lname']
Email Address = $_POST['email']
Category = $_POST['cats']
Drop Code = $adcode
";

  $file=$OrdDir."/".$odate.".".$ORDtype."_".$random.".".$DBAtype;
$f=fopen($file,'w');
fwrite($f,$wfileP1);
fclose($f);

[/code]

My version of php is 4.3.9 and my version of Apache is Apache/2.0.52 (Red Hat)

Share this post


Link to post
Share on other sites
are your folder and file permissions on your new box set in such a way as to allow your apache user (server) write access?

Share this post


Link to post
Share on other sites
Are you sure it's crashing on the call to fopen and not before?

Share this post


Link to post
Share on other sites
Yup. If I take this chunk out (top of file) the page will be displayed correctly, it shoots out two emails and the world is good. But as soon as I put this chunk in, with or without it's own php tags, it gets goofy. Nothing displays, no emails, nothing.

Share this post


Link to post
Share on other sites
why not throw some error checking onto there and see where it's dying:
[code]
<?php
$file=$OrdDir."/".$odate.".".$ORDtype."_".$random.".".$DBAtype;
if (is_writable($file)) {
  if (!$f=fopen($file,'w')) {
    echo "Can't open file!";
  } else {
    if (fwrite($f,$wfileP1) === FALSE) {
      echo "Couldn't write to file!";
    } else {
      echo "File written successfully!";
    }
    fclose($f);
  }
} else {
  echo "File is not writable!";
}
?>
[/code]

this way, you can tell exactly where it's erroring out

Share this post


Link to post
Share on other sites
[quote author=ecroskey link=topic=112150.msg456348#msg456348 date=1161616494]
Same thing. It doesn't show me any of the errors. Back to a white screen.
[/quote]

Is this an included file? If so, my guess is that you have syntax errors or another issue somewhere in the parent structure. I say this because, even if the code posted above was working, you'd see something on the screen ("File written successfully"). So, since you're not seeing anything at all, there are deeper issues than your fopen().

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.