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. PHP isset for an Array

PHP isset for an Array

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
helpquestionphpdata-structuresannouncement
8 Posts 2 Posters 37 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

    Previously with help of this forum I was able to fix Undefined variable errors using if(isset()) for PHP 8.1. But this time I was unable to use if(isset()) to fix this error_log: PHP Warning: Undefined variable $sendid in /home/____/check.php on line 70 Code line 70 is

    printm($str.$sendid);

    As above line connected with an array, how can I use isset? Please suggest me a solution. Full code is given below:

    DATE_SUB(NOW(), INTERVAL ".C_REG_DAYS." DAY)");
    $row=mysqli_fetch_array($temp);
    $count = $row['total'];
    if($count != '0') {
    mysqli_query($conn,"DELETE FROM ".C_MYSQL_TEMP." WHERE id='".$id."' AND code='".$code."'");
    if(C_CHECK_REGISTER == '3') {
    $status='1';
    $str=$w[159];
    }
    else {
    $status='7';
    $str = $w[46];
    }
    mysqli_query($conn,"UPDATE ".C_MYSQL_MEMBERS." SET status='".$status."' WHERE id='".$id."'");
    $result = mysqli_query($conn,'SELECT email, password FROM '.C_MYSQL_MEMBERS.' WHERE id = \''.$id.'\'');
    while($i=mysqli_f

    L 1 Reply Last reply
    0
    • A Aruna KN

      Previously with help of this forum I was able to fix Undefined variable errors using if(isset()) for PHP 8.1. But this time I was unable to use if(isset()) to fix this error_log: PHP Warning: Undefined variable $sendid in /home/____/check.php on line 70 Code line 70 is

      printm($str.$sendid);

      As above line connected with an array, how can I use isset? Please suggest me a solution. Full code is given below:

      DATE_SUB(NOW(), INTERVAL ".C_REG_DAYS." DAY)");
      $row=mysqli_fetch_array($temp);
      $count = $row['total'];
      if($count != '0') {
      mysqli_query($conn,"DELETE FROM ".C_MYSQL_TEMP." WHERE id='".$id."' AND code='".$code."'");
      if(C_CHECK_REGISTER == '3') {
      $status='1';
      $str=$w[159];
      }
      else {
      $status='7';
      $str = $w[46];
      }
      mysqli_query($conn,"UPDATE ".C_MYSQL_MEMBERS." SET status='".$status."' WHERE id='".$id."'");
      $result = mysqli_query($conn,'SELECT email, password FROM '.C_MYSQL_MEMBERS.' WHERE id = \''.$id.'\'');
      while($i=mysqli_f

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      The variable $sendid is not defined anywhere at module level, it is local to the following switch block:

      switch (C_ID) {

      case '2':
      $sendid=$i['email'];
      break;
      default:
      $sendid=$id;
      break;
      }

      So once that block ends the variable no longer exists. Change it to something like:

      $sendid = '';
      switch (C_ID) {
      global $sendid; // tell switch to use the global variable
      case '2':
      $sendid=$i['email'];
      break;
      default:
      $sendid=$id;
      break;
      }

      You may like to review PHP: Variable scope - Manual[^].

      A 1 Reply Last reply
      0
      • L Lost User

        The variable $sendid is not defined anywhere at module level, it is local to the following switch block:

        switch (C_ID) {

        case '2':
        $sendid=$i['email'];
        break;
        default:
        $sendid=$id;
        break;
        }

        So once that block ends the variable no longer exists. Change it to something like:

        $sendid = '';
        switch (C_ID) {
        global $sendid; // tell switch to use the global variable
        case '2':
        $sendid=$i['email'];
        break;
        default:
        $sendid=$id;
        break;
        }

        You may like to review PHP: Variable scope - Manual[^].

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

        I tried using your code suggestion but when user recieved verification email and clicked on verify link, it gives "HTTP ERROR 500". Also error_log has following: PHP Parse error: syntax error, unexpected 'global' (T_GLOBAL), expecting case (T_CASE) or default (T_DEFAULT) or '}'

        L 1 Reply Last reply
        0
        • A Aruna KN

          I tried using your code suggestion but when user recieved verification email and clicked on verify link, it gives "HTTP ERROR 500". Also error_log has following: PHP Parse error: syntax error, unexpected 'global' (T_GLOBAL), expecting case (T_CASE) or default (T_DEFAULT) or '}'

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          HTTP status 500 is an internal server error. So you need to look at your server logs, and maybe even add some debug code to find out what is going wrong. Is this your code or did someone else write it?

          A 1 Reply Last reply
          0
          • L Lost User

            HTTP status 500 is an internal server error. So you need to look at your server logs, and maybe even add some debug code to find out what is going wrong. Is this your code or did someone else write it?

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

            Actually this code was written by an outside person. I will check this further.

            A L 2 Replies Last reply
            0
            • A Aruna KN

              Actually this code was written by an outside person. I will check this further.

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

              Actually issue has been fixed after adding your code suggestion to another place in the same PHP file:

              $tm=array($sendid,'____',C_SNAME);
              $message=template($w[588],$tm);
              sendmail(C_FROMM,$i['email'],$subject,$message,'text');
              }
              $sendid = '';
              global $sendid;
              printm($str.$sendid);
              }

              1 Reply Last reply
              0
              • A Aruna KN

                Actually this code was written by an outside person. I will check this further.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Udaya Arunakantha wrote:

                this code was written by an outside person.

                Then you have my sympathy. I have faced similar issues in the past and it is never easy.

                A 1 Reply Last reply
                0
                • L Lost User

                  Udaya Arunakantha wrote:

                  this code was written by an outside person.

                  Then you have my sympathy. I have faced similar issues in the past and it is never easy.

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

                  You are correct Richard, it's bit hard but your code suggestion worked for another code line in the same PHP code, see my last reply.

                  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