Results 1 to 8 of 8

Thread: Again an fatal error

  1. #1
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    594
    Thanks
    43
    Thanked 28 Times in 28 Posts

    Default Again an fatal error

    I am getting this error:
    Fatal error: Call to undefined function EncodeMessage() in ......./../enlighten/php_guestbook.php on line 34

    PHP Code:
    <?
    ########################################################################################
    #   A Simple PHP GuestBook Script written by Andrea Cabibbo          #      ######     #
    #   Feel free to modify the code to suit your needs                 # #     #          #
    #   Redistribution is NOT allowed and will be prosecuted           #   #    #          #
    #   Version: v0.6                                                 #######   #          # 
    #   If you find bugs or have suggestions, please contact         #       #  #          #
    #   the author at the PHP Guestbook official home page:         #         # ######     #
    #                                                                                      #
    #   http://www.cellbiol.com/scripts/free_php_guestbook/free_php_guestbook.html         #
    #   File last edited on may 11, 2010                                                   #
    ########################################################################################
    #                                                                                      #
    # REQUIRED FILES AND FOLDERS PERMISSIONS INFORMATION                                   #
    # For the html guestbook file, the configuration file (include/conf.php)               #
    # and the verify.png file a 666 permission is needed for the script to work            #
    # The posts folder should have either a 755 or 777 permission depending on server      #
    # THE CONFIGURATION VARIABLES ARE NOW IN THE include/conf.php FILE.                    #
    # No manual editing of this conf.php file is needed as the configuration variables     #
    # are accessed though the administration web interface                                 #
    #                                                                                      #
    #                                                                                      #
    ########################################################################################

    error_reporting(1);
    $used_language="include/lang/eng/lang.php"# this cannot be changed 
    $enable_image_verification_step=1# this cannot be changed 
    $moderation_active="no"# this cannot be changed 
    $powby="<a class=\"powby\" href=\"http://www.cellbiol.com/scripts/free_php_guestbook/free_php_guestbook.html\" target=\"_blank\">Powered by the The Easy PHP Guestbook «</a>";// editing of the powered by lines is not allowed
    $pwb2="<a class=\"powby\" href=\"http://www.cellbiol.com/scripts/free_php_guestbook/free_php_guestbook.html\" target=\"_blank\">Powered by the The Easy PHP Guestbook «</a>";// editing of the powered by lines is not allowed
    $conf_file="include/conf.php"//the configuration file
    include $conf_file;include $used_language;include "include/classes.php";include "include/functions.php";
    include 
    "include/mixvar.php";include "include/html/forms.php";include "include/html/mix_html.php";
    $date=EncodeMessage($date);

    # GEOIP, please read carefully:
    # $geoip_db is the expected location of the geoip database file.
    # This file IS NOT INCLUDED in this software distribution and is not part of this guestbook software, which merely offers a way to access and use this file, if so desired by the user.
    # It is a GPL licensed file that can be freely downloaded from http://software77.net/geo-ip/
    # The provided geoip code can use the CSV version of this file only. You can download this csv file compressed in a zip format or gzip format from the above web site
    # You should then unzip it and place it in the "include" folder of the guestbook software distribution. When unzipped, this file should be named IpToCountry.csv, you might want to check that out.
    $geoip_db="include/IpToCountry.csv"# see comments above
    $geoip_file_exists=file_exists($geoip_db);
    if(
    $geoip_file_exists){$geoip_file_detected="<span style=\"color:green\">yes</span>";}
    else{
    $geoip_file_detected="<span style=\"color:red\">no</span>";}

    if (
    $activate_geoip=="yes" && $geoip_file_exists)
    {
      
    $user_country_name=locate_ip_2($ip_addr,"name");
      
    $user_country_code=locate_ip_2($ip_addr,"code");
    }
    # END GEOIP

    $create_post_array=
    '
    $post_array=array(
    I don't know what to look for for this problem.Is there a problem with the ( or ) in tor near line 34?

    This is part of the php code I hope the rest is not related to my problem.
    Thanks,

    Bud

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    ack! you deleted the one I replied to.
    problem is, the function EncodeMessage() is not a function in PHP, and it is not defined anywhere in your script. Is there another part of the script that is supposed to define that function?

  3. #3
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    594
    Thanks
    43
    Thanked 28 Times in 28 Posts

    Default

    Here is the whole thing:
    http://www.web-user.info/enlighten/php_guestbook2.txt

    I tried to c/p the code but it was to long so I got the txt file for you to check out

    It is weird,this same code in a different directory works fine but when I try and get it to work here I get this error.

    I don't have any idea Adrian, if it is anywhere else.......

    Any help would be appreciated
    Thanks,

    Bud

  4. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by ajfmrf View Post
    It is weird,this same code in a different directory works fine but when I try and get it to work here I get this error.
    that's a good sign that it's because the function definitions are in a separate file. go through the entire script and find all places where you include a file, and make sure all the file paths are correct for the script's new location.

    ........................
    just a word of caution - I didn't read the entire script, but I saw that it uses the eval() function in several places. this is poor practice, because it *can* introduce security problems (or just regular problems, if you're lucky). Please note, it isn't necessarily bad - eval can be used safely - but there is almost always a "better way" to accomplish the same goal. In my experience, over-reliance on eval() is often the sign of a poorly written script.

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    ajmrf, I'm a little confused about why you're spending so much time on these problematic scripts (or is it just one?). There are lots of comment scripts out there and some will work better for you than others. But honestly you're not going to find one that just fits your site perfectly as-is.

    You're already putting a lot of time and effort (and learning) into making this work, so I suggest you create your own comments script. It's not actually that difficult (compared to other things like making a forum or other big project).

    You'd need to choose if you want text files or a database. Either one would work. Comments are simple enough to work smoothly in flat files (text files), but they can of course work in a database too. If you're already using a database (and you know how) then use that; if not, flat files are probably a little easier to deal with.

    Here's an old discussion about a comments script that I wrote. Feel free to take it apart and put it back together until you have something you'd like. Or just use some ideas and make your own new one.
    http://www.dynamicdrive.com/forums/s...6-PHP-Comments

    It's a somewhat disorganized discussion, but actually if you read through all of it you'll learn a lot, as the script evolves and gets new features over time. Then you can use the final working version, or some version you adjust, on your pages.

    And best of all, it's something you'd need to put together yourself, but because of that it will be very easy to integrate with your existing site. (And as far as I know it works pretty well.)
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    594
    Thanks
    43
    Thanked 28 Times in 28 Posts

    Default

    Well ,this script is working fine in a different directory.What the problem is and why it happened in a different directory confuses me.

    I got a simple script to work and when I went to move it Bam-something went squirrelly-I don't know why but this should have been a simple thing to do.

    But I will look at the discussion you posted Daniel-thanks
    Thanks,

    Bud

  7. #7
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by ajfmrf View Post
    Well ,this script is working fine in a different directory.What the problem is and why it happened in a different directory confuses me.
    I got a simple script to work and when I went to move it Bam-something went squirrelly-I don't know why but this should have been a simple thing to do.
    Quote Originally Posted by traq View Post
    go through the entire script and find all places where you include a file, and make sure all the file paths are correct for the script's new location.
    You've already identified the cause of the problem: you moved the script to a different directory.
    Given this, the first thing you should check is any file paths your script uses.

    This is a very, very basic concept in web design - in computing in general, in fact: it has nothing to do with what language you're using, or how complicated the script is.

    There are three ways to specify a URL on a webserver:
    • Absolute (e.g., www.example.com/path/to/file.txt). This is a complete locator, and the server can find the file specified with no extra help (excepting, possibly, the protocol (http://).
    • Root-relative (e.g., /path/to/file.txt). As long as you are somewhere on example.com, the server can find the specified file, because it always starts from the site root.
    • Relative (e.g., to/file.txt - this is the model your script uses). As long as the current working directory (the directory where your script is running) is example.com/path, the server can find the file, because it assumes the URL starts from the cwd. i.e., the server expands the path "to/file.txt" to be "/path/to/file.txt" and everything is fine.

      If you move the script to a different directory, then the server will expand the URL to "/different/to/file.txt" and will be unable to find the desired file (because "/different/to/file.txt" does not exist).

      There is nothing mysterious about why or how it happens; it is completely expected behavior.
      and to fix it, you need only check that all of the file paths are correct.


    I don't mean to be condescending or to deter you. This is a "basic" that you need to know if you want to do web stuff. If you need any help understanding any of this, please, ask! The stronger your understanding of the basics, the better your coding will be.
    Last edited by traq; 09-05-2012 at 03:02 AM.

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    Well ,this script is working fine in a different directory.What the problem is and why it happened in a different directory confuses me.

    I got a simple script to work and when I went to move it Bam-something went squirrelly-I don't know why but this should have been a simple thing to do.

    But I will look at the discussion you posted Daniel-thanks
    Although I agree with traq that this is something that could be fixed, again I just am not sure whether the time you're putting into it is worth it.

    If you design your own script, or use a "do it yourself" script like I linked to, then:
    1) You'll have completely control over anything. It will be harder, but with less limitations.
    2) Once you know how it works, you'll spend no time trying to understand it and much less time debugging it. At the moment you're just hoping to find what's wrong with this script, and it might be 5 other things too (I have no idea!). If you do it yourself, you'll know immediately how it all works together rather than trying to fix it by trial and error.


    Honestly, even as some generally experienced in PHP, one of the worst parts of working with this stuff is trying to understand someone else's code when it's not clearly documented. There are different styles, and sometimes the work of another coder just makes no sense, or it's too complicated to go through line by line. Having to work within that then is difficult. There's a line where I just decide not to bother and I write my own code. Of course that can take a long time and requires another sort of experience/expertise-- such as on my current project when I decided to write my own Wiki software from scratch-- and it works. But of course that was a major undertaking. The result is better than anything I could have put together with the standard software (eg, MediaWiki, the free [but somewhat difficult to customize] software behind Wikipedia).

    A clear indication that it's time to write your own script is when you want more control than the script you're using allows.


    In short, often debugging an existing script can be more difficult than writing it from scratch. Only you can reasonably decide what's best for you, but consider both options. From your recent posts, it doesn't sound like using these comments scripts is easy for you (they seem to not work too well), so why not put the same level of "not easy" effort into writing something new? You might surprise yourself.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Similar Threads

  1. Resolved Fatal error: Function name must be a string
    By Priyo in forum PHP
    Replies: 2
    Last Post: 02-07-2012, 06:12 PM
  2. Resolved Fatal Error?
    By sparklingsky in forum PHP
    Replies: 2
    Last Post: 04-17-2009, 02:43 AM
  3. Fatal error: MySQL and PHP
    By adriana_l_2000 in forum PHP
    Replies: 1
    Last Post: 03-12-2006, 06:31 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •