Well, I've already do it, but i have a problem: I have two files:
block-Forums.php:
if( eregi( "block-Foros.php",$PHP_SELF ) )
{
Header("Location: index.php");
die();
}
global $prefix, $user_prefix, $db;
// Ajax function
$content .= "
<script language=\"javascript\" type=\"text/javascript\">
function getPage(Last_New_Topics){
var xmlhttp=false; //Clear our fetching variable
try {
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
} catch (e) {
try {
xmlhttp = new
ActiveXObject('Microsoft.XMLHTTP');
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
var file = 'test/1/text.php?n=';
xmlhttp.open('GET', file + Last_New_Topics, true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
var content = xmlhttp.responseText;
if( content ){
document.getElementById('content').innerHTML = content;
}
}
}
xmlhttp.send(null)
return;
}
</script>";
[...]
and text.php:
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("lq");
$n = $_GET["n"];
$result = mysql_query("SELECT t.topic_id, t.topic_first_post_id, t.forum_id, t.topic_last_post_id,
t.topic_title, t.topic_poster, t.topic_views, t.topic_replies, t.topic_moved_id, p.poster_id,
p.post_time, u.username, l.username, u.user_id, tx.post_text, p.post_username, f.post_username
FROM nuke_bbtopics AS t
LEFT JOIN nuke_bbposts AS p ON (p.post_id = t.topic_last_post_id)
LEFT JOIN nuke_bbposts AS f ON (f.post_id = t.topic_first_post_id)
LEFT JOIN nuke_bbposts_text AS tx ON (p.post_id = tx.post_id)
LEFT JOIN nuke_users AS u ON (u.user_id=p.poster_id)
LEFT JOIN nuke_users AS l ON (l.user_id=t.topic_poster)
WHERE t.topic_moved_id=0
ORDER BY t.topic_last_post_id DESC LIMIT 0, $n
");
while( list( $topic_id, $postf_id, $forum_id, $topic_last_post_id, $topic_title, $topic_poster, $topic_views, $topic_replies, $topic_moved_id, $poster_id, $post_time, $post1, $post2, $user_id, $post_text, $guest_name, $guest_name2) = $row = mysql_fetch_row($result))
{
[...]
In the second file, I have to make a connection, but i want to make it through the "$db" variable, to avoid these lines:
mysql_connect("localhost", "root", "");
mysql_select_db("lq");
How could i do it?