top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How to retrieve code of exception using Exception class in PHP when error occured?

+2 votes
61 views
How to retrieve code of exception using Exception class in PHP when error occured?
posted Jan 22, 2016 by Vrije Mani Upadhyay

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

In PHP 4 error handling in functions and methods was returned by the return command. Let´s say we would like to connect to a database via MySQLi inside a method or function. If the connection fails an error message and the error code should be displayed. In PHP 4 the error handling would have looked like this:

function connect_to_mysql()
{
$mysqli = @new mysqli('localhost', 'username', 'password', 'db_name');
if ($mysqli->connect_errno)
{
return false;}
return true;}

for more Information:http://www.lingulo.com/tutorials/php/error-handling-with-exceptions-in-php-5

answer Feb 23, 2016 by Rahul Singh
Similar Questions
+1 vote

I am trying to execute the following but he does not execute me well. Which will be able to be the problem?

$sql = "insert into scele (codigo, nombre) values (?, ?)";
$param = "1, Test1";

$tr = ibase_trans(IBASE_WRITE,$this->cn);
$qr = ibase_prepare($tr,$param);
$this->rs = ibase_execute($sql,$param);
if ($this->rs){
 //Evaluate this condition, but he does not enter here 
}
0 votes

I have an application running under PHP-5.4.17-TS-VC9 (and .14 as of yesterday) with Aprelium's Abyss X1 v2.8 web server in FastCGI mode on WinXPSP3.

An earlier version of this application works. The current version causes a 500 Internal Server Error. There is no entry in PHP's (fully active) error log. I cannot decipher Abyss's logging, so I cannot determine if a clue was reported by Abyss or not.

The current version works on a different system (Server 2003, PHP 5.3.5-TS-VC6 (Apache module), Apache 2.2).

What I would like to have is a method of getting PHP to report in some undeniable manner, short of total system failure, what it doesn't like about whatever killed it.

+5 votes

I Know that we can always fetch from one database server and rewrite it to another. But what is the simplest way to do this?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...