problem connecting to remote mysql database using php

If I open up a cmd shell and run

>mysql --host=12.34.56.78 --port=1234 --user=myuser --password=mypassword mydb

I can successfully connect to the remote mysql database.

But if I create a php page on my localhost containing

<?php
$hostname = "12.34.56.78:1234";
$username = "myuser";
$password = "mypassword";
$dbname   = "mydb";
$connect = mysql_connect($hostname,$username,$password) or die ("Error: could not connect to database");
?>

I get the following error:

Error: could not connect to database

Can anyone explain what might be causing the problem here?

mysql_error() => mysqlnd cannot connect to MySQL 4.1+ using old authentication

Answers


Auth problems are a known issue with PHP 5.3 and older versions of MySQL. Check this:

http://www.bitshop.com/Blogs/tabid/95/EntryId/67/PHP-mysqlnd-cannot-connect-to-MySQL-4-1-using-old-authentication.aspx


maybe in your php.ini parameter sql.safe_mode is "1"?

sql.safe_mode boolean 

If turned on, database connect functions that specify default values will use those values in place of supplied arguments. For default values see connect function documentation for the relevant database.


Need Your Help

Scala Play 2.0. Compilation error: IO error while decoding

scala playframework playframework-2.0 sbt multi-module

I downloaded multi-module Scala project from GitHub (https://github.com/henrikengstrom/roygbiv), and one of the module is Play 2.0 module. So I can run whole application using SBT's run command on ...

Store String Array In appSettings?

asp.net .net web-config app-config asp.net-4.0

I'd like to store a one dimensional string array as an entry in my appSettings. I can't simply separate elements with , or | because the elements themselves could contain those characters.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.