Welcome Guest, Not a member yet? Register   Sign In
Cant connect to to DB using CI4
#5

(This post was last modified: 03-17-2021, 12:27 PM by InsiteFX.)

Try testing it with MySQLi Test

PHP Code:
<?php

/**
 * Fill our vars and run on cli - $ php -f mysqli_test.php
 * or
 * Use php editor save file as mysqli_test.php
 */

$dbname 'database_name'// The database name
$dbuser 'user_name';     // The users name
$dbpass 'user_password'// The database users password
$dbhost 'database_host'// usally localhost else use 27.0.0.1

// Try to connect
$connect mysqli_connect($dbhost$dbuser$dbpass) or die("Unable to Connect to '$dbhost'");

// Select the database
mysqli_select_db($connect$dbname) or die("Could not open the db '$dbname'");

// Test query to get database tables
$test_query "SHOW TABLES FROM $dbname";

// The query result
$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";


See if that works if not you have a problem in user password or host.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
Cant connect to to DB using CI4 - by eldan88 - 03-16-2021, 04:19 PM
RE: Cant connect to to DB using CI4 - by kenjis - 03-16-2021, 11:14 PM
RE: Cant connect to to DB using CI4 - by eldan88 - 03-17-2021, 10:48 AM
RE: Cant connect to to DB using CI4 - by kenjis - 03-17-2021, 03:44 PM
RE: Cant connect to to DB using CI4 - by eldan88 - 03-17-2021, 04:26 PM
RE: Cant connect to to DB using CI4 - by InsiteFX - 03-17-2021, 12:26 PM
RE: Cant connect to to DB using CI4 - by eldan88 - 03-17-2021, 01:33 PM
RE: Cant connect to to DB using CI4 - by InsiteFX - 03-17-2021, 01:58 PM
RE: Cant connect to to DB using CI4 - by kenjis - 03-17-2021, 04:38 PM
RE: Cant connect to to DB using CI4 - by eldan88 - 03-17-2021, 09:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB