-2

GOAL

I am trying to create a web app that will access to my database, and be able to SELECT, INSERT, UPDATE and DELETE records.


PROBLEM

I cannot connect to the database server


ERROR

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in
C:\Users\********\Desktop\CS\GitHub\scheduler-v2\scheduler-v2-
master\test.php:15

CODE

<?php
$myServer = "localhost";
$myUser = "root";
$myPass = "*******";
$myDB = "scheduler";

$conn = mysql_connect($myServer,$myUser,$myPass);
if (!$conn) {
    die('Not connected : ' . mssql_get_last_message());
}
?>

What I've Tried

-I added the php_sqlsrv_56.ts.dll file to the extensions folder of PHP.

-I also added the extension=php_sqlsrv_56.ts.dll line to the php.ini file.

-I uncommented extension=php_mysqli.dll and extension=php_mysql.dll from the php.ini file.

I have looked at many posts and they have not helped. I am running Windows 10 x86 and PHP 7. Any ideas where I am going wrong/what I am missing to connect to the database?

EDIT: The error was that I was trying to use a deprecated method, mysql_connect, instead of the new mysqli_connect that it has been replaced with

Bob Bobby
  • 21
  • 3

1 Answers1

2

The error was that I was trying to use a deprecated method, mysql_connect, instead of the new mysqli_connect that it has been replaced with. For PHP versions 7 and onward, use MySQLi_connect().

Bob Bobby
  • 21
  • 3