3v4l.org

run code in 300+ PHP versions simultaneously
<?php $link = mysql_connect('localhost','root','root'); mysql_select_db("goal_database",$link); if (isset($_GET["pid"]) && isset($_GET["week"])) { $pid = intval($_GET["pid"]); $week = intval($_GET["week"]); $response = array(); $response["meals"] = array(); // Mysql select query $result = mysql_query("SELECT * FROM Meals WHERE ParticipantID=$pid AND WeekNumber=$week;"); while($row = mysql_fetch_array($result)){ $tmp = array(); $tmp["mid"] = $row["ActivityID"]; $tmp["pid"] = $row["ParticipantID"]; $tmp["week"] = $row["WeekNumber"]; $tmp["day"] = $row["Day"]; $tmp["type"] = $row["Type"]; $tmp["image"] = $row["ImagePath"]; $tmp["comments"] = $row["Comments"]; $tmp["grain"] = $row["GrainAmount"]; $tmp["protein"] = $row["ProteinAmount"]; $tmp["dairy"] = $row["DairyAmount"]; $tmp["vegetable"] = $row["VegetableAmount"]; $tmp["fruit"] = $row["FruitAmount"]; $tmp["attic"] = $row["AtticAmount"]; array_push($response["meals"], $tmp); } // keeping response header to json header('Content-Type: application/json'); // echnoing json result echo json_encode($response); if (mysql_errno()) { $error = "MySQL error ".mysql_errno().": ".mysql_error()."\n<br>When executing:<br>\n$query\n<br>"; echo $error; } } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 111
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 83
Branch analysis from position: 83
2 jumps found. (Code = 44) Position 1 = 88, Position 2 = 38
Branch analysis from position: 88
2 jumps found. (Code = 43) Position 1 = 98, Position 2 = 111
Branch analysis from position: 98
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 111
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 88, Position 2 = 38
Branch analysis from position: 88
Branch analysis from position: 38
Branch analysis from position: 111
Branch analysis from position: 16
filename:       /in/OWZna
function name:  (null)
number of ops:  112
compiled vars:  !0 = $link, !1 = $pid, !2 = $week, !3 = $response, !4 = $result, !5 = $tmp, !6 = $row, !7 = $error, !8 = $query
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL_BY_NAME                                       'mysql_connect'
          1        SEND_VAL_EX                                              'localhost'
          2        SEND_VAL_EX                                              'root'
          3        SEND_VAL_EX                                              'root'
          4        DO_FCALL                                      0  $9      
          5        ASSIGN                                                   !0, $9
    3     6        INIT_FCALL_BY_NAME                                       'mysql_select_db'
          7        SEND_VAL_EX                                              'goal_database'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
    4    10        FETCH_IS                                         ~12     '_GET'
         11        ISSET_ISEMPTY_DIM_OBJ                         0  ~13     ~12, 'pid'
         12      > JMPZ_EX                                          ~13     ~13, ->16
         13    >   FETCH_IS                                         ~14     '_GET'
         14        ISSET_ISEMPTY_DIM_OBJ                         0  ~15     ~14, 'week'
         15        BOOL                                             ~13     ~15
         16    > > JMPZ                                                     ~13, ->111
    6    17    >   FETCH_R                      global              ~16     '_GET'
         18        FETCH_DIM_R                                      ~17     ~16, 'pid'
         19        CAST                                          4  ~18     ~17
         20        ASSIGN                                                   !1, ~18
    7    21        FETCH_R                      global              ~20     '_GET'
         22        FETCH_DIM_R                                      ~21     ~20, 'week'
         23        CAST                                          4  ~22     ~21
         24        ASSIGN                                                   !2, ~22
    8    25        ASSIGN                                                   !3, <array>
    9    26        ASSIGN_DIM                                               !3, 'meals'
         27        OP_DATA                                                  <array>
   11    28        INIT_FCALL_BY_NAME                                       'mysql_query'
         29        ROPE_INIT                                     5  ~27     'SELECT+%2A+FROM+Meals+WHERE+ParticipantID%3D'
         30        ROPE_ADD                                      1  ~27     ~27, !1
         31        ROPE_ADD                                      2  ~27     ~27, '+AND+WeekNumber%3D'
         32        ROPE_ADD                                      3  ~27     ~27, !2
         33        ROPE_END                                      4  ~26     ~27, '%3B'
         34        SEND_VAL_EX                                              ~26
         35        DO_FCALL                                      0  $30     
         36        ASSIGN                                                   !4, $30
   12    37      > JMP                                                      ->83
   13    38    >   ASSIGN                                                   !5, <array>
   14    39        FETCH_DIM_R                                      ~34     !6, 'ActivityID'
         40        ASSIGN_DIM                                               !5, 'mid'
         41        OP_DATA                                                  ~34
   15    42        FETCH_DIM_R                                      ~36     !6, 'ParticipantID'
         43        ASSIGN_DIM                                               !5, 'pid'
         44        OP_DATA                                                  ~36
   16    45        FETCH_DIM_R                                      ~38     !6, 'WeekNumber'
         46        ASSIGN_DIM                                               !5, 'week'
         47        OP_DATA                                                  ~38
   17    48        FETCH_DIM_R                                      ~40     !6, 'Day'
         49        ASSIGN_DIM                                               !5, 'day'
         50        OP_DATA                                                  ~40
   18    51        FETCH_DIM_R                                      ~42     !6, 'Type'
         52        ASSIGN_DIM                                               !5, 'type'
         53        OP_DATA                                                  ~42
   19    54        FETCH_DIM_R                                      ~44     !6, 'ImagePath'
         55        ASSIGN_DIM                                               !5, 'image'
         56        OP_DATA                                                  ~44
   20    57        FETCH_DIM_R                                      ~46     !6, 'Comments'
         58        ASSIGN_DIM                                               !5, 'comments'
         59        OP_DATA                                                  ~46
   21    60        FETCH_DIM_R                                      ~48     !6, 'GrainAmount'
         61        ASSIGN_DIM                                               !5, 'grain'
         62        OP_DATA                                                  ~48
   22    63        FETCH_DIM_R                                      ~50     !6, 'ProteinAmount'
         64        ASSIGN_DIM                                               !5, 'protein'
         65        OP_DATA                                                  ~50
   23    66        FETCH_DIM_R                                      ~52     !6, 'DairyAmount'
         67        ASSIGN_DIM                                               !5, 'dairy'
         68        OP_DATA                                                  ~52
   24    69        FETCH_DIM_R                                      ~54     !6, 'VegetableAmount'
         70        ASSIGN_DIM                                               !5, 'vegetable'
         71        OP_DATA                                                  ~54
   25    72        FETCH_DIM_R                                      ~56     !6, 'FruitAmount'
         73        ASSIGN_DIM                                               !5, 'fruit'
         74        OP_DATA                                                  ~56
   26    75        FETCH_DIM_R                                      ~58     !6, 'AtticAmount'
         76        ASSIGN_DIM                                               !5, 'attic'
         77        OP_DATA                                                  ~58
   28    78        INIT_FCALL                                               'array_push'
         79        FETCH_DIM_W                                      $59     !3, 'meals'
         80        SEND_REF                                                 $59
         81        SEND_VAR                                                 !5
         82        DO_ICALL                                                 
   12    83    >   INIT_FCALL_BY_NAME                                       'mysql_fetch_array'
         84        SEND_VAR_EX                                              !4
         85        DO_FCALL                                      0  $61     
         86        ASSIGN                                           ~62     !6, $61
         87      > JMPNZ                                                    ~62, ->38
   31    88    >   INIT_FCALL                                               'header'
         89        SEND_VAL                                                 'Content-Type%3A+application%2Fjson'
         90        DO_ICALL                                                 
   34    91        INIT_FCALL                                               'json_encode'
         92        SEND_VAR                                                 !3
         93        DO_ICALL                                         $64     
         94        ECHO                                                     $64
   36    95        INIT_FCALL_BY_NAME                                       'mysql_errno'
         96        DO_FCALL                                      0  $65     
         97      > JMPZ                                                     $65, ->111
   37    98    >   INIT_FCALL_BY_NAME                                       'mysql_errno'
         99        DO_FCALL                                      0  $66     
        100        CONCAT                                           ~67     'MySQL+error+', $66
        101        CONCAT                                           ~68     ~67, '%3A+'
        102        INIT_FCALL_BY_NAME                                       'mysql_error'
        103        DO_FCALL                                      0  $69     
        104        CONCAT                                           ~70     ~68, $69
        105        ROPE_INIT                                     3  ~72     '%0A%3Cbr%3EWhen+executing%3A%3Cbr%3E%0A'
        106        ROPE_ADD                                      1  ~72     ~72, !8
        107        ROPE_END                                      2  ~71     ~72, '%0A%3Cbr%3E'
        108        CONCAT                                           ~74     ~70, ~71
        109        ASSIGN                                                   !7, ~74
   38   110        ECHO                                                     !7
   41   111    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.44 ms | 1396 KiB | 19 Q