Jump to content

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


ecroskey

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)
Link to comment
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.
Link to comment
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
Link to comment
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().
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.