Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php mysql Connect Database from another server

Connect Database from another server in mysql and php I use this :

<?php
$db = mysql_connect("mysite.com", "theusername", "proud");
mysql_select_db("theotherserverDB",$db);

?>

need to Fix?

like image 644
Hassan Avatar asked May 22 '26 08:05

Hassan


1 Answers

<?php

mysql_connect("mysite.com:3306", "admin", "1admin") or die(mysql_error());
echo "Connected to MySQL<br />";

?>

Just run it and see if it works.

like image 141
Sandeep Bansal Avatar answered May 24 '26 23:05

Sandeep Bansal