1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to update script from 5.6 to 7.2 PHP version?

Discussion in 'PHP' started by lapidus, Dec 7, 2018.

  1. #1
    Hello

    I have one old script which only work with 5.6 PHP version,when i switch in WHM to latest PHP version 7.2 only see white screen.So that mean script is not optimized to work with latest PHP 7.2 version. How to update script files to work with latest PHP version 7.2?
     
    lapidus, Dec 7, 2018 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Turn your error reporting on E_ALL and see what errors it is throwing. There's likely depreciated functions in your script that you will need to replace.
     
    jestep, Dec 7, 2018 IP
  3. lapidus

    lapidus Well-Known Member

    Messages:
    392
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    128
    #3
    Thanks Jestep for helping me. I just check and i not have error.log file in my public html. How can i create error log file or i must do something else? Sincerely
     
    lapidus, Dec 7, 2018 IP
  4. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #4
    You may not even need to do anything. If the PHP5 script was built with best practices in mind you are good. However, if it was built with terrible code that even PHP4 would shun from then yea you're going to have to do some editing.
     
    NetStar, Dec 11, 2018 IP
  5. JEET

    JEET Notable Member

    Messages:
    3,825
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #5
    Most likely its "mysql" functions which are failing.
    To turn on your error reporting, do this at the top of your script:

    error_reporting(E_ALL);

    This will throw all errors to the browser.
    I'm 99% sure that its mysql functions, if your script is connecting to database.
    Otherwise it could be an old function like ereg etc.

    If its mysql, then switch to mysqli or to PDO. PDO will be difficult though.
     
    JEET, Apr 1, 2019 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #6
    WHY do people claim this? Yes, it might be a bit more work since you're forced to the object model, but at least when you use prepare like a good little doobie it's far, FAR simpler to implement that mysqli's bind-result trash.

    Unless you're going to go full Pakled and keep shlepping variables into your query strings like a moron with their head stuck up 2005's rectum, that's BS. At least with PDO it's all the same object (PDOStatment) instead of mysqli's half-assed difference between result and statement.

    Though a LOT of what you've said about mysqli and PDO makes me wonder if you're even using prepare/execute... or if you are, if you're even close to using it properly.

    if as @NetStar suggested it's outdated PHP 4.x style code that was being legacy supported in 5, it likely DOES need to be tossed in the trash and started over from scratch -- in which case taking the sleazy shortcuts of not switching to prepares and the function-based model of mysql is simply slapping the hobble skirt on the OP so this site can just whip around and bite them.

    Whilst yes, you can do prepare/execute in mysqli and do it right, I've found it harder to teach those essential lessons when most people just end up going full dumbass with search-replace from mysql_ to mysqli_ then hacking 'til it works... OR WORSE use some outdated "framework" or "wrapping functions" that were created with the outdated outmoded approach to doing things being hacked into working with new systems like mysqli/PDO that just don't work that way anymore.

    Since the moment you do this:

    
    $sql = "SELECT * FROM myTable WHERE id = `$userId`";
    
    Code (markup):
    You've gone full Pakled. As mind-numbingly ignorant as STYLE tags, CENTER tags, clearing DIV, absolute URI's on the same domain, or just slapping Anchors together without block level containers and calling it a menu.

    You never go FULL Pakled.
     
    Last edited: Apr 5, 2019
    deathshadow, Apr 5, 2019 IP
    SpacePhoenix likes this.
  7. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #7
    PDO is simple. It took me 5 minutes of reading to figure it out. If I ever get "stumped" or become forgetful I take a look at example code and my question is answered. It reminded me of Perl DBI and it just seemed right.
     
    NetStar, Apr 12, 2019 IP