Log in

View Full Version : Include a php file on main forum


Anakior
04-19-2006, 10:58 AM
Hi,

I'm french so sorry for my really bad english.

I'm working on an simple script who makes random quotations from my sql. It's working nice in stand alone. I put it here :

include("includes/config.php");

//Connection
$connections = mysql_connect($config['MasterServer']['servername'], $config['MasterServer']['username'], $config['MasterServer']['password']) or die ('Impossible de se connecter !');
mysql_select_db($config['Database']['dbname']) or die ('Impossible de s?lectionner la base de donn?es !');

//Select for quote
$query = "SELECT id, nom, nom_auteur, citation FROM pdp";
$result = mysql_query($query) or die ("Erreur dans la requ?te : $query. " . mysql_error());


srand((double)microtime()*10000);

$num = mysql_num_rows($result);

$nb = rand(0, $num-1);

mysql_data_seek($result, $nb);

$ligne = mysql_fetch_assoc($result);

echo '<table border="0" align="center">';
echo '<tr>';
echo '<td><div align="left"><em>"'.$ligne['citation'].'"</em></div></td>';
echo '</tr>';
echo '<tr>';
echo '<td><div align="right"><b>'.$ligne['nom'].'</b></div></td>';
echo '</tr>';
echo '</table>';

But i want to put it on my vb forum page above the Mark Forums Read and the View Forum Leaders.

I have followed the method on this page :
http://www.vbulletin.com/forum/showthread.php?t=173937

Unfortunately without success because the forum give me this error :

Fatal error: Call to a member function on a non-object in blabla/functions_user.php on line 161

Somes ideas to make it work?^^

Thanks in advance for your help :up: