1

Anyone knows what is wrong with my config code? I'm just a beginner in PHP so here's my error


Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\XAMPP\htdocs\gas_php\config.php:10

Stack trace:

0 - C:\XAMPP\htdocs\gas_php\checkbanned.php(7): include()

1 - {main} thrown in C:\XAMPP\htdocs\gas_php\config.ph

Worked all night long to come up with this:

<?php

$db_host        =    'localhost';

$db_user         =     'root';

$db_password     =     '';
$db_name        =    'accounts';  

$connect     =     mysql_connect($db_host,$db_user,$db_password) or die(mysql_error());
$select     =     mysql_select_db($db_name) or die(mysql_error());  
mysql_query("set character_set_server='utf8'");
mysql_query("set names 'utf8'");
?>
Community
  • 1
  • 1
Marky
  • 33
  • 1
  • 6

1 Answers1

1

Your error

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\XAMPP\htdocs\gas_php\config.php:10

Says that mysql_connect is an undefined function.

By looking at PHP Manual - mysql_connect you can see that this function was removed in PHP 7.0. So if you're using PHP 7.0 or higher, this function is unavailable.

You should use instead the function mysqli_connect

David Alves
  • 398
  • 5
  • 19