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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -