Good day. Recently just started learning mysql, therefore. from time to time there are difficulties that I could solve myself up to now. But now I ask for your help.
I'm trying to connect to a mysql server from php, the admin gave me an ip, login, password, database name. Php file looks like this:
$hostname = '192.168.1.20:1433'; $username = "t"; $password = "t"; $dbName = "insy"; mysql_connect($hostname,$username,$password) OR DIE(mysql_error()); mysql_select_db($dbName) or die(mysql_error()); $query = "SELECT * FROM `insy` WHERE 1;"; $result=mysql_query($query) or die(mysql_error()); echo "works!"; mysql_close();
When executed, the page hangs for a long time, and eventually returns:
Warning: mysql_connect() [function.mysql-connect]: MySQL server has gone away in N:\home\192.168.1.19\www\phlib.php on line 12 Warning: mysql_connect() [function.mysql-connect]: Error while reading greeting packet. PID=1908 in N:\home\192.168.1.19\www\phlib.php on line 12 Warning: mysql_connect() [function.mysql-connect]: MySQL server has gone away in N:\home\192.168.1.19\www\phlib.php on line 12 MySQL server has gone away
12 line is:
mysql_connect($hostname,$username,$password) OR DIE(mysql_error());
I tried in the administration of ODBC Sql Server a data source - with the same parameters it is normally created, the bases are seen.
Tell me what am I doing wrong?
UPD: all machines on Windows.
Thank you in advance!