Hi all, i'm trying to integrate the phpbb3 login system with the comment form in wordpress so that authenticated people is automatically recognized and doesn't need to input name and email or login to comment.
To do so i read a phpbb3 cookie and then query the database to get the data i need. Here is the code i use (file comments.php):
...
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<?php
//inizio modifica per personalizzazione viterbolive
$userSID = $_COOKIE["phpbb3_osrzf_sid"];
//apro connessione...
$myCon = mysql_connect("localhost","root","");
if (!$myCon) {
die('Connessione fallita: ' . mysql_errore());
}
else
{
$sqlSelect = "SELECT username, user_email, user_avatar, user_id " .
"FROM <code>phpbb_users</code> " .
"INNER JOIN <code>phpbb_sessions</code> ON session_user_id = user_id " .
"WHERE session_id = '" . $userSID . "'";
//echo($sqlSelect);
mysql_select_db("forum", $myCon);
$result = mysql_query($sqlSelect);
while($row = mysql_fetch_array($result))
{
$myUserName = $row['username'];
$myEmail = $row['user_email'];
}
}
mysql_close($myCon);
//fine modifica
?>
<?php if ($myUserName!='Anonymous' and $myUserName!='') : ?>
...
With this code i obtain the result expected but i mess up all the other queries in the page. All the queries executed after this code return the following error on screen:
Warning: mysql_error(): 8 is not a valid MySQL-Link resource in D:\xampp\htdocs\wordpress\wp-includes\wp-db.php on line 236
No categories
Any suggestion? What am i doing wrong and how can i solve it? Thank you all!