Arijanit Nitti Salihu
Arijanit Nitti Salihu

Reputation: 112

why can't I connect to mysql with uwamp,

/* Please input your sql-connection correctly

Made by Nitti
*/

$sqlHost = 'localhost';
$sqlUser = 'root';
$sqlPass = '';

// Please don't change anything below
mysql_connect($sqlHost, $sqlUser, $sqlPass) or die('Could not connect to the mysqlserver ('.mysql_error().')');

mysql_select_db('db_nit')
;

and as a result

Fatal error: Call to undefined function mysql_connect() in C:\UwAmp\www\admin\php\connectDb.php on line 13

I'm using `

Apache 2.2.24 (with SSL) MySQL 5.6.11 PHP (5.3.25 / 5.4.15) with Xdebug 2.2.0 PHPMyAdmin 4.0.2

`

Upvotes: 1

Views: 6724

Answers (3)

RonLugge
RonLugge

Reputation: 5174

Using mysql_connect has been depreciated for a long time. At a guess, they finally got rid of the feature entirely in your version, given that you're receiving an undefined function error.

As another poster also added, you should use either mysqli_* functions, or better yet the PDO library. I strongly recommend the PDO library, but the mysqli library does work as well.

The PDO library will give you the advantage of making your database object oriented and properly abstract away the actual database, giving you the freedom to eventually move onto other databases if the program requires. It might look like a little bit of work to learn, but it's much easier than you think once you dig into it and really start using it.

Upvotes: 0

Guillaume
Guillaume

Reputation: 36

Default UwAmp MySQL password is "root".

$sqlHost = 'localhost';
$sqlUser = 'root';
$sqlPass = 'root';

Upvotes: 1

immulatin
immulatin

Reputation: 2118

mysql_* functions were deprecated and will then removed from PHP. You need to use the mysqli_* functions or PDO for database operations now.

See PDO manual: http://php.net/manual/en/book.pdo.php

See mysqli manual: http://php.net/manual/en/book.mysqli.php

Upvotes: 1

Related Questions