[Help] php4 to php5 errors

Discussion in 'PHP' started by Divvy, Mar 7, 2009.

  1. #1
    hi friends,

    I have my sites in a dedicated server with php4 and everything is work great.
    But now I want to upgrade my php to version 5 and someone has give me a test server with php5 to test my sites.

    The only problem, is that in some sites, I got to many errors.
    Can someone help me fixing them? Unfortunately, I don't understand anything about php knowledge to fix this errors my own.

    I don't wanna scare you guys, so I will put one error as a time. :)

    So first error is:
    Line 806 of wp_smf.php file is:
    foreach ($basliklar as $baslik) {
    Code (markup):
    Some part of the code:
    foreach ($basliklar as $baslik) {
    $content .= $mesajdanonce. 'Sec&ccedil;&atilde;o: <a href="'.$boardurl .'?board=' . $baslik->ID_BOARD .'.0">'.$baslik->bName.'</a><br>'.__('T&oacute;pico:','wp_smf').' <a href="' . $boardurl . '?topic=' . $baslik->ID_TOPIC . '.msg' . $baslik->ID_MSG . ';topicseen#new" class="smflastpost">'. $baslik->subject .'</a><br><span class="smfpostextra">'.__('&Uacute;ltimo post por:','wp_smf').' <b>'. $baslik->posterName .'</b> '.__('&agrave;s','wp_smf').' '. date("H:i - d.m.Y",$baslik->posterTime + get_settings('gmt_offset') * 3600) .'</span>'.$mesajdansonra;
    $count = $count + 1;
    }
    Code (markup):
    Can someone help me fixing this one?
    I don't understand why is working in php4 and don't work with php5.
    If you need the full code, please let me know.

    I really appreciate your help guys. Thank you!
     
    Divvy, Mar 7, 2009 IP
  2. exodus

    exodus Well-Known Member

    Messages:
    1,900
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    165
    #2
    exodus, Mar 7, 2009 IP
  3. Divvy

    Divvy Well-Known Member

    Messages:
    785
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #3
    Thank you for the help exodus.
    But damn, I don't understand anything about php to fix this error.
    Can you or someone help me?
     
    Divvy, Mar 7, 2009 IP
  4. yoavmatchulsky

    yoavmatchulsky Member

    Messages:
    57
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #4
    i don't think its a php4 to php5 problem.

    you are trying to traverse a non-object/non-array variable. add a "if (!empty($basliklar))" before your foreach

    besides that, i think your error reporting level is set too high.
    http://il.php.net/manual/en/function.error-reporting.php
     
    yoavmatchulsky, Mar 7, 2009 IP
  5. Vbot

    Vbot Peon

    Messages:
    107
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Do as yoavmatchulsky said or you can also do this:
    Just add 1 line before foreach:

    if(!is_array($basliklar)) $basliklar = array();
    foreach ($basliklar as $baslik) {
    PHP:
     
    Vbot, Mar 7, 2009 IP
  6. Divvy

    Divvy Well-Known Member

    Messages:
    785
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #6
    hi friends,

    thank you so much for your reply's.
    I did the both solutions and the error disappeared.
    But was supposed to appear the last forum comments... and instead of that, don't appears anything.

    What could be wrong? Any more ideas? :)
    Here is the full code if you want to see:
    http://enigma.webhs.pt/wp_smf.php.txt

    Thank you for your time. I really appreciate that.

    P.S. Sorry for my poor english.
     
    Divvy, Mar 7, 2009 IP
  7. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Probably the difference between the two servers is that the PHP4 one has register_globals on and in the PHP5 one it is off. User needs to learn about $_GET / $_POST / $_REQUEST.
     
    SmallPotatoes, Mar 8, 2009 IP
  8. Divvy

    Divvy Well-Known Member

    Messages:
    785
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #8
    SmallPotatoes, thank you mate for your reply.
    I have turned register_globals on in the PHP5 server but the errors is still appearing :(

    Any more ideas friends?
     
    Divvy, Mar 9, 2009 IP
  9. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Don't turn register_globals on! They made the default to turn it off for a very good reason. It makes your scripts into security nightmares. Better to invest the time and fix them so that they work without it, rather than deal with the cleanup when your server is hacked.
     
    SmallPotatoes, Mar 9, 2009 IP
  10. Divvy

    Divvy Well-Known Member

    Messages:
    785
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #10
    Ok, thank you for the advice.
    But can someone help me fixing this error that I have in my site?
    My php knowledge is zero and I really need some help. :)
     
    Divvy, Mar 9, 2009 IP
  11. madguy24

    madguy24 Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    is it for your WP blog only or entire sites in the server ? if it is just the WP, usually upgrading the WP along with plugin should work
     
    madguy24, Mar 10, 2009 IP
  12. Divvy

    Divvy Well-Known Member

    Messages:
    785
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #12
    Hi madguy24, thank you for your reply.
    Is only for a WP plugin, and I got the last version of It.

    Please, someone?
     
    Divvy, Mar 10, 2009 IP
  13. Divvy

    Divvy Well-Known Member

    Messages:
    785
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #13
    problem solved! yeah! :)

    In the plugin configuration, was needed to change the path of the forum.
    From: /home/7arte/public_html/forum
    To: /home/enigmaw/public_html/forum

    Thank you anyway guys :)
    This solved not one error, but all php errors in the site hehe
     
    Divvy, Mar 10, 2009 IP