我正在尝试使用PHP在heroku中开发一个php应用程序...
我已经完成了使用link - https://devcenter.heroku.com/articles/xeround#connecting-to-xeround添加插件的工作。
现在,我正在尝试查询数据库,这只是一个简单的查询,但甚至没有显示任何错误。
我可以知道是否仍然需要连接字符串吗?如果需要,我可以知道作为主机应该放什么吗?
如果需要任何后续问题,请让我知道。
提前感谢!
发布于 2013-04-02 10:13:41
您可以尝试这样做:
$url=parse_url(getenv("DATABASE_URL"));
$server = $url["host"];
$username = $url["user"];
$password = $url["pass"];
$port = $url["port"];
$db = substr($url["path"],1);
$link = mysql_connect($server . ":" . $port, $username, $password);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';Source: [https://devcenter.heroku.com/articles/cleardb#using-cleardb-with-php]
希望它能有所帮助:)
https://stackoverflow.com/questions/11975363
复制相似问题