问题描述
- 微信获取BAE上的mysql中的数据问题
-
<?php
$dbname = 'ePjMlhlEtSYcyqaWDIMM';
/*从环境变量里取出数据库连接需要的参数*/
$host = getenv('HTTP_BAE_ENV_ADDR_SQL_IP');
$port = getenv('HTTP_BAE_ENV_ADDR_SQL_PORT');
$user = getenv('HTTP_BAE_ENV_AK');
$pwd = getenv('HTTP_BAE_ENV_SK');
/*接着调用mysql_connect()连接服务器*/
$link = @mysql_connect("{$host}:{$port}",$user,$pwd,true);
if(!$link) {
die("Connect Server Failed: " . mysql_error());
}
/*连接成功后立即调用mysql_select_db()选中需要连接的数据库*/
if(!mysql_select_db($dbname,$link)) {
die("Select Database Failed: " . mysql_error($link));
}
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);//$postObj是simpleXml的对象
$msgtype = trim($postObj->MsgType);
$fromUsername = $postObj->FromUserName;
$toUsername = $postObj->ToUserName;
$keyword = trim($postObj->Content);
$time = time();
$textTpl = "
<![CDATA[%s]]>
<![CDATA[%s]]>
%s
<![CDATA[%s]]>
<![CDATA[%s]]>
0
";$sql="create table if not exists cake(
name char primary key not null,
des char,
name varchar(50))";
$ret = mysql_query($sql);$Isql="insert cake values('k','ww',111,'http://fenghongyue.duapp.com/images/home.jpg')";
$r=mysql_query($Isql);
$query=mysql_query("select * from cake where name='k'");
$res=mysql_fetch_array($query);
$contentStr=$res['Content'];
/*显式关闭连接,非必须*/$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $contentStr);
echo $resultStr;mysql_close($link);
?>
这个为什么公众平台什么都没有返回
时间: 2024-10-31 08:53:20