V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Recommended Services
Amazon Web Services
LeanCloud
New Relic
ClearDB
helloboy
V2EX  ›  云计算

appfog 数据库问题

  •  
  •   helloboy · 2012-08-17 11:10:11 +08:00 · 4007 次点击
    这是一个创建于 4269 天前的主题,其中的信息可能已经有所发展或是发生改变。
    按照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 条回复    1970-01-01 08:00:00 +08:00
    CoX
        1
    CoX  
       2012-08-17 11:13:54 +08:00
    有没有添加并绑定数据库呢?
    helloboy
        2
    helloboy  
    OP
       2012-08-17 11:16:10 +08:00
    @Cox 有呢,添加并绑定了的,选的新加坡的节点。
    7anshuai
        3
    7anshuai  
       2012-08-17 13:02:26 +08:00
    我用appfog services设置下的php code samples很顺利的连接了数据库
    helloboy
        4
    helloboy  
    OP
       2012-08-17 21:02:03 +08:00
    @7anshuai 不知道我这啥问题,现在那个链接打不开了
    7anshuai
        5
    7anshuai  
       2012-08-20 14:29:15 +08:00   ❤️ 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
       2012-08-20 16:50:27 +08:00
    @7anshuai 感谢,解决~
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5536 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 06:46 · PVG 14:46 · LAX 23:46 · JFK 02:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.