Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling errors and continuing execution in PHP script

Tags:

php

execution

die

I don't want to "die()" when it concerns only a small part of the script and I tried:

$result = mysql_query($sql) or echo("error with responses");

But it generated an error. How do I just give out an error message and continue to execute the rest of the script since even if it fails to connect, the rest should not be affected.

like image 543
netrox Avatar asked Dec 09 '22 08:12

netrox


1 Answers

$result = mysql_query($sql);
if(mysql_error()) {
  echo "Error: " . mysql_error();
}
like image 162
ceejayoz Avatar answered Dec 11 '22 23:12

ceejayoz