MySQL Forums
Forum List  »  PHP

Re: Why can't i connect to my sql database?
Posted by: Peter Brawley
Date: June 23, 2018 07:24AM

First, don't use the mysql API, it's removed in latest PHP versions. Use mysqli.

Second, every db call needs error handling, eg minimally ...

$db = mysqli_connect(...) or exit( mysqli_connect_error() );
...
$result = $db->query(...) or exit( $db->error );

The error will tell you what's not right.



Edited 1 time(s). Last edit at 06/23/2018 07:26AM by Peter Brawley.

Options: ReplyQuote


Subject
Written By
Posted
Re: Why can't i connect to my sql database?
June 23, 2018 07:24AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.