SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help coding with php5-->4

    hello everyone, I have this .php file which is not working with my php4 since it contain try..catch exception..........please help to make this work with my php4 since my host only support php4...........and I need this ASSP.

    Thanks a lot !!



    <?php

    // include function files for this application
    require_once('bookmark_fns.php');
    session_start();

    //create short variable names
    $username = $_POST['username'];
    $password = $_POST['password'];

    if ($username && $password)
    // they have just tried logging in
    {
    try
    {
    login($username, $password);
    // if they are in the database register the user id
    $_SESSION['valid_user'] = $username;
    }
    catch(Exception $e)
    {
    // unsuccessful login
    do_html_header('Problem:');
    echo 'You could not be logged in.
    You must be logged in to view this page.';
    do_html_url('login.php', 'Login');
    do_html_footer();
    exit;
    }
    }

    do_html_header('Home');
    check_valid_user();
    // get the bookmarks this user has saved
    if ($url_array = get_user_urls($_SESSION['valid_user']))
    display_user_urls($url_array);

    // give menu of options
    display_user_menu();

    do_html_footer();
    ?>

  2. #2
    SitePoint Zealot
    Join Date
    Mar 2007
    Posts
    196
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you positive your host only supports PHP4 because some hosts support PHP5 you just have to save your files with the extension .php5
    Kayzio - We don't hesitate, we accelerate.

  3. #3
    Worship the Krome kromey's Avatar
    Join Date
    Sep 2006
    Location
    Fairbanks, AK
    Posts
    1,621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not going to be as simple as you think - it would appear that the function login would be the source of the thrown exception, so you would need to go into there, find where the exception is thrown, and rewrite it to not throw an exception.

    As Kayzio suggests, check if your host truly does not support PHP5 at all (I was pleasantly surprised to discover one of my clients' hosts does support it if you save the files with a .php5 extension; this host also allowed a set of .htaccess directives to reverse this behavior, i.e. default to PHP5 and save files with a .php4 extension if you wanted to use PHP4). If not, you're in for one heckuva headache - you'd be better off rewriting this code entirely or else finding a PHP4-compatible script somewhere.
    PHP questions? RTFM
    MySQL questions? RTFM


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
  •