A
A
Alexey Goncharov2020-10-13 08:18:38
PHP
Alexey Goncharov, 2020-10-13 08:18:38

Can't connect to database on OpenServer. How to solve it?

I can't put my site on Openserver. phpmyadmin has a database called qwerty.
Here is a line from index.php:
if (!mysql_connect($sub_opt['db_serv'], $sub_opt['db_user'], $sub_opt['db_pass'])) { die('Error connecting to database.'); }
if (!mysql_select_db($sub_opt['db_name'])) { die('Error choosing database.'); }

And here are the lines from config.php:

$sub_opt['db_serv'] = 'localhost';
$sub_opt['db_name'] = 'qwerty';
$sub_opt['db_user'] = 'root';
$sub_opt['db_pass'] = 'root';

Importing this file into index.php is worth it. Everything seems to be right, but when I launch my site, I get an error:

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in D:\qwerty\open_server_5_3_7_basic_full\OpenServer\domains\qwerty\index.php:22 Stack trace: #0 {main} thrown in D:\grazvalda\open_server_5_3_7_basic_full\OpenServer \domains\qwerty\index.php on line 22

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2020-10-13
@asd1982

mysql_connect is deprecated, use mysqli_connect

F
FanatPHP, 2020-10-13
@FanatPHP

Learning to use the Internet

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question