I've set two database conections as below
$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());
and it works fine
so then i do some queries on a page like this:
$sql="select unome from associado where uid=$uid";
$result=mysql_query($sql,$con1) or die(mysql_error());
and it works fine, after that i do a second query like this:
$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());
and again everything is just fine, but then....
$sql="select * from eventos where edatade>='$hoje' or edataate>='$hoje'";
$result=mysql_query($sql, $con1) or die (mysql_error());
gives this error:
**
SELECT command denied to user 'wordpress'@'localhost' for table 'eventos'
**
Well
Its solved.
Don't askme the reason but i've tried to change the order in the first two roww, i.e put $con2 before $con1 and the queries now simply work fine.
I suspect that the ..."true" parameter has something to do with that.
Thx guys.