0

i'm using php 5.2.17 and i'm getting an error on a the following code...

if (USE_PCONNECT == 'true') {
  $$link = mysql_pconnect($server, $username, $password);
} else {
  $$link = mysql_connect($server, $username, $password);
}

The error i'm getting is...

Fatal error: Call to undefined function mysql_connect() in C:\Domains\domain.com\wwwroot\catalogue2\includes\functions\database.php on line 19

I have recently migrated this site from an older server so I suspect its the version of php. Sadly i'm not that knowledgeable with php. Does anyone have any ideas?

Thanks

elixireu
  • 245
  • 3
  • 14

2 Answers2

2

PHP 5.2 does not support mysql_connect. It is now outdated..

use mysqli_connect();

But if u still prefer to use mysql Uncomment the line "extension=php_mysql.dll" in your "php.ini" file and restart Apache.

Additionally, "libmysql.dll" file must be available to Apache, i.e., it must be either in available in Windows systems PATH or in Apache working directory.

SO-user
  • 1,398
  • 1
  • 19
  • 40
1
mysql_connect($server, $username, $password);

there is no database name specified in mysql_connect();

$con = mysqli_connect("localhost","my_user","my_password","my_db");

you can use mysqli_connect instead also

siddhesh
  • 1,365
  • 1
  • 10
  • 16
  • Hi, I have now changed it to... function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') { global $$link; $$link = mysqli_connect("localhost","my_user","my_password","my_db"); if ($$link) mysql_select_db($database); return $$link; } function tep_db_close($link = 'db_link') { global $$link; return mysql_close($$link); } – elixireu Feb 21 '15 at 12:41