Welcome, Guest
  • Author Topic: guestbook php 4.5 to 5  (Read 1897 times)

    Ipacus

    • Server what's that
    • *
    • Posts: 4
      • View Profile
    guestbook php 4.5 to 5
    « on: 06/07/10, 03:25 »
    Hi,

    I'm a newbee at flashscripting and php. I used a guestbook from this forum and restyled it
    ( http://www.operadellacasa.com/gastenboek_opera.html ). It worked fine until last month. The provider stated that i had to change the php file because they migrated from php 4 to php5. This is the code i used.
    And, yes, it does'nt work anymore. Can anyone help me to get this php script working again.

    thanx

    'a desperate' Ipacus

    -------------------- code --------------------------
    <?php

    $Submit             = $_POST["Submit"];
    $Name             = $_POST["Name"];
    $Email             = $_POST["Email"];
    $Comments    = $_POST["Comments"];
    $NumLow    = $_REQUEST["NumLow"];
    $NumHigh    = $_REQUEST["NumHigh"];

    //$Name      = ereg_replace("[^A-Za-z0-9 ]", "", $Name);
    $Email            = ereg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $Email);
    //$Comments   = ereg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $Comments);
    //$Website    = eregi_replace("http://", "", $Website);
    //$Website    = ereg_replace("[^A-Za-z0-9 \@\.\-\/\'\~\:]", "", $Website);

    $Name             = stripslashes($Name);
    $Email             = stripslashes($Email);
    $Comments    = stripslashes($Comments);

    // Lezen en schrijven naar de GuestBook.txt file

    if ($Submit == "Yes") {

       $filename    = "GuestBook.txt";



       $fp       = fopen( $filename,"r");
       $OldData    = fread($fp, 80000);
       fclose( $fp );

    // Geeft de datum weer...

       $Today  = (date (" d F Y ( h:i:s A )",time()));
    // $Today  = (date ("I d F Y ( h:i:s A )",time()));
       
       $Input = "Naam: <b>$Name</b><br>Email: <b><u><a href=\"mailto:$Email\">$Email</a></u></b><br>Reactie: <b>$Comments: </b><br><i><fontsize=\"-1\">Datum: $Today</font><br><br>.:::.";


       $New = "$Input$OldData";


       $fp = fopen( $filename,"w");
       if(!$fp) die("&GuestBook=cannot write $filename ......&");
       fwrite($fp, $New, 800000);
       fclose( $fp );
    }


       $filename = "GuestBook.txt";



       $fp    = fopen( $filename,"r");
       $Data    = fread($fp, 800000);
       fclose( $fp );


       $DataArray = split (".:::.", $Data);


       $NumEntries = count($DataArray) - 1;

       print "&TotalEntries=$NumEntries&NumLow=$NumLow&NumHigh=$NumHigh&GuestBook=";
       for ($n = $NumLow; $n < $NumHigh; $n++) {
       print $DataArray[$n];
          if (!$DataArray[$n]) {
             Print "<br><br><b>Niet meer reacties</b>";
          exit;
          }
       }
    ?>

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: guestbook php 4.5 to 5
    « Reply #1 on: 06/07/10, 08:45 »
    ereg_replace does not exist anymore - replace with preg_replace - that should do it
    happy flashing
    8)
    Ronald

    Ipacus

    • Server what's that
    • *
    • Posts: 4
      • View Profile
    Re: guestbook php 4.5 to 5
    « Reply #2 on: 06/07/10, 09:06 »
    Hi,
    Thank you for the quick response,.......but the preg_replace did'nt do the job. A new entry does not show in the GuestBook.

    Any other ideas?

    sorry for my bad english.

    Ips

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: guestbook php 4.5 to 5
    « Reply #3 on: 06/07/10, 12:37 »
    Dont worry about your english.
    The most of us are not native speakers - I am from Germany.

    Anyway - to get more detailed info: what do you receive, if you call the scipt directly in the browser?
    Do you receive error messages?

    Is it possible to ge a life link, to have a direct look?
    happy flashing
    8)
    Ronald

    Ipacus

    • Server what's that
    • *
    • Posts: 4
      • View Profile
    Re: guestbook php 4.5 to 5
    « Reply #4 on: 06/07/10, 16:29 »
    Hi Ronald,

    I receive no error message what so ever. I tried it with

     ini_set('display_errors,1);
    error_reporting(E_ALL | E_STRICT);

    to enforce a return error, but when i put this code in the script the Geustbook does not work at all.

    I believe that the script should work with php5. And i believe that the provider did not set the chmod=777 to the GuestBook.txt file. Therefore the entry can not be written into the GuestBook.txt file. But when i phoned the provider, they told me that the chmod of the GuestBook.txt file was 777 and therefore correct. They insist that the PHP script is wrong and should be rewritten for PHP5.
    This provider does not allow to change the CHMOD of a file, you have to make a request and they will do it for you.

    http://www.operadellacasa.com/gastenboek_opera.html

    this is the site

    greetz Ips





    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: guestbook php 4.5 to 5
    « Reply #5 on: 06/08/10, 04:40 »
    the guestbook file is there and working.
    if you call the script, you receive an internal server error (error 500).

    This means, something is wrong with the script itself, or a function inside of it.

    You are right - writing seams to be a problem.

    Do you have access to the files via FTP?
    With the FTP-Programm, you can set access rights.
    Check this.
    happy flashing
    8)
    Ronald

    Ipacus

    • Server what's that
    • *
    • Posts: 4
      • View Profile
    Re: guestbook php 4.5 to 5
    « Reply #6 on: 06/09/10, 08:55 »
    Hi,

    Yes, writing to the .txt file was the problem. My provider told me on the phone that the script was the problem. So, i installed php5 on my own server and..... everything worked fine.
    With this knowledge i phone the helpdesk again. Finally they changed the CHMOD of the txt file.

    Thanx for your help

    Ips

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: guestbook php 4.5 to 5
    « Reply #7 on: 06/09/10, 12:19 »
    cant ou do those changes with ftp?
    It is complicated to ask your privider doing little things like that ;)
    Are you paying for this webservice, or is it a free hosting service?
    happy flashing
    8)
    Ronald