Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. If command triggering at wrong time with PHP 8.1

If command triggering at wrong time with PHP 8.1

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phpdesigndata-structureshelpquestion
4 Posts 2 Posters 18 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aruna KN
    wrote on last edited by
    #1

    I'm trying to migrate my PHP code which is working on PHP 7.4 to PHP 8.1. With PHP 8.1, following

    if($message_id == "") {

    code is triggering for logged in users too. Can somebody point out common errors in this code?

    require_once("inc_common.php");
    include($engine_path."users_get_list.php");
    set_variable("message_id");
    set_variable("send_to");
    set_variable("send_to_id");
    $send_to_id = intval($send_to_id);
    if (!$exists) {
    $error_text = "$w_no_user";
    include($file_path."designes/".$design."/error_page.php");
    exit;
    }

    $u_ids = array();
    $u_names = array();
    $tmp_body = "";
    $tmp_subject = "";

    $info_message = "";

    if($message_id == "") {
    if ($send_to!="") {
    $user_to_search = $send_to;
    include($ld_engine_path."users_search.php");
    if (!count($u_ids)) $info_message = "".str_replace("~",""".htmlspecialchars($send_to).""",$w_search_no_found)."
    ";
    }
    if ($send_to_id!="") {
    include("inc_user_class.php");
    $ttt = $is_regist;
    $is_regist = $send_to_id; #fake again :(
    include($ld_engine_path."users_get_object.php");
    $u_ids[] = $is_regist;
    $is_regist = $ttt;
    $u_names[] = $current_user->nickname;
    }
    }
    else {
    $board_operation = "reply";
    $id = $message_id;
    include($ld_engine_path."board_process_message.php");
    $u_ids[] = $board_message["from_id"];
    $u_names[] = $board_message["from"];
    $tmp_body = str_replace("
    ","\n",$board_message["body"]);
    $tmp_body = "\n\n_______ ".str_replace("~", $board_message["from"], $w_user_wrote)." ______\n$tmp_body";
    $tmp_subject = str_replace("\"",""","Re: ".$board_message["subject"]);
    }

    include($file_path."designes/".$design."/board_send.php");

    Richard DeemingR 1 Reply Last reply
    0
    • A Aruna KN

      I'm trying to migrate my PHP code which is working on PHP 7.4 to PHP 8.1. With PHP 8.1, following

      if($message_id == "") {

      code is triggering for logged in users too. Can somebody point out common errors in this code?

      require_once("inc_common.php");
      include($engine_path."users_get_list.php");
      set_variable("message_id");
      set_variable("send_to");
      set_variable("send_to_id");
      $send_to_id = intval($send_to_id);
      if (!$exists) {
      $error_text = "$w_no_user";
      include($file_path."designes/".$design."/error_page.php");
      exit;
      }

      $u_ids = array();
      $u_names = array();
      $tmp_body = "";
      $tmp_subject = "";

      $info_message = "";

      if($message_id == "") {
      if ($send_to!="") {
      $user_to_search = $send_to;
      include($ld_engine_path."users_search.php");
      if (!count($u_ids)) $info_message = "".str_replace("~",""".htmlspecialchars($send_to).""",$w_search_no_found)."
      ";
      }
      if ($send_to_id!="") {
      include("inc_user_class.php");
      $ttt = $is_regist;
      $is_regist = $send_to_id; #fake again :(
      include($ld_engine_path."users_get_object.php");
      $u_ids[] = $is_regist;
      $is_regist = $ttt;
      $u_names[] = $current_user->nickname;
      }
      }
      else {
      $board_operation = "reply";
      $id = $message_id;
      include($ld_engine_path."board_process_message.php");
      $u_ids[] = $board_message["from_id"];
      $u_names[] = $board_message["from"];
      $tmp_body = str_replace("
      ","\n",$board_message["body"]);
      $tmp_body = "\n\n_______ ".str_replace("~", $board_message["from"], $w_user_wrote)." ______\n$tmp_body";
      $tmp_subject = str_replace("\"",""","Re: ".$board_message["subject"]);
      }

      include($file_path."designes/".$design."/board_send.php");

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      The only place that variable is mentioned prior to the test is the set_variable("message_id"); line. As far as I can see, that's not a built-in PHP function. So you need to check what that function is doing, and try to work out why its behaviour has changed in PHP 8. We can't do that for you, since we can't see the function.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      A 2 Replies Last reply
      0
      • Richard DeemingR Richard Deeming

        The only place that variable is mentioned prior to the test is the set_variable("message_id"); line. As far as I can see, that's not a built-in PHP function. So you need to check what that function is doing, and try to work out why its behaviour has changed in PHP 8. We can't do that for you, since we can't see the function.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        A Offline
        A Offline
        Aruna KN
        wrote on last edited by
        #3

        Thank you for the tip. I will check it

        1 Reply Last reply
        0
        • Richard DeemingR Richard Deeming

          The only place that variable is mentioned prior to the test is the set_variable("message_id"); line. As far as I can see, that's not a built-in PHP function. So you need to check what that function is doing, and try to work out why its behaviour has changed in PHP 8. We can't do that for you, since we can't see the function.


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          A Offline
          A Offline
          Aruna KN
          wrote on last edited by
          #4

          The issue has been resolved after adding null by replacing "" Old code:

          if ($send_to_id!="") {

          New code:

          if ($send_to_id!=null) {

          But will it do the same?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups