Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Morpheusxeno Posted January 16, 2019 Posted January 16, 2019 I am creating some module that needs information from the database, is it safe to store $servername = ""; $username = ""; $password = ""; $dbname = ""; $conn = new mysqli($servername, $username, $password, $dbname); $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $online = 0; Into a block which is loaded on the front page? If its not, what is the require path to use so I can store the DB info in a file that can be accessed by the block. I am having an issue making the block require the database info without using an absolute path.
Aiwa Posted January 16, 2019 Posted January 16, 2019 Please don't do that... It's poor practice. https://invisioncommunity.com/developers/docs/fundamentals/accessing-the-database-r166/ If you're connecting to your Invision DB for data, use \IPS\Db, how to use the methods are in the System/Db/Db.php file or the above doc. \IPS\Db::i()->select() If you're connecting to a remote DB..... Store the data in your conf_global.php file so it's protected just like your Invision DB details. Use \IPS\Db::i('your_remote_name',$connectionSettings) Populate $connectionSettings array from conf_global.php values you added for your remote DB. require( \IPS\ROOT_PATH . '/conf_global.php' ); $connectionSettings['sql_host'] = $INFO['your_remote_db_...'] $connectionSettings['sql_user'] = $INFO['your_remote_db_...'] $connectionSettings['sql_pass'] = $INFO['your_remote_db_...'] $connectionSettings['sql_database'] = $INFO['your_remote_db_...'] $connectionSettings['sql_port'] = $INFO['your_remote_db_...'] $connectionSettings['sql_socket'] = $INFO['your_remote_db_...'] $connectionSettings['sql_tbl_prefix'] = $INFO['your_remote_db_...']
Recommended Posts
Archived
This topic is now archived and is closed to further replies.