I'm trying to use a wildcard subdomain with my application.
But it's not working properly...
Can you help me out, please?
$WildcardDomain = $_SERVER['HTTP_HOST'];
$WildcardTMP = explode('.', $WildcardDomain);
$WildcardSubdomain = current($WildcardTMP);
$db_host = 'localhost';
$db_user = 'localuser';
$db_password = 'localpass';
$db_name = 'localdb';
define('APP_URL', "http://" + $WildcardSubdomain);
The URL Generated is http://localhost/0/login/
The '0' should not be there...
Related
Hello i have file in folder assets/includes/config.php
The file contains this data:
$db_host = 'localhost';
$db_name = 'xxxx';
$db_username = 'xxxx';
$db_password = 'xxxxx';
$site_url = 'https://xxxxx.xx/';
How can i echo this data in index.php so it would be visible for everybody ?
Thank you!
Just use echo before all code lines.
For example
echo $db_host = 'localhost';
echo $db_name = 'xxxx';
echo $db_username = 'xxxx';
echo $db_password = 'xxxxx';
echo $site_url = 'https://xxxxx.xx/';
i am getting this error as i integrate this forum in my website i am new to this error his is my config.php i had made changes according to my database i am new to this i don't know why and what is this error.
<?php
$dbms = 'phpbb\\db\\driver\\mysqli';
$db host = 'localhost';
$dbport = '';
$dbname = 'abc_forum';
$dbuser = 'root',
$dbpasswd = '';
$table_prefix = '';
$phpbb_adm_relative_path ='adm/';
$acm_type = 'phpbb\\cache\\driver\\file';
#define('PHPBB_INSTALLED', true);
change $db host to $dbhost :
<?php
$dbms = 'phpbb\\db\\driver\\mysqli';
$dbhost = 'localhost';
$dbport = '';
$dbname = 'abc_forum';
$dbuser = 'root',
$dbpasswd = '';
$table_prefix = '';
$phpbb_adm_relative_path ='adm/';
$acm_type = 'phpbb\\cache\\driver\\file';
#define('PHPBB_INSTALLED', true);
The username and password are not valid. That is what this means. Ask your hosting provider for the correct credentials.
Keep it simple
$conn = new mysqli("DB_HOST","USERNAME","PASSWORD","DATABASE");
is there a way to reconfig database using a controller in codeigniter?
let say i have this code in database config
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'db';
Then i want to change to this
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'admin';
$db['default']['password'] = 'password';
$db['default']['database'] = 'db_admin';
Using controller in codeigniter. Is this possible?
You can define multiple database in database.php in config folder like
//database 1 details
$db['db1']['hostname'] = 'localhost';
$db['db1']['username'] = 'root';
$db['db1']['password'] = '';
$db['db1']['database'] = 'db';
//database 2 details
$db['db2']['hostname'] = 'localhost';
$db['db2']['username'] = 'admin';
$db['db2']['password'] = 'password';
$db['db2']['database'] = 'db_admin';
And you can connect to required database as following in your scripts
if(condition){
$DB = $this->load->database('db1', TRUE);
}
else{
$DB = $this->load->database('db2', TRUE);
}
When you connect database like this, you have to use your object name $DB rather than $this
$DB->query();
$DB->result();
instead of
$this->db->query();
$this->db->result();
For more details
Yes you can do that. Inside your controller function specify the conditions and then add the following code:
$config['hostname'] = "localhost";
$config['username'] = "admin";
$config['password'] = "password";
$config['database'] = "db_admin";
$this->load->database($config);
Now you can access the new database config. Also disable caching as,
$db['default']['cache_on'] = FALSE;
in your database.php file inside config folder.
Hope it helps.
Looks like i have found the solution. Dont know is better or not. But its better than nothing.
I have tried over
$config['hostname'] = "localhost";
$config['username'] = "admin";
$config['password'] = "password";
$config['database'] = "db_admin";
$this->load->database($config);
and tried many ways.. but its always call the database from config folder
Then i found this basic php method for calling the database i desire
like this
$dbname = 'my_db';
$mysqli = new mysqli("localhost", "root", "", $dbname);
$result = $mysqli->query("query")`
$result->close();
I know how foolish i am, and how silly the answers.. but its better than nothing hahaha
I am using PHP nuke 7.6
In config.php i have changes the some code -
$dbhost = "localhost";
$dbuname = "root";
$dbpass = "";
$dbname = " phpnuke";
$prefix = "nuke";
$user_prefix = "nuke";
$dbtype = "MySQL";
$sitekey = "SdFk*fa28367-dm56w69.3a2fDS+e9";
$gfx_chk = 0;
$subscription_url = "";
$admin_file = "admin";
After complete the configuration i got the following message.
"There seems to be a problem with the MySQL server, sorry for the inconvenience. We should be back shortly."
Please help me to shutout this problem.
Thanks
Maybe the space before phpnuke in $dbname?
$dbname = " phpnuke";
I am stumped. I have a login.php page that contains the SQL login info (hostname, database, username, password) included at the top of my index.php page (using require_once). The login info is within a conditional statement that determines whether I am on the remote server or the local testing server and offers up the correct login info. Now this is where it gets weird, it doesn't work (as in it does not make a connection with the database) when I go directly to the index.php page on the remote server however it does work on the testing server and it works if I visit the login.php site on the remote server first (which doesn't echo anything) and then visit the index.php page on the remote server. I have caches disabled. Why is this happening and how can I fix it? try it yourself by visiting http://distantfuturejosh.com/playground/pendingaxioms first (it won't work), then visiting http://distantfuturejosh.com/playground/pendingaxioms/login.php (a blank page is served) and then returning to http://distantfuturejosh.com/playground/pendingaxioms (it will work and you'll see the images appear).
here is the login.php page:
<?php
$requesturi = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$pos = strpos($requesturi, "www.distantfuturejosh.com");
if ($pos === 0)
{
$db_hostname = "xxxxxxxx";
$db_database = "xxxxxxxx";
$db_username = "xxxxxxxx";
$db_password = "xxxxxxxx";
}
else
{
$db_hostname = "localhost";
$db_database = "xxxxxxxx";
$db_username = "root";
$db_password = "root";
}
?>
Try using
session_start();
at beginning of your file.
try using if ($pos === false) instead of if ($pos === 0) like this
<?php
$requesturi = $_SERVER['HTTP_HOST'];
$pos = strpos($requesturi, "distantfuturejosh");
if ($pos === false)
{ //local
$db_hostname = "localhost";
$db_database = "xxxxxxxx";
$db_username = "root";
$db_password = "root";
}
else
{ //remote
$db_hostname = "xxxxxxxx";
$db_database = "xxxxxxxx";
$db_username = "xxxxxxxx";
$db_password = "xxxxxxxx";
}
?>
I suppose you check user login and include login.php in your other PHP pages with include /subfolder/login.php;