Author Topic: FORTRAN SMASH  (Read 2536 times)

The Holy Saint, Grand High Poobah, Master of Monkeys, Ehlers

  • Administrator
  • Level 96
  • *****
  • Posts: 19211
  • Fell Points: 17
  • monkeys? yes.
    • View Profile
    • herb's world
FORTRAN SMASH
« on: July 29, 2008, 01:15:14 AM »
ok, php, not fortran.

Code: [Select]
$docu_content='string information';
$newloc = '/home/clients/herbertlives.com/www/books/' . $orig;
if (file_put_contents('$newloc', '$docu_content')) {
print '<a href="' . $orig . '">File Created</a>';
} else {
print 'file creation failed';
}
($orig comes from POST data earlier)

now, my understanding is that if file_put_contents() is successful it returns the number of bytes written. Otherwise it returns false.
but all it does here is kill the script.
It does the same thing if I have a variable equal to the file_put_contents() statement and use that variable for the if statement. The script dies when it hits file_put_contents(), which i've tested by moving a print statement around. works fine before it's called, not immediately after.

anyway, jsut very very angry about this right now and no one who knows PHP is online right now to talk to me. so I had to spew it somewhere.

Miyabi

  • Level 45
  • *
  • Posts: 3098
  • Fell Points: 1
  • Simple is the concept of love as eternity.
    • View Profile
Re: FORTRAN SMASH
« Reply #1 on: July 29, 2008, 02:37:30 AM »
Maybe this is just because I can't see like script you excluded here, but you would first have to call the file_put_contents() function earlier in the script, or define its parameters before you could check its paramaters.

It's like saying IF there's a basketball and soccer ball in the bag . . . but you didn't define WHAT was in the bag first,  and we couldn't look because that space hasn't been defined and could be anything or nothing, we wouldn't know what to do.

With what information you gave me this is all I could come up with.
オレは長超猿庁じゃ〜。

The Holy Saint, Grand High Poobah, Master of Monkeys, Ehlers

  • Administrator
  • Level 96
  • *****
  • Posts: 19211
  • Fell Points: 17
  • monkeys? yes.
    • View Profile
    • herb's world
Re: FORTRAN SMASH
« Reply #2 on: July 29, 2008, 03:46:46 AM »
i've moved it around.

like, if I put

$somevar = file_put_contents('$newloc', '$docu_content');

and then check against $somevar

Or if I even just put

file_put_contents('$newloc', '$docu_content');

it kills the script.
I'd understand if it were returning false and just not writing the file. But it's like I'm putting DIE; there instead of file_put_contents().
v. irritating.

Spriggan

  • Administrator
  • Level 78
  • *****
  • Posts: 10582
  • Fell Points: 31
  • Yes, I am this awesome
    • View Profile
    • Legacies Lost
Re: FORTRAN SMASH
« Reply #3 on: July 30, 2008, 09:15:41 PM »
easy fix.

if (file_put_contents('$newloc', '$docu_content'))  is your problem, since file_put_contents doesn't return true this statement will never happen, you need to change it to if (file_put_contents('$newloc', '$docu_content')!=false)  for this to work.
Screw it, I'm buying crayons and paper. I can imagineer my own adventures! Wheeee!

Chuck Norris is the reason Waldo is hiding.