Hello all! New here and new to PHP. I have an old script that was built for PHP 5.X and need some help getting it to work with PHP 7.X. According to the PHP manual I need to pass the db connection as the first argument. I do get the display error "SQL Error: Can't select DB" and in the logs show "PHP Warning: mysqli_select_db() expects exactly 2 parameters, 1 given".
<?php
extract($_REQUEST);
$DB_HOST="localhost"; //Host
$DB_DATABASE="babyyoda"; //database name
$DB_USER="mando"; //database username
$DB_PASSWORD="password"; //databse password
$ADMIN_EMAIL='
[email protected]';
$TEMPLATES='./templates/';
$URL_BASE='http://example.com/banners/';
$PATH='/var/www/vhosts/example.com/httpdocs/banners/';
$BANNERS_PATH=$PATH.'banners/';
$BANNERS_URL=$URL_BASE.'banners/';
$DB_TABLE_CATEGORIES='ban_categories';
$DB_TABLE_SUBCATEGORIES='ban_subcategories';
$DB_TABLE_SUBCATEGORIES_BANNERS='ban_subcategories_banners';
$DB_TABLE_BANNERS='ban_banners';
$DB_TABLE_USERS='ban_users';
$DB_TABLE_SETTINGS='ban_settings';
$IMAGE_MAGICK_PATH='/usr/bin/';
//$IMAGE_MAGICK_PATH='/usr/local/bin/'; // on some servers it may be like this
$TEMPLATE_EXECUTE_PHP=1; // set to 1 to allow use of php inside of templates
$CRYPT_SALT='ef&dF%HGRTSvsw35';
$TYPES[1]='Jpeg';
$TYPES[2]='Gif';
$TYPES[3]='Flash'; // dont change flash should be "3"
//$LINKED_SCRIPTS['Galleries Manager']='/galleries/admin/';
//$LINKED_SCRIPTS['Flash Manager']='/flash/admin/';
$NATS=0;
//$PASS_VARIABLES=array('campaign','program');
define('CONFIG_INCLUDED',1);
mysqli_connect($DB_HOST, $DB_USER, $DB_PASSWORD) or die("SQL ERROR: Can't Connect to DB");
mysqli_select_db($DB_DATABASE) or die("SQL ERROR: Can't select DB");
error_reporting(0);
ini_set('session.gc_maxlifetime',3600);
?>
I came up with the below but I don't know where to insert these two statements and what to remove.
$link = mysqli_connect($DB_HOST, $DB_USER, $DB_PASSWORD);
mysqli_select_db($link, $DB_DATABASE);