0

I have a script I am trying to install on XAMPP but I am getting this error:

Fatal error: Uncaught Error: Call to undefined function mysql_select_db() in D:\xampp\htdocs\extend\install\step_1.php:44

Stack trace: #0 {main} thrown in D:\xampp\htdocs\extend\install\step_1.php on line 44

My line 44 is

    if (@mysql_connect($_POST['hostname'], $_POST['username'], 
    $_POST['password']) && mysql_select_db($_POST['dbname']))

I am suspecting the scripts connection was MySQL Any help to get around this?

Dharman
  • 26,923
  • 21
  • 73
  • 125
  • If you are running PHP7 or greater there IS NO `mysql` database extension any more. Its been removed – RiggsFolly Sep 14 '17 at 11:06
  • Using values from the `$_POST` array as parameters to a database connection is about as dangerous as it gets. _Maybe you should not be installing this script !!!!_ – RiggsFolly Sep 14 '17 at 11:08
  • Also, any script you see that uses the `@` error silencer should be considered **SUSPECT** right from the get go – RiggsFolly Sep 14 '17 at 11:10
  • Does this answer your question? [Undefined function mysql\_connect()](https://stackoverflow.com/questions/13825108/undefined-function-mysql-connect) – Dharman Oct 14 '21 at 22:03

1 Answers1

0

this will help

 if (@mysqli_connect($_POST['hostname'], $_POST['username'], 
$_POST['password']) && mysqli_select_db($_POST['dbname']))

mysqli_*() is the modern way to access a MySQL database via PHP.

user223321
  • 170
  • 1
  • 14
  • Why should the OP ___Do this___? **Good answers** will always have an explanation of what was done and why it was done that way, not only for the OP but for future visitors to SO that may find this question and be reading your answer. – RiggsFolly Sep 14 '17 at 11:09
  • @RiggsFolly okay thanks for your comment .I will keep this in my mind – user223321 Sep 14 '17 at 11:14
  • thanks @Abhislek. i i got through and hit this. i had this other error........Warning: mysqli_query() expects parameter 1 to be mysqli, string given in D:\xampp\htdocs\extend\install\step_2.php on line 147..and some also online 149 .. line 149 is mysql_select_db($session->get('dbname'), $connection); – Michelle Dimwaite Sep 14 '17 at 11:36
  • It means first parameter must be connection details of your db. If you pass any other variable this error will be shown. take a look -> http://php.net/manual/en/mysqli.query.php ->http://php.net/mysqli_select_db – user223321 Sep 14 '17 at 11:51