-1

I am getting this message in my site all of a sudden without making any changes in the config file. I will post my config code to see if there are any issues with it.

define('DB_SERVER', 'www.victorexoticagoa.com');
define('DB_SERVER_USERNAME', '******');
define('DB_SERVER_PASSWORD', '********');
define('DB_DATABASE', 'victor');
define('USE_PCONNECT', 'false');
define('STORE_SESSIONS', 'mysql');
define('CFG_TIME_ZONE', 'Asia/Kolkata');

The above code is from the configure.php file.

The below code is the connection:

tep_db_connect() or die('Unable to connect to database server!');

And the code below is the function which does the connection:

  function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') {
global $$link;

if (USE_PCONNECT == 'true') {
  $server = 'p:' . $server;
}

$link = mysqli_connect($server, $username, $password, $database);

if ( !mysqli_connect_errno() ) {
  mysqli_set_charset($$link, 'utf8');
} 

return $$link;
}

Any help will be gladly appreciated. Thanks

Calimero
  • 4,238
  • 1
  • 23
  • 34
DEV
  • 647
  • 4
  • 19
  • 31

2 Answers2

1

Check if your database is up by using the following command in a command shell:

mysql --host=www.victorexoticagoa.com --port=yourport --user=youruser --pass=yourpass

If it cannot connect, the problem is the server, not your code.

André Chalella
  • 13,788
  • 10
  • 54
  • 62
  • Will it not work, if i check the www.victorexoticagoa.com on url? Cos the above command is not working – DEV Nov 26 '15 at 14:25
  • @davidnoronha it should state that it's unable to connect to the server (provided of course MySQL is installed in your computer). – André Chalella Nov 26 '15 at 14:28
  • the service is installed through ampps. Will it not work with that? – DEV Nov 26 '15 at 14:29
  • @davidnoronha exactly what message are you getting? – André Chalella Nov 26 '15 at 14:30
  • It is saying there is no mysql installed and is asking me to install a package from the selected packages suggested. Doing that would probably affect my ampps mysql right? – DEV Nov 26 '15 at 14:31
  • The program 'mysql' can be found in the following packages: * mysql-client-core-5.5 * mariadb-client-core-5.5 * mysql-client-core-5.6 * percona-xtradb-cluster-client-5.5 Try: sudo apt-get install – DEV Nov 26 '15 at 14:31
  • @davidnoronha your ampps MySQL is not accessible from any directory because it's not in the PATH variable. Either include it in PATH or install the MySQL suggested package, which will likely not interfere with your ampps install (you can remove the package when you're done with the command above, just to be sure it won't interfere). – André Chalella Nov 26 '15 at 14:35
  • OK, now all I got was an arrow below – DEV Nov 26 '15 at 14:38
  • @davidnoronha you're supposed to run it with the parameters I gave you (`--host`, `--user` etc) – André Chalella Nov 26 '15 at 14:40
  • I copy pasted the same code you gave, replaced the username and password, and the port with 3306, still showing me the arrow below (->) – DEV Nov 26 '15 at 14:42
  • @davidnoronha read the output. If it doesn't end with `mysql>` and a cursor for you to enter commands with, it failed to connect. – André Chalella Nov 26 '15 at 14:46
  • so the error lies in the db server? It just shows an arrow like this: (- >) – DEV Nov 26 '15 at 14:47
  • @davidnoronha no. Something's wrong with your command, but I don't have enough information to help you with it. – André Chalella Nov 26 '15 at 15:03
  • would the issue lie with the port number? I have tried giving it 3306 and 80., still getting the same issue – DEV Nov 27 '15 at 02:10
1

Have you checked if that is the way you need to connect or the port to connect? I dont see the port (thats not supposed to be port 80 most times). Please check docs of the host and ask for details. It should be documented.

Gary
  • 2,293
  • 2
  • 25
  • 47