php - How to connect to database on another server? -
<?php $dbh=mysql_connect('187.0.0.0','abcd','1234') or die(mysql_error()); if($dbh) { echo "server connected"; } $db=mysql_select_db('demo') or die(mysql_error()); if($db) { echo "database connected"; } ?>
i used code on server check connectivity i'm getting error
host 'mail.hosting1001.in' not allowed connect mysql server
the server has allow remote connections user in question. use grant
syntax give user remote permissions (but limit permissions ip address making remote connection, assuming it's fixed address).
even better, feeela suggested in comments: open secure tunnel between machines can connect if connecting local machine.
also, please don't use mysql_*
; mysql_*
functions outdated, deprecated, , insecure. use mysqli
or pdo
instead.
Comments
Post a Comment