Reputation: 1365
I am trying to migrate an application from PHP 5.2.X to PHP 5.4.4 and I am having a few problems related to how the app connects to the database.
The new server fails on this line:
$this->db = @mysql_pconnect(_DBHOST,_DBUSER,_DBPASS);
I know that the new versions have changed the way the apps connect to the database but I have been trying to connect with other methods and I couldn't. I think it should be related to the server configuration which can be found here: http://bit.ly/S2px7Q
What I see is that mysqlnd is installed but not the mysql, mysqli or PDO. Is that correct?
Upvotes: 0
Views: 4326
Reputation: 168735
If you're getting Undefined Function
errors, then it means that the mysql
library is not installed in your copy of PHP.
This may actually be a good thing, because this particular library is considered obsolete. PHP provides at least two good alternatives which are recommended to use instead.
I recommend that you switch all your mysql_xxx()
function calls for the equivalent mysqli_xxx()
calls.
This will allow you to start using a better library with minimal code changes. You could also use the PDO library, but that would involve more work if you're dealing with existing code.
Upvotes: 1
Reputation:
I agree, try PDO
$this->db = new PDO("mysql:host=localhost;dbname=mysql", "root", "password");
$this->statement = $db->query('SELECT first_name, last_name FROM users;');
$this->users = $this->statement->fetchAll(PDO::FETCH_ASSOC);
Upvotes: 0