-1

I am trying to connect database using PHP and Apache2 server but it could not connect. I am providing my code below.

<?php
session_start();

$_SESSION['start'] = time();
$_SESSION['show_session_alert'] = 1;

$VIEW_ADMIN = 1;
$VIEW_OWNER = 2;

$con = mysql_connect("localhost", "root", "abcdefg");
mysql_select_db('easyride', $con);

$connect = mysqli_connect("localhost", "root", "abcdefg", "easyride");
?>

I am trying to connect to MySQL database but it could not connected. I am giving below the phpMyAdmin configuration file.

/etc/phpmyadmin/config-db.php:

$dbuser='phpmyadmin';
$dbpass='abcdefg';
$basepath='';
$dbname='phpmyadmin';
$dbserver='';
$dbport='';
$dbtype='mysql';

Here I am unable to connect getting the error localhost is currently unable to handle this request: HTTP ERROR 500. I need to connect to my MySQL database.

halfer
  • 19,824
  • 17
  • 99
  • 186
satya
  • 3,508
  • 11
  • 50
  • 130
  • 2
    why you are using mysql and mysqli on same file – NanThiyagan Jan 19 '18 at 09:47
  • Ok let me to keep any one and check . – satya Jan 19 '18 at 09:50
  • As the other comment says, why is there a mysqli and mysql connection together. Does not make much sense. Try to remove one or the other and check for yourself if it works. It might be a connection error most probably. I had the same error message yesterday but with different problem. So it should be the connection. – GSquadron Jan 19 '18 at 09:51
  • Ok let me get this correct, the first snippet is your server code right ? and the one below is the config file for phpmyadmin. Both could have different reasons for not being able to connect to the DB, your PHP file is attempting two different ways to connect to the db as mentioned above, and PHPmyadmin could fail for many reasons, fixing one will not probably fix the other issue as well. Btw, Check if you have included PHPmyadmin's config file in apache's config file – Vishnu Nair Jan 19 '18 at 09:58
  • what is the php version? Remember to @Niner me if you want more help or ping others. – Funk Forty Niner Jan 19 '18 at 11:17
  • Never mind the above, seeing your past question https://stackoverflow.com/q/48319731/ is php 7. The mysql_ api was deleted in that version. – Funk Forty Niner Jan 19 '18 at 11:21

1 Answers1

0

It is likely that you are using some version of php7, in this case the functions mysql_connect and mysql_select_db no longer exists in php7 so they will not work

Nathanael
  • 870
  • 5
  • 11
  • If he is using PHP7, and then there aren't the mysql_* functions, an `FATAL ERROR` would be raised! So, this is not that case. – user2342558 Jan 19 '18 at 09:57
  • @user2342558 This answer is in fact correct. See the OP's previous question, and as per [this comment](https://stackoverflow.com/questions/48338141/could-not-connect-to-phpmyadmin-using-php-and-mysql?noredirect=1#comment83665006_48338141) I left under the post. – Funk Forty Niner Jan 19 '18 at 11:23
  • ok, I understand. – user2342558 Jan 19 '18 at 11:29