+ Reply to Thread
Results 1 to 4 of 4

Thread: Problem writing to a file (php)

  1. #1
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    Problem writing to a file (php)

    I am having this problem where = are getting added to the code.

    here is the source to everything and the file that i am writing to and the orginal file


    http://sterling.is-a-chef.com/countd...=countdown.php (orginal)

    http://sterling.is-a-chef.com/countd...countdown2.php (new)

    http://sterling.is-a-chef.com/countd...le=replace.php (rewrite)
    Last edited by Chris S; 06-04-2006 at 07:56 PM.

    I would love to change the world, but they won't give me the source code

  2. #2
    Torch's Avatar
    Torch is offline x10 Lieutenant Torch is an unknown quantity at this point
    Join Date
    Apr 2006
    Location
    Belgrade, Serbia
    Posts
    317

    Re: Problem writing to a file (php)

    It's not that '=' is added, the problem is that none of your variables are getting transfered, because script is trying to print their value instead of them as string. And since they have no value, nothing is printed and transfered to new file.

    I fixed your code, haven't tested it, but I think it should work:
    PHP Code:
    <?php 
    $filename 
    "countdown2.php"

    $somecontent '<?php

    header("Content-type: image/png");
       $image = imagecreatefrompng("../away.png");

          $red = imagecolorallocate($image, 255, 000, 000); 
          $green = imagecolorallocate($image, 000, 100, 000); 
          $black = imagecolorallocate($image, 000, 000, 000); 
       
       imageline($image, 1, 1, 1, 199, $black); 
       imageline($image, 1, 1, 199, 1, $black); 
       imageline($image, 1, 74, 199, 74, $black); 
       imageline($image, 199, 1, 199, 74, $black); 
    $font = "../larabieb.ttf";

    function countdown($year, $month, $day, $hour, $minute, $image, $font, $color) 

      $the_countdown_date = mktime($hour, $minute, 0, $month, $day, $year, -1); 

      $today = time(); 

      $difference = $the_countdown_date - $today; 
      if ($difference < 0) $difference = 0; 

      $event = "Come Home from Europe\nand Homecoming Performence"; //event

      $days_left = floor($difference/60/60/24); 
      $hours_left = floor(($difference - $days_left*60*60*24)/60/60); 
      $minutes_left = floor(($difference - $days_left*60*60*24 - $hours_left*60*60)/60); 
       
        imagettftext($image, 10.1, 0, 5, 15, $black, $font, "Event:$event");
        imagettftext($image, 10.1, 0, 5, 50, $black, $font, "Days Until I Come Back:$days_left");

      } 

    countdown(2006,7,19,5,0, $image, $font, $color); 


    imagepng($image); 

    imagedestroy($image); 
    ?>'
    ;
       if (!
    $handle fopen($filename'w')) { 
             echo 
    "Cannot open file ($filename)"
             exit; 
       } 

       
    // Write $somecontent to our opened file. 
       
    if (fwrite($handle$somecontent) === FALSE) { 
           echo 
    "Cannot write to file ($filename)"
           exit; 
       } 
       
       echo 
    "Success"
       
       
    fclose($handle); 

    ?>
    This is replace.php file
    Last edited by Torch; 06-05-2006 at 01:57 PM.

  3. #3
    Torch's Avatar
    Torch is offline x10 Lieutenant Torch is an unknown quantity at this point
    Join Date
    Apr 2006
    Location
    Belgrade, Serbia
    Posts
    317

    Re: Problem writing to a file (php)

    Did it work?

  4. #4
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    Re: Problem writing to a file (php)

    ya sorry, i've been busy getting ready for my trip

    I would love to change the world, but they won't give me the source code

+ Reply to Thread

Similar Threads

  1. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  2. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  3. Problem editing a .tpl file
    By blaindugan in forum Free Hosting
    Replies: 2
    Last Post: 05-20-2006, 11:44 PM
  4. Writing / Translating php tutorials.
    By flapietoetoe in forum The Marketplace
    Replies: 2
    Last Post: 04-02-2006, 04:08 PM
  5. File permission problem
    By cetutnx1 in forum Free Hosting
    Replies: 6
    Last Post: 02-16-2006, 09:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers