Recommended Services
› Amazon Web Services
› LeanCloud
› New Relic
› ClearDB
helloboy
V2EX  ›  云计算

appfog 数据库问题

  •  
  •   helloboy · Aug 17, 2012 · 5365 views
    This topic created in 5206 days ago, the information mentioned may be changed or developed.
    按照https://github.com/appfog/af-php-wordpress/blob/master/wp-config.php这个里面的代码写了个,测试页面,但是传上去无法执行:

    <?php
    $services = getenv('VCAP_SERVICES');
    $services_json = json_decode($services,true);
    $mysql_config = $services_json["mysql-5.1"][0]["credentials"];

    $host = $mysql_config["hostname"];
    $port = $mysql_config["port"]);
    $db = $mysql_config["name"];
    $user = $mysql_config["user"];
    $password = $mysql_config["password"];


    echo $host.'<br>';
    echo $port.'<br>';
    echo $db.'<br>';
    echo $user.'<br>';
    echo $password.'<br>';
    ?>

    有用过的么。
    6 replies  •  1970-01-01 08:00:00 +08:00
    CoX
    CoX
    Aug 17, 2012
    1
    有没有添加并绑定数据库呢?
    helloboy
    helloboy
    OP
    Aug 17, 2012
    2
    @Cox 有呢,添加并绑定了的,选的新加坡的节点。
    7anshuai
    7anshuai
    Aug 17, 2012
    3
    我用appfog services设置下的php code samples很顺利的连接了数据库
    helloboy
    helloboy
    OP
    Aug 17, 2012
    4
    @7anshuai 不知道我这啥问题,现在那个链接打不开了
    7anshuai
    7anshuai
    Aug 20, 2012❤️1
    5
    @helloboy php code samples代码如下:
    $services_json = json_decode(getenv("VCAP_SERVICES"),true);
    $mysql_config = $services_json["mysql-5.1"][0]["credentials"];
    $username = $mysql_config["username"];
    $password = $mysql_config["password"];
    $hostname = $mysql_config["hostname"];
    $port = $mysql_config["port"];
    $db = $mysql_config["name"];
    helloboy
    helloboy
    OP
    Aug 20, 2012
    6
    @7anshuai 感谢,解决~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   968 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 22:03 · PVG 06:03 · LAX 14:03 · JFK 17:03
    ♥ Do have faith in what you're doing.