mysql - php database help, database hosted on separate server than web host -


hi making login/register database. not hosting database on same server how make point separate domain? if can tell me root pointing to... thx

here files:

db.php

<?php $connection = mysql_connect('localhost', 'root', ''); if (!$connection){ die("database connection failed" . mysql_error()); } $select_db = mysql_select_db('register'); if (!$select_db){ die("database selection failed" . mysql_error()); } ?> 

links (my scripts , original scripts): https://docs.google.com/document/d/1u60x_mkd9z548qrh_vjdytx3hziiziyplua_rjx11mq/edit?usp=sharing

for starters, don't use mysql_connect()! use either mysqli or pdo. second, don't have application log in mysql root; create application-specific unprivileged user (with password!) purpose.

you'll need create unprivileged user connect privilege web server's ip or dns address, , instead of connecting localhost php need connect db server's ip or dns address, so:

$dsn = "mysql:host=mysqlserver.mynetwork.com;dbname=register"; try {     $conn = new pdo($dsn, $appuser, $apppasswd); } catch (pdoexception $e) {     echo 'connection failed: ' . $e->getmessage(); } 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -