Welcome Guest, Not a member yet? Register   Sign In
Database Error Occurred
#3

Here is code for testing a database connection etc;

PHP Code:
<?php
/**
 * Fill our vars and run on cli
 * db-connect-test.php
 */

$dbname 'name';
$dbuser 'user';
$dbpass 'pass';
$dbhost 'host';

$connect mysqli_connect($dbhost$dbuser$dbpass) or die("Unable to Connect to '$dbhost'");
mysqli_select_db($connect$dbname) or die("Could not open the db '$dbname'");

$test_query "SHOW TABLES FROM $dbname";
$result mysqli_query($connect$test_query);

$tblCnt 0;

while(
$tbl mysqli_fetch_array($result))
{
  $tblCnt++;
  #echo $tbl[0]."<br />\n";
}

if (!
$tblCnt)
{
  echo "There are no tables<br />\n";
}
else
{
  echo "There are $tblCnt tables<br />\n";

What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
Database Error Occurred - by mycoban - 03-04-2020, 06:44 AM
RE: Database Error Occurred - by John_Betong - 03-04-2020, 08:37 AM
RE: Database Error Occurred - by InsiteFX - 03-04-2020, 01:01 PM
RE: Database Error Occurred - by tweenietomatoes - 03-04-2020, 02:03 PM
RE: Database Error Occurred - by InsiteFX - 03-05-2020, 04:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB