i have implement one application that contains some page of php and some page of asp.net. and i have deploy this app in iis server.Application is working fine with local data.but database does not connect with live database.
下面给出的php文件中的连接字符串:
`$conn=mysql_connect("example.com","user_name","password") or die(mysql_error());
$db = mysql_select_db("database_name",$conn);
`
web.config中的连接字符串:
<add name="LocalMySqlServer" connectionString="Datasource=example.com;Database=database_name;uid=user_name;pwd=passwd;convert zero datetime=True" providerName="MySql.Data.MySqlClient"/>
答案 0 :(得分:1)
$hostname_localhost ="localhost";
$database_localhost ="u2us"; //datbase name
$username_localhost ="root";
$password_localhost ="";
$localhost = mysql_connect($hostname_localhost,$username_localhost,$password_localhost)//connection of localhost
or
trigger_error(mysql_error(),E_USER_ERROR); //generate error report whether connection is failed.
mysql_select_db($database_localhost, $localhost); //select db