Php + mysql Fatal error: call to undefined function mysql_connect () in

I searched the Internet for troubleshooting using this function "Calling the undefined function mysql_connect ()", but none of the suggested procedures work ...

When I try to access mysql from php, I get this error. I have PHP version 5.2.17 and MySQL 5.1.68 (mysql works outside of php, I tried to create tables and databases, etc.).

I will uncomment the extensions in php.ini:

extension=php_mysql.dll
extension=php_mysqli.dll

and pointed the way to these extensions.

I also added PHP and MySQL to my PATH variable. I am using Apache 2.2. and I restarted the server after every change I made.

This is my php code to access the database (but I suppose the problem is not in the syntax):

<?php     
      $dbhost = 'localhost';
      $dbuser = 'root';
      $dbpass = 'pasw';
      $dbname = 'db';

      $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
      mysql_select_db($dbname);
?>

, , ? ... MySQL, , . !

EDIT: apache:

[Mon Mar 25 13:50:42 2013] [error] [client 127.0.0.1] PHP Fatal error:  Call to undefined function mysql_connect() in C:\\Web\\thenemis\\dbconnect.php on line 7, referer: http://localhost/thenemis/admin.php
[Mon Mar 25 13:50:42 2013] [error] [client 127.0.0.1] File does not exist: C:/Web/favicon.ico

EDIT2: php- ( , php.ini). , , , , , ... ?

mysql

MySQL Support   enabled
Active Persistent Links 0
Active Links    0
Client API version  5.0.51a

Directive   Local Value Master Value
mysql.allow_persistent  On  On
mysql.connect_timeout   60  60
mysql.default_host  no value    no value
mysql.default_password  no value    no value
mysql.default_port  no value    no value
mysql.default_socket    no value    no value
mysql.default_user  no value    no value
mysql.max_links Unlimited   Unlimited
mysql.max_persistent    Unlimited   Unlimited
mysql.trace_mode    Off Off
+5
4

, phpinfo() mysql. , mysql, mysql, mysqli http://php.net/manual/de/book.mysqli.php

, method_exists

+6

:

$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'pasw';
$dbname = 'db';

<?php
// Create connection
$con=mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);

// Check connection
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
?>

MySQL PHP, MySQLi PDO.

:)

+3

, PHP mysql. php , <?php phpinfo(); exit(); ?>, . 'MySQL'. , PHP MySQL PHP, .

.

sudo apt-get install mysql-server

PHP, php- mysql

sudo apt-get install php5-mysql
+2

PHP , C:/program files/php;   extension=php_mysqli.dll php.ini.

mysqli_connect($host,$username,$password)or die(mysql_error()); 

. ; , .

0

All Articles