Database Error

I’m using Interserver hosting shared package. I’m facing database error from last 3 weeks. I contact many time but on every reply there is no problem. This error come error hour in a day. Please help me .

There is probably an issue regarding the query you’re using to connect to your database. Nobody will be able to help you though until you provide us with some sort of code to assist you on finding where the problem is coming from.

What entries are you getting in the database server’s error logs?

Hi @prodramasonline and welcome to SitePoint Forums.

Without knowing the errorcode it is impossible to take a guess or to offer any solution.

May I suggest creating a simple “testDatabaseConnection.php” page and trying to connect to your server:

// testDatabaseConnection.php

<?php 

# DEBUG
   function fred($val='Yes we have no $val???', $msg="")
   {
	echo '<pre>' .$msg .'<br>';
	  print_r( $val );
	echo '</pre>';  
   }

# 'mysqli' : // try to connect to database using username and password
   $dbh =  mysqli_connect
   (
      'hostName', // REPLACE THESE PARAMETERS
      'userName',
      'password',
      'databaseName'
   );
   fred($dbh, '$dbh');

  fred( mysqli_info($dbh),  'mysqli_info()', 1);
  fred($dbh, '$dbh');
  $ok = mysqli_select_db($dbh, 'databaseName');
  /* check connection */
  if ($dbh->connect_errno) 
  {
     fred($dbh, '$dbh ERROR '); 
     $msg = 'mysqli_error()' .mysqli_error();
  }			

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.