Jump to content

PHP and MySql


Phenomena

Recommended Posts

Though this is my first time trying to create a whole new page with php, i do have a bit of experience through installing mods on my phpBB forums.

Ive managed to get it so that im connected to the same database my phpBB forums are installed on. Now what I'm trying to do i get it so that the text from each post in a specific forum is displayed on the page. I can't seem to figure this out. Any help would be greatly appreciated.
Link to comment
Share on other sites

Select the data you want using a SELECT sql statement and [url=http://php.net/mysql_query]mysql_query[/url], then loop through the result using [url=http://php.net/mysql_fetch_assoc]mysql_fetch_assoc[/url] to grab each row.
Link to comment
Share on other sites

This is a shameless plug....
Check out http://www.iobe.net/proj/
I have a program I'm working on and I have some "beta versions" available for download.  There are two choices application builder and script builder.  The appbuilder builds what I like to call and application and script builder builds individual scripts.  The only real difference is that application builder calls index.php passing its name to it and the script builder scripts call themeselves so they are stand alone.

The result is 1 php script per table in your database.  It really only fully works for tables with 1 primary key but you can go in and edit the files easily. They are pretty simple.  I'm working on having it work with multiple keys or no keys at all and I should have it done soon.

Sounds to me that script builder will work for your purposes....

At minimum, it will make a script that you can look at and see what is going on.

Feedback would also be kool. 

Regards,
John Sladek
Link to comment
Share on other sites

ugh, ive managed to compile a test script but its not working properly, i dont get any php errors but It doesnt display the rank title

[code]$username="********";
$password="********";
$database="********";

mysql_connect(localhost,$username,$password);

@mysql_connect_db($database) or die ("Unable to connect to the database.");

$query="SELECT * FROM phpbb_ranks";
$result=mysql_query($query);

$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {

$first=mysql_result($result,$i,"rank_title");

echo "rank_title";

$i++;
}[/code]
Link to comment
Share on other sites

try this...

<?
$username="********";
$password="********";
$database="********";

mysql_connect(localhost,$username,$password);

@mysql_connect_db($database) or die ("Unable to connect to the database.");

$query="SELECT * FROM phpbb_ranks";
$result=mysql_query($query);
while($row = mysql_fetch_array($result)) {
print("$row[rank_title]<br>");
}
mysql_close();

?>
Link to comment
Share on other sites

I'm sure there are, I'm trying to get it to do what I want it to first.  I am thinking about security too, just back burnered it for now.  Did you actually try running the program against a database?  If so, besides the obvious security issues, what do you think?
Link to comment
Share on other sites

Ok, Thanks rab for showing me the error in my ways.  I made a quick fix to validate someone sneaking in a link like that and I'll have to fix the other issues before allowing a live demo.  I think I was just a little over excited about the program I'm working on..... to me it's cool.....


....anyhow, Phenomena, did you ever get your program to work?
Link to comment
Share on other sites

sorry for late reply, i did... well almost. Since i dont have enough knowledge of php to make my own, safe page. I decided to download a phpBB mod and change it around to work on my main page

http://modhalotrial.com/test.php

only problem is i need to read it from a certain forum, right now it just reads from every forum. There is something in the orginal phpBB mod to do this but you need to be able to create arrays.

[code]// exclude forums from fetching
// can be left blank to disable it, can contain a single forum id or an array
// with multiple id's
//

$CFG['posts_exclude_forums'] = '';[/code]

i dont know how to turn that into an array lol

edit: never mind i got it :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.