Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    rmd
    rmd is offline
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Having trouble getting php4 code working on php5 server

    My hosting provider recently upgraded to php5 and one of my php scripts is playing up. I have looked all over the php site for an idea of what part of the code needs changing and have drawn a blank. If anyone has any idea of what needs altering in the below code to get it working on php5, I would be very grateful.

    PHP Code:
    if (($_GET["sub"] == "auto") && (($_GET["action"] == "add") || ($_GET["action"] == "edit"))) {

                    
    $_models $that->db->QFetchRowArray("SELECT * FROM {$that->tables[make]}");
                    if (
    is_array($_models)) {
                        foreach (
    $_models as $key => $val) {
                            if (
    $val["make_parent"] == 0) {
                                
    $make[$val["make_id"]] = $val["make_name"];

                                
    $js .= "models[{$val[make_id]}] = new Array();\n";
                                
    $i 1;
                                
    $js .= "models[{$val[make_id]}][" $i++ ."] = new Option(\"[ select ]\" , \"\"); \n";
                                foreach (
    $_models as $k => $v) {
                                    if (
    $v["make_parent"] == $val["make_id"]) {
                                        
    $js .= "models[{$val[make_id]}][" $i++ ."] = new Option(\"{$v[make_name]}\" , \"{$v[make_id]}\"); \n";
                                    }                            
                                }                        
                            }                    
                        }
                    }


                    
    $extra["add"]["after"] = $extra["edit"]["after"] = $that->templates["js"]->Replace(array("script" => $js ));
                }

            
                if ((
    $_GET["sub"] == "auto") && ($_GET["action"] == "details")) {
                    
    $task = new CSQLAdmin("photos"$_CONF["forms"]["admintemplate"],$that->db,$that->tables $extra);
                    
    $extra["details"]["after"] .= $task->DoEvents(); 
    Many thanks

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,020
    Thanks
    2
    Thanked 313 Times in 305 Posts
    There are very few incompatible changes between php4 and php5. Your problem is likely a configuration difference rather than a php version problem. For the same exact server configuration, 99.5% (or more) of php4 code will run unchanged under php5.

    The code fragment you posted does not appear to contain any thing that is php configuration dependent or php4/php5 version specific.

    Turning on full php error reporting might help you find problems, such as undefined program variables that are no longer getting set because register globals are no longer on...

    Posting part of your code and making a vague statement that - "one of my php scripts is playing up" is of zero use for anyone to help you. What specifically is it doing that is wrong? What output are you getting vs what it should be? What symptoms are there? What errors are there?

    Re-read your post and tell us if you think it contains any information for someone to help you. It does not state what it is, what is should be doing, or what it is doing (and mind reading does not work over the Internet.)
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


  •  

    Posting Permissions

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