Jump to content


Photo

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


  • Please log in to reply
7 replies to this topic

#1 ecroskey

ecroskey
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 20 October 2006 - 05:38 PM

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?

  $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);


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

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 20 October 2006 - 05:44 PM

are your folder and file permissions on your new box set in such a way as to allow your apache user (server) write access?
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 ecroskey

ecroskey
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 20 October 2006 - 05:50 PM

Yup. The folder is 777.

#4 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 20 October 2006 - 05:56 PM

Are you sure it's crashing on the call to fopen and not before?
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com

#5 ecroskey

ecroskey
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 20 October 2006 - 06:00 PM

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.

#6 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 20 October 2006 - 06:05 PM

why not throw some error checking onto there and see where it's dying:
<?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!";
}
?>

this way, you can tell exactly where it's erroring out
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#7 ecroskey

ecroskey
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 23 October 2006 - 03:14 PM

Same thing. It doesn't show me any of the errors. Back to a white screen.

#8 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 23 October 2006 - 04:13 PM

Same thing. It doesn't show me any of the errors. Back to a white screen.


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().
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users