文章內query MySQL - 部落格
By Odelette
at 2011-01-06T05:35
at 2011-01-06T05:35
Table of Contents
小弟的 WP 是自己架設的
想要在某網誌分頁裡顯示其他網誌分頁的內容
先去找了 PHP 外掛來試,Exec-PHP、PHP Execution、runPHP
這三套都試過了,基本的 PHP 語法都 OK
SQL 的語法也都通過了,DB 都有順利連上 (沒連上會有 error 訊息)
但就是無法把 query 到的資料 echo 出來,一片空白
附上 code
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error with MySQL
connection');
mysql_query("SET NAMES 'utf8'");
mysql_select_db($dbname);
$sql = "SELECT * FROM wp_4_posts WHERE post_title='活動' AND
post_status='publish' ORDER BY post_date DESC";
$result = mysql_query($sql) or die('MySQL query error');
while($row = mysql_fetch_array($result)){
echo $row['post_content'];
}
不在WP下,自己新開一個 php,是可以 work 的
不曉得有沒有人有經驗或者有解決辦法?
--
想要在某網誌分頁裡顯示其他網誌分頁的內容
先去找了 PHP 外掛來試,Exec-PHP、PHP Execution、runPHP
這三套都試過了,基本的 PHP 語法都 OK
SQL 的語法也都通過了,DB 都有順利連上 (沒連上會有 error 訊息)
但就是無法把 query 到的資料 echo 出來,一片空白
附上 code
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error with MySQL
connection');
mysql_query("SET NAMES 'utf8'");
mysql_select_db($dbname);
$sql = "SELECT * FROM wp_4_posts WHERE post_title='活動' AND
post_status='publish' ORDER BY post_date DESC";
$result = mysql_query($sql) or die('MySQL query error');
while($row = mysql_fetch_array($result)){
echo $row['post_content'];
}
不在WP下,自己新開一個 php,是可以 work 的
不曉得有沒有人有經驗或者有解決辦法?
--
Tags:
部落格
All Comments
By Charlie
at 2011-01-07T02:27
at 2011-01-07T02:27
By Charlotte
at 2011-01-11T02:36
at 2011-01-11T02:36
By Hardy
at 2011-01-13T15:18
at 2011-01-13T15:18
By Oscar
at 2011-01-17T12:04
at 2011-01-17T12:04
Related Posts
具個人特色的創意圖文部落格
By Charlotte
at 2011-01-05T14:09
at 2011-01-05T14:09
各位前輩有用過「線上金流服務」嗎?
By Sierra Rose
at 2011-01-05T11:37
at 2011-01-05T11:37
調整版面配置的問題
By Kyle
at 2011-01-05T04:49
at 2011-01-05T04:49
文章內的小廣告
By Donna
at 2011-01-05T02:03
at 2011-01-05T02:03
無法新增文章!
By Daph Bay
at 2011-01-04T22:17
at 2011-01-04T22:17