dimanche 27 mars 2016

If statement not running after extra code added in PHP

Hi everyone I am new to PHP and I am trying to debug but getting a problem. When I run my script it works fine and the IF statement runs correctly to tell me my password is incorrect but then when I add code below it, I no longer get the error message. I am not sure whether the screen is being cleared or the IF statement for some reason is not run. Example below

This runs fine and as the password is incorrect the IF statement runs and tells me password is incorrect.

<?php
$con = mysqli_connect("localhost","Username","IncorrectPassword","DBName");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  exit();
  }      
?>

Now the same code again but with some more added below it I no longer get the error message to say the IF statement has run and the password is incorrect.

<?php
$con = mysqli_connect("localhost","Username","IncorrectPassword","DBName");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  exit();
  }
$files = glob('*.mp3");
usort ($files, function ($a, $b) {
       return filemtime($a) < filemtime($b);
});       
?>

Thanks

Aucun commentaire:

Enregistrer un commentaire