Jump to content

unable to see last line of code


fonrob1

Recommended Posts

can someone help me figure out why my code will not see the last line eg echo '<div class="div-center">'.$prev_button.$next_button.'</div>';

 

 
                                   <h2>5.0 ESB Interface Failures (Total: '.$num_esb.')</h2>
                                   <hr/>';
                       
                  }
               
                  
                 if($num_esb > '0')
                    {
                    echo '<table class="data" style="margin-bottom:50px;">
                          <tr>
                          <th style="width:6%">  Ticket                                            </th>
                          <th style="width:8%">  Date                                              </th>
                          <th style="width:6%">  Time                                              </th>
                          <th style="width:8%">  Schedule                                          </th>
                          <th style="width:40%"> ESB Process                                       </th>
                          <th style="width:6%">  Critical                                          </th>
                          <th style="width:6%">  Restarted                                         </th>
                          <th style="width:6%">  Completed                                         </th>
                          <th style="width:7%">  Type                                              </th>
                          <th style="width:5%">  Operator                                          </th>
                          </tr>';
 
                          WHILE($row3 = MYSQL_FETCH_ARRAY($esbresult))
                                {
                                $abendid           =    $row3['ID'];
                                $date_start        =    $row3['Abend_Date'];
                                $ticket            =    $row3['Ticket'];
                                $time_start        =    SUBSTR($row3['Abend_Time'], 0, 5);
                                $batch_schedule    =    $row3['Batch_Schedule'];
                                $esb_process       =    $row3['esb_process'];
                                $request_details   =    NL2BR($row3['Error']);
                                $resolution        =    NL2BR($row3['Resolution']);
                                $created_username  =    $row3['Created_Username'];
                                $created_timestamp =    $row3['Created_Timestamp'];
                                $edited_username   =    $row3['edited_username'];
                                $edited_timestamp  =    $row3['edited_timestamp'];
                                $critical          =    $row3['Critical'];
                                $restarted         =    $row3['Restarted']; 
                                $resolved          =    $row3['Resolved'];
                                $cause             =    $row3['Failure_Type'];
                                
                                $criticalcolor  = $critical  == 'Y' ? '#C12603' : '#01C425';
                                $restartedcolor = $restarted == 'N' ? '#C12603' : '#01C425';
                                $resolvedcolor  = $resolved  == 'N' ? '#C12603' : '#01C425';
                                $restartedcolor = $restarted == 'N' ? '#C12603' : '#01C425';
                                $altcolor       = $altcolor  == 'rowcolor2' ? 'rowcolor1' : 'rowcolor2';
 
                                echo              '<tr class="'.$altcolor.'">
                                                   <td class="text_center">'.$ticket.'</td>
                                                   <td class="text_center">'.$date_start.'</td>
                                                   <td class="text_center">'.$time_start.'</td>
                                                   <td class="text_center"><a href="index.php?p=10&date='.$batch_schedule.'" title="Go to batch schedule">'.$batch_schedule.'</a></td>
                                                   <td class="text_left">
                                                   <a href="index.php?p=58&id='.$abendid.'">'.$esb_process.'</a><br/><a href="index.php?p=58&id='.$abendid.'"></a></td>
                                                   <td class="text_center" style="background-color:'.$criticalcolor.'">'.$critical.'</td>
                                                   <td class="text_center" style="background-color:'.$restartedcolor.'">'.$restarted.'</td>
                                                   <td class="text_center" style="background-color:'.$resolvedcolor.'">'.$resolved.'</td>
                                                   <td class="text_center">'.$cause.'</td>
                                                   <td class="text_center">'.$created_username.'</td>
                                                   </tr>';
                                                                                   }
                             echo '</table>
                             <hr/>';
 
                             echo '<div class="div-center">'.$prev_button.$next_button.'</div>';
 
                    }
 
?>
Link to comment
Share on other sites

Did you mean to say "my code will not show the last line"?

 

How do you know it is not showing it? What do you expect to see? You haven't shown us what the values of prev_button and next_button are so that line as far as we can judge wouldn't display anything, unless your div has a border on it.

Link to comment
Share on other sites

the code in question is now inside a conditional statement if($num_esb > '0'){    ... }. in the original, it was not. it was outside of and after the end of the conditional statement.

 

you need to update the msyql_ statements to something more current. the msyql_ extension has been removed from php and your code won't run at all on current php versions. the PDO extension is the best choice to switch to.

 

while you are making the changes necessary to keep the database code working, you should clean up all the repetitive code and consider using a template to produce the html document. you currently have a "cannot see the forest for the trees problem", which is one reason you missed putting the pagination links in the right place in the changed logic. the file has 670 lines of code, of which there is probably only about 400 lines that are needed.

Link to comment
Share on other sites

You can also save a lot of code when you stop creating useless variables for values that are readily available through existing variables. For example, whenever you fetch a row, you somehow copy every single field into an extra variable. Why would you do that? You already have the row.

 

This really looks more like a typing exercise than code. Programming is about avoiding repetition. When you find yourself doing the same thing over and over again for hundreds of lines of code, that means you need to stop and look for a smarter solution. This just doesn't happen in a proper script.

 

And then there's the total lack of security. I haven't found a single instance of SQL-escaping or HTML-escaping. You just drop the user input straight into your queries and the HTML markup. Do you not understand how dangerous this is? Have you never heard of SQL injections and cross-site scripting?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.