gpt4 book ai didi

mysql - 如何将实时 mysql 数据库连接到本地 php 和网络应用程序?

转载 作者:行者123 更新时间:2023-11-29 12:25:18 25 4
gpt4 key购买 nike

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"/>

最佳答案

$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

关于mysql - 如何将实时 mysql 数据库连接到本地 php 和网络应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28425406/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com