V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Recommended Services
Amazon Web Services
LeanCloud
New Relic
ClearDB
helloboy
V2EX  ›  云计算

appfog 数据库问题

  •  
  •   helloboy · Aug 17, 2012 · 4878 views
    This topic created in 5009 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
        1
    CoX  
       Aug 17, 2012
    有没有添加并绑定数据库呢?
    helloboy
        2
    helloboy  
    OP
       Aug 17, 2012
    @Cox 有呢,添加并绑定了的,选的新加坡的节点。
    7anshuai
        3
    7anshuai  
       Aug 17, 2012
    我用appfog services设置下的php code samples很顺利的连接了数据库
    helloboy
        4
    helloboy  
    OP
       Aug 17, 2012
    @7anshuai 不知道我这啥问题,现在那个链接打不开了
    7anshuai
        5
    7anshuai  
       Aug 20, 2012   ❤️ 1
    @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
        6
    helloboy  
    OP
       Aug 20, 2012
    @7anshuai 感谢,解决~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2684 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 57ms · UTC 03:24 · PVG 11:24 · LAX 20:24 · JFK 23:24
    ♥ Do have faith in what you're doing.