<?php
/*
Template Name: test
*/
// edit these values to match your database information
$server = "localhost";
$user = "root";
$password = "";
$db = "_wp201";
$con = mysql_connect($localhost,$user,$password);
if (!$con) {
die("database connection error");
} else {
mysql_select_db($db, $con);
// example query
$result = mysql_query("SELECT * FROM wp_posts
WHERE post_author='1'");
// show all posts by author 1 (admin)
while($row = mysql_fetch_array($result))
{
if($row['post_status'] == "publish") {
echo "".$row['post_title']." <br />";
}
}
}
mysql_close($con);
?>
我正在 wordpress 中创建一个自定义注册页面。所以我创建了一个测试页面来测试数据库连接。但是没有显示任何内容。为什么呢?请帮忙。(所有服务器进入都是正确的)