Newbie phpbb question

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
mrbandit
Registered User
Posts: 88
Joined: Mon Mar 10, 2003 3:51 pm

Newbie phpbb question

Post by mrbandit »

I've created a new table "phpbb_mempages" within my phpbb database. It only has three fields that will be used for club stuff. I only want forum members to have access, which is why I didn't create a new db. I'm very new to php, but have coded with other languages, so don't rake me over the coals for stupid stuff please.

I'm starting simply by creating a php script that connects to the database/table and displays the data in a table. I figured I could use an include to the db.php file, but it keeps telling my I'm hacking. The db.php file appears to have a prereq that something be defined "IN_PHPBB", but how and where to I define whatever it is that I need to define?

Thanks for the help in advance. :?
User avatar
blueadmin
Registered User
Posts: 124
Joined: Wed May 14, 2003 4:58 pm
Location: Bradford, UK

Post by blueadmin »

At the beggining of your file put the following code:

Code: Select all

define('IN_PHPBB', true);
Ho Ho Ho merry christmas
You Stuck? Read this before askinghere and here
mrbandit
Registered User
Posts: 88
Joined: Mon Mar 10, 2003 3:51 pm

Post by mrbandit »

That got me passed that error, but now I get this

Fatal error: Cannot instantiate non-existent class: sql_db in /home/transamc/public_html/forum/includes/db.php on line 60


Here's my script:


<?php
define('IN_PHPBB', true);
include('../includes/db.php');
$db = mysql_connect($dbhost, $dbname, $dbuser, $dbpassword);
mysql_select_db($dbname,$db);
$result = mysql_query("SELECT * FROM phpbb_mempages",$dbname);
echo "$dbhost\n";
echo "<table border=1>\n";
echo "<tr><td>Name</td><td>Position</tr>\n";
while ($myrow = mysql_fetch_row($result)) {
printf("<tr><td>%s %s</td><td>%s</td></tr>\n",
$myrow[1], $myrow[2], $myrow[3]);
}
echo "</table>\n";
?>


Am I just way off base here?
User avatar
morpheus2matrix
Former Team Member
Posts: 9171
Joined: Wed Apr 10, 2002 7:31 pm
Location: France
Contact:

Post by morpheus2matrix »

try this :

Code: Select all


<?php
define('IN_PHPBB', true); 
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

$result = mysql_query("SELECT * FROM phpbb_mempages",$dbname);
echo "$dbhost\n";
echo "<table border=1>\n";
echo "<tr><td>Name</td><td>Position</tr>\n";
while ($myrow = mysql_fetch_row($result)) {
printf("<tr><td>%s %s</td><td>%s</td></tr>\n",
$myrow[1], $myrow[2], $myrow[3]);
}
echo "</table>\n";
?> 
but you're not using the phpBB DBAL system :wink:
Former phpBB MOD-Team Member -

Forgive my bad English :(

No support by PM/Email - Thanks - You can thanks me here :) - Pay me for installing MOD's :lol:
mrbandit
Registered User
Posts: 88
Joined: Mon Mar 10, 2003 3:51 pm

Post by mrbandit »

I'm getting a little frustrated, but I don't like to quit. I made the changes you listed, but now it doesn't like my SELECT statement. Does it have anything to do with phpDBAL or whatever that is. I'm trying this with the help of a PHP Bible and I'm not sure if its steering me wrong.

Click here for the error I get now.

Thanks for the help too! :D
User avatar
morpheus2matrix
Former Team Member
Posts: 9171
Joined: Wed Apr 10, 2002 7:31 pm
Location: France
Contact:

Post by morpheus2matrix »

try to replace

Code: Select all

$result = mysql_query("SELECT * FROM phpbb_mempages",$dbname);
with

Code: Select all

$result = mysql_query("SELECT * FROM phpbb_mempages");
Former phpBB MOD-Team Member -

Forgive my bad English :(

No support by PM/Email - Thanks - You can thanks me here :) - Pay me for installing MOD's :lol:
mrbandit
Registered User
Posts: 88
Joined: Mon Mar 10, 2003 3:51 pm

Post by mrbandit »

Thanks for that, now I've got my start! I'm positive I'll be back to beg for help again very soon :lol:
User avatar
morpheus2matrix
Former Team Member
Posts: 9171
Joined: Wed Apr 10, 2002 7:31 pm
Location: France
Contact:

Post by morpheus2matrix »

You're welcome :)
Former phpBB MOD-Team Member -

Forgive my bad English :(

No support by PM/Email - Thanks - You can thanks me here :) - Pay me for installing MOD's :lol:
User avatar
LLKwerv
Registered User
Posts: 201
Joined: Mon Mar 03, 2003 3:21 pm
Location: Here, there, everywhere
Contact:

Post by LLKwerv »

by the way, you do not need to include db.php if you are using mysql_connect, mysql_query, etc.

You only need it if you use the phpBB object-based db-connection,

Code: Select all

eg. $db->sql_query($sql);
which is equibvalent to mysql_query($sql) but translates it into whatever language needed, for example msSQL or PostgreSQL. But, if you have mySQL, this is irrelevant so do whatever works.
this here be a sig
Post Reply

Return to “[2.0.x] MOD Writers Discussion”