我设置了两个数据库连接,如下所示
$con1 = mysql_connect("localhost", "root", "pwd") or die (mysql_error());
$con2 = mysql_connect("localhost", "wordpress", "pwd", true) or die(mysql_error());
mysql_select_db("lab_ancp", $con1) or die(mysql_error());
mysql_select_db("wordpress",$con2) or die(mysql_error());
它工作正常
所以我在这样的页面上做一些查询:
$sql="select unome from associado where uid=$uid";
$result=mysql_query($sql,$con1) or die(mysql_error());
它工作正常,之后我做了第二个这样的查询:
$sql="select ID, post_content, post_title, post_excerpt, meta_value
from wp_posts join (
select post_id, meta_value
from wp_postmeta
join (
select post_id from wp_postmeta
where meta_key='destaque' and meta_value='s'
)as t1 using(post_id)
where meta_key='pft_widescreen'
) as t2 on (wp_posts.ID=t2.post_id)
ORDER BY RAND() LIMIT 1";
//echo $sql . "<br />";
$row=mysql_fetch_assoc(mysql_query($sql,$con2)) or die(mysql_error());
再次一切都很好,但是然后....
$sql="select * from eventos where edatade>='$hoje' or edataate>='$hoje'";
$result=mysql_query($sql, $con1) or die (mysql_error());
给出这个错误:
**
SELECT 命令拒绝用户 'wordpress'@'localhost' 用于表 'eventos'
**