Getting Variables from the Forum? How

Started by blood618^_^, July 25, 2007, 01:24:24 AM

Previous topic - Next topic

blood618^_^

Lets say I wanna get this Variables from the forum What should I do?

Username
User's number of post
User's Profile Information
User's Avatar

Users own Profile, My Message link and if in a certain group member (i.e. Admin, moderator, etc) a Certain link will show up.

Recent Topics from a certain forum board (example show only news and announcement post) just the Subject line and its link

Latest Post just the subject line and its link.

Things like that.

i was looking at the files and sources and what i've found out is the

global $content and some other stuff.. The page is not really inside the forums. but the templates its using will be same as the board default. how would this be possible? thanks :D

spottedhog

print_r($context);
--or--
echo '<pre>', print_r($context, true), '</pre>'; //<--goes in the template somewhere

//or for users
print_r($user);

blood618^_^

#2
how did you get this code? what are the possible variables that are inside those $codes?

what globals and files i should use to make this work? should i copy index.php ?

::EDIT::

Im sorry if im this much of an idiot. Im really lost with this even though i wanna understand it. please help. thx.

spottedhog

Where did I get it???  lol   ;D

I am here nearly every day, reading, and when I find something I think may be useful sometime, I save it.  I got this long ago.

The key is probably to use the print_r($context); code on the page where you wish to call the variables.  This way you will see an array of everything available.  Each page may contain different things, so it is good not to assume...   :)

blood618^_^

#4
i see. this is a php file right ? so it should be in the same folder where everyone goes? hmmm *testing*


::EDIT::

I got this Code


<?php

echo '<pre>'print_r($contexttrue), ' </pre>';

?>


actually this is your code it didnt work. is there any files i need to suplement this code? security.php? source code like that?

spottedhog

you need to make sure that $context is called in the globals.....  Above that code, put:

globals $context;

blood618^_^

umm no required files even outside the forum folder?

you need to require settings and other files right? before it can load up the variables? ... and the SQL ? im just guessing right now because my pc is having some problems...

spottedhog

you do need to require....

like this:

<?
require_once('path/to/SSI.php');
global $context;
echo '<pre>', print_r($context, true), ' </pre>';
?>


blood618^_^

Thanks for that .. it works! :D

how about latest threads and topics???

i've seen global $topic, $board what is the file required for this one?  and also how can i include permissions to work on this specific page?


I've been reading the index files and load.php hoping to learn more about this... again thanks... right now... im lookin for the topics and the possible permissions to exist when  certain thinggies occur...

Dragooon

You can use SSI functions for latest threads, topics
Or make custom DB queries.

blood618^_^

#10
Im really sorry if im such a burden... I really looking for the solution on this...

require_once('forums/SSI.php');
global 
$context$topic$board;

	
echo 
'<pre>'print_r($topictrue), ' </pre>
	
<br><br><br><br><br>'
;

	
echo 
'<pre>'print_r($boardtrue), ' </pre>
	
<br><br><br><br><br>'
;


It didnt work... although my globals already indicate them the latest threads and topics didnt show...

what i want to do is to make the a specific board(e.g. News and Announcements) show its latest 5(Number of results) topics titles along with its link...

also i want to show my users the 10 latest threads which is only in thier permissions... somewhat like the ones from the bottom of the board (latest threads) where you can see a link of a thread...

Those topics will only show a # of characters so that it wont move the certain table...

does anyone get what i mean? im sorry if im vague in my information... please ask if you are confused with this... thanks...
==============================
I was reading the SSI.php but i havent read it completely yet...  although i've read some interesting stuff already...


::EDIT::

Umm.. Once i call the SSI.php that means i can use its functions right ? can i just add new functions in my newfile to coordinate with the SSI?

how do you call functions in SSI ?

(and yes sadly... i still want some answers on my questions before the ::EDIT:: message... :( )

Dragooon

#11

require('/path/to/SMF/SSI.php');
require('/path/to/SMF/Settings.php');
global $scripturl, $db_prefix, $context,$txt;

$result = mysql_query("
SELECT
m.id_msg, m.subject, m.body, t.id_topic, t.id_board,
b.name AS bname, m.id_member
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}members AS mem, {$db_prefix}boards AS b
WHERE t.id_board = 1
AND b.id_board = 1
AND m.id_msg = t.id_first_msg
AND mem.id_member = m.id_member
ORDER BY t.id_topic DESC
LIMIT 5") or die(mysql_error());

while ($row = mysql_fetch_array($result))
{
$bodylen = 200;
// Limit the length of the message, if the option is set.
if (strlen(str_replace('<br />', "\n", $row['body'])) > $bodylen)
$row['body'] = htmlspecialchars(substr(str_replace('<br />', "\n", un_htmlspecialchars($row['body'])), 0, $bodylen-3) . '...', ENT_QUOTES);


censorText($row['body']);
censorText($row['subject']);


$context['news][] = array(
'title' => $row['subject'],
'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
'description' => $row['body'],
'author' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : '',
'comments' => $scripturl . '?action=post;topic=' . $row['id_topic'] . '.0',
'guid' => $row['id_msg'],
                        'replies' => $row['numReplies']
);

You can use this code to call 5 latest topics from a Board. It will show first 200 letters from it.
Edit WHERE t.id_board = 1
AND b.id_board = 1

To determine your board ID.
Edit $bodylen = 200; to determine your character limit
Edit LIMIT 5 to limit the no. of topics.

Now to throw it out you need
foreach( $context['ghinfo'] as $info)
echo'
<strong><br><a href="', $info['link'], '">', $info['title'], '</strong></a>
<span>', $info['description'];
)
( I didnt properly tested this thing so it may give errors.)

For Recent topics
global $scripturl, $db_prefix, $context, $smfFunc, $txt, $user_info, $modSettings;
//Main query
$result = db_query("
SELECT
m.id_msg, m.subject, m.body, t.id_topic, t.id_board,
b.name AS bname,m.id_member,b.memberGroups
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}members AS mem, {$db_prefix}boards AS b
WHERE t.id_board = b.id_board
AND m.id_msg = t.id_first_msg
AND mem.id_member = m.id_member
AND b.memberGroups = b.memberGroups
AND $user_info[query_see_board]
AND ID_BOARD != $modSettings[recycle_board]
ORDER BY t.id_topic  DESC
LIMIT 5") or die(mysql_error());

while ($row = mysql_fetch_assoc($result))
{      //The variable which decides the MAX letters it can have.
$bodylen = 200;
// Limit the length of the message, if the option is set.
if (strlen(str_replace('<br />', "\n", $row['body'])) > $bodylen)
$row['body'] = htmlspecialchars(substr(str_replace('<br />', "\n", un_htmlspecialchars($row['body'])), 0, $bodylen-3) . '...', ENT_QUOTES);


censorText($row['body']);
censorText($row['subject']);

$context['rp'][] = array(
'title' => $row['subject'],
'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
'description' => $row['body'],
'category' =>  $scripturl .'?board=' .$row['id_board'] . '.0',
'bname' => $row['bname']
);
}
foreach( $context['rp'] as $info)
echo'
<dt><br><a href="', $info['link'], '">', $info['title'], '</a></dt>
<dd>', $info['description'], '<br>posted in <a href ="',$info['category'],'">',$info['bname'],'</a></dd>
</dlv>';


This code will show 5 recent posts from any board.Its maximum letter limit would be 200 if crossed it will be "...".

Customization :
To limit the number of topics shown:
See that LIMIT 5 and edit the 5 to no. of posts you want.

To show posts from 1 board.
See that t.id_board = b.id_board.Edit it and change it to t.id_board = <Your Board ID> AND b.id_board = <Your Board ID>
Make the Board ID to match the ID of the board you want to show.Remember BOTH entries must be same.

To limit the length of max body letters which can be shown:
Find $bodylen = 200; and edit 200 with what you want.

To remove a description remove ', $info['description'], '

spottedhog

Here... let me throw this out....  The code you placed in a reply:

echo '<pre>', print_r($topic, true), ' </pre>



<br><br><br><br><br>';



echo '<pre>', print_r($board, true), ' </pre>



<br><br><br><br><br>';


...is not "globaled" like $context.  $context is set up in one of the Sources file (forget which one) and this is why you can call it to see all the variables.  There is no such thing for $topic or $board, mainly because it is not needed.  $context contains all info possible.

Dragooon

$context is not stored in 1 single file. It is stored in nos of files.

ioszilla

Quote$context is set up in one of the Sources file (forget which one)

It's initialized in index.php (in root installation folder):

Line #77:

$context = array();

Dragooon

No
have a closer look. $context is defined at many different places. The root $context is at index.php but you really cannot use a heck out of it.

ioszilla


felcon

Quote from: wordzilla on August 13, 2007, 07:27:34 AM
Quote$context is set up in one of the Sources file (forget which one)

It's initialized in index.php (in root installation folder):

Line #77:

$context = array();

$context is only "defined" in index.php but it's been assigned values in various files. mostly in .php files in the source directory.

blood618^_^

#18
I fixed the script... yeah there were some missing brackets and quotes but its fixed and nicely done... i turned it into functions and i received this error

QuoteDatabase Error: No database selected
File: /home/blood618/public_html/forums/Sources/Load.php
Line: 2017

::EDIT::

This was that line:


function sessionDestroy($session_id)
{
global $db_prefix;

if (preg_match('~^[A-Za-z0-9]{16,32}$~', $session_id) == 0)
return false;

// Just delete the row...
return db_query("
DELETE FROM {$db_prefix}sessions
WHERE session_id = '" . addslashes($session_id) . "'
LIMIT 1", __FILE__, __LINE__);
}


::EDIT::

This is the whole code fixed and stuff...


<?php

require('---MYFORUMPATH/SSI.php');
require(
'---MYFORUMPATH/Settings.php');

function 
recent_news()
{
global 
$scripturl$db_prefix$context,$txt;

$result mysql_query("
SELECT
m.id_msg, m.subject, m.body, t.id_topic, t.id_board,
b.name AS bname, m.id_member
FROM 
{$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}members AS mem, {$db_prefix}boards AS b
WHERE t.id_board = 1
AND b.id_board = 1
AND m.id_msg = t.id_first_msg
AND mem.id_member = m.id_member
ORDER BY t.id_topic DESC
LIMIT 5"
) or die(mysql_error());

while ($row mysql_fetch_array($result))
{
$bodylen 20;
// Limit the length of the message, if the option is set.
if (strlen(str_replace('<br />'"\n"$row['body'])) > $bodylen)
$row['body'] = htmlspecialchars(substr(str_replace('<br />'"\n"un_htmlspecialchars($row['body'])), 0$bodylen-3) . '...'ENT_QUOTES);


censorText($row['body']);
censorText($row['subject']);


$context['news'][] = array(
'title' => $row['subject'],
'link' => $scripturl '?topic=' $row['id_topic'] . '.0',
'description' => $row['body'],
'author' => !empty($row['id_member']) ? $scripturl '?action=profile;u=' $row['id_member'] : '',
'comments' => $scripturl '?action=post;topic=' $row['id_topic'] . '.0',
'guid' => $row['id_msg'],
                        
'replies' => $row['numReplies']
);
}

}

function 
recent_topics()
{
global 
$scripturl$db_prefix$context$smfFunc$txt$user_info$modSettings;
//Main query
$result db_query("
SELECT
m.id_msg, m.subject, m.body, t.id_topic, t.id_board,
b.name AS bname,m.id_member,b.memberGroups
FROM 
{$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}members AS mem, {$db_prefix}boards AS b
WHERE t.id_board = b.id_board
AND m.id_msg = t.id_first_msg
AND mem.id_member = m.id_member
AND b.memberGroups = b.memberGroups
AND 
$user_info[query_see_board]
AND ID_BOARD != 
$modSettings[recycle_board]
ORDER BY t.id_topic  DESC
LIMIT 5"
) or die(mysql_error());

while ($row mysql_fetch_assoc($result))
{      //The variable which decides the MAX letters it can have.
$bodylen 20;
// Limit the length of the message, if the option is set.
if (strlen(str_replace('<br />'"\n"$row['body'])) > $bodylen)
$row['body'] = htmlspecialchars(substr(str_replace('<br />'"\n"un_htmlspecialchars($row['body'])), 0$bodylen-3) . '...'ENT_QUOTES);


censorText($row['body']);
censorText($row['subject']);

$context['rp'][] = array(
'title' => $row['subject'],
'link' => $scripturl '?topic=' $row['id_topic'] . '.0',
'description' => $row['body'],
'category' =>  $scripturl .'?board=' .$row['id_board'] . '.0',
'bname' => $row['bname']
);
}
foreach($context['rp'] as $info)
echo'
<dt><br><a href="'
$info['link'], '">'$info['title'], '</a></dt>
<dd>'
$info['description'], '<br>posted in <a href ="',$info['category'],'">',$info['bname'],'</a></dd>
</dlv>'
;
}



?>



again thanks... im really getting things now step by step... (btw whats nos?)

ioszilla

Quoterequire('---MYFORUMPATH/SSI.php');
require('---MYFORUMPATH/Settings.php');

Change it to:

Quote
require('---MYFORUMPATH/Settings.php');
require('---MYFORUMPATH/SSI.php');

Dragooon

Yeah he is right.
SSI came up first and jacked it up :P

blood618^_^

#21
lol I forgot... this really shows that im not good in coding... i forgot that you should initialize first before calling all functions and variables....

(btw? you call the functions by name(); right?)

*will post if found more errors*

::EDIT::

It showed the whole forum... even the templates... (it was suppose to be topics only right??? but not the Home index.php) i was expecting it to out with just the txt and its link

QuoteWarning: Missing argument 2 for db_query(), called in /home/blood618/public_html/testindex.php on line 57 and defined in /home/blood618/public_html/forums/Sources/Subs.php on line 238

Warning: Missing argument 3 for db_query(), called in /home/blood618/public_html/testindex.php on line 57 and defined in /home/blood618/public_html/forums/Sources/Subs.php on line 238

I've seen the WHOLE template... my avatar, logo header which is not suppose to happen... and then in the error box it shows:

QuoteColumn 'ID_BOARD' in where clause is ambiguous
File:
Line:



45 $result = db_query("
46 SELECT
47 m.id_msg, m.subject, m.body, t.id_topic, t.id_board,
48 b.name AS bname,m.id_member,b.memberGroups
49 FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}members AS mem, {$db_prefix}boards AS b
50 WHERE t.id_board = b.id_board
51 AND m.id_msg = t.id_first_msg
52 AND mem.id_member = m.id_member
53 AND b.memberGroups = b.memberGroups
54 AND $user_info[query_see_board]
55 AND ID_BOARD != $modSettings[recycle_board]
56 ORDER BY t.id_topic  DESC
57 LIMIT 5") or die(mysql_error());
58
59 while ($row = mysql_fetch_assoc($result))
60 {      //The variable which decides the MAX letters it can have.
61 $bodylen = 200;
62 // Limit the length of the message, if the option is set.
63 if (strlen(str_replace('<br />', "\n", $row['body'])) > $bodylen)
64 $row['body'] = htmlspecialchars(substr(str_replace('<br />', "\n", un_htmlspecialchars($row['body'])), 0, $bodylen-3) . '...', ENT_QUOTES);
65


Pure Code:
$result = db_query("
SELECT
m.id_msg, m.subject, m.body, t.id_topic, t.id_board,
b.name AS bname,m.id_member,b.memberGroups
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}members AS mem, {$db_prefix}boards AS b
WHERE t.id_board = b.id_board
AND m.id_msg = t.id_first_msg
AND mem.id_member = m.id_member
AND b.memberGroups = b.memberGroups
AND $user_info[query_see_board]
AND ID_BOARD != $modSettings[recycle_board]
ORDER BY t.id_topic  DESC
LIMIT 5") or die(mysql_error());

while ($row = mysql_fetch_assoc($result))
{      //The variable which decides the MAX letters it can have.
$bodylen = 200;
// Limit the length of the message, if the option is set.
if (strlen(str_replace('<br />', "\n", $row['body'])) > $bodylen)
$row['body'] = htmlspecialchars(substr(str_replace('<br />', "\n", un_htmlspecialchars($row['body'])), 0, $bodylen-3) . '...', ENT_QUOTES);


spottedhog

I believe the reason you "initialize" first is more related to security than anything else.  Take a close look at the coding in the SSI.php file for a ssi function.  You will see many times where a variable is initialized, but the key is, it is initialized as an empty array.

For example: $return = array();

What this does is to ensure the variable $return has nothing in it before it is populated.

Dragooon

Oh replace the db_query with mysql_query
And also after adding require('pathtosmf/Settings.php'); Add mysql_connect($db_server, $db_user, $db_passwd); and then mysql_select_db($db_name); and then rest of the code

blood618^_^

It worked! :D

but this one didnt

global $scripturl, $db_prefix, $context, $smfFunc, $txt, $user_info, $modSettings;
//Main query
$result = mysql_query("
SELECT
m.id_msg, m.subject, m.body, t.id_topic, t.id_board,
b.name AS bname,m.id_member,b.memberGroups
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}members AS mem, {$db_prefix}boards AS b
WHERE t.id_board = b.id_board
AND m.id_msg = t.id_first_msg
AND mem.id_member = m.id_member
AND b.memberGroups = b.memberGroups
AND $user_info[query_see_board]
AND ID_BOARD != $modSettings[recycle_board]
ORDER BY t.id_topic  DESC
LIMIT 5") or die(mysql_error());

while ($row = mysql_fetch_assoc($result))
{      //The variable which decides the MAX letters it can have.
$bodylen = 20;
// Limit the length of the message, if the option is set.
if (strlen(str_replace('<br />', "\n", $row['body'])) > $bodylen)
$row['body'] = htmlspecialchars(substr(str_replace('<br />', "\n", un_htmlspecialchars($row['body'])), 0, $bodylen-3) . '...', ENT_QUOTES);


censorText($row['body']);
censorText($row['subject']);

$context['rp'][] = array(
'title' => $row['subject'],
'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
'description' => $row['body'],
'category' =>  $scripturl .'?board=' .$row['id_board'] . '.0',
'bname' => $row['bname']
);
}
foreach($context['rp'] as $info)
echo'
<dt><br><a href="', $info['link'], '">', $info['title'], '</a></dt>
<dd>', $info['description'], '<br>posted in <a href ="',$info['category'],'">',$info['bname'],'</a></dd>
</dlv>';


This was the mentioned Error...


Column 'ID_BOARD' in where clause is ambiguous


What i've learn from this is that it doesnt know which field we are using... so definitely we have to initialize the t.ID_BOARD's Column... or is it the 'category' =>  $scripturl .'?board=' .$row['id_board']. '.0', that gives the error?

I really wanna know what are the codes used so i can just do it myself... i love coding... but the problem is i really dont have knowledge on this... specially in mysql... anyways again THANKS! the other one worked already...

whats the difference between t.id_board to board?



Dragooon

OK I figured out why.
In $result = mysql_query("
SELECT
m.id_msg, m.subject, m.body, t.id_topic, t.id_board,
b.name AS bname,m.id_member,b.memberGroups
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}members AS mem, {$db_prefix}boards AS b
WHERE t.id_board = b.id_board
AND m.id_msg = t.id_first_msg
AND mem.id_member = m.id_member
AND b.memberGroups = b.memberGroups
AND $user_info[query_see_board]
AND ID_BOARD != $modSettings[recycle_board]
ORDER BY t.id_topic  DESC
LIMIT 5") or die(mysql_error());


See the last AND statement it is just ID_BOARD it should be b.ID_BOARD so at end it should be $result = mysql_query("
SELECT
m.id_msg, m.subject, m.body, t.id_topic, t.id_board,
b.name AS bname,m.id_member,b.memberGroups
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}members AS mem, {$db_prefix}boards AS b
WHERE t.id_board = b.id_board
AND m.id_msg = t.id_first_msg
AND mem.id_member = m.id_member
AND b.memberGroups = b.memberGroups
AND $user_info[query_see_board]
AND b.ID_BOARD != $modSettings[recycle_board]
ORDER BY t.id_topic  DESC
LIMIT 5") or die(mysql_error());


The difference between t.id_board and board is that t.id_Board means it is the board ID from topic table where is board is in just general to nothing.

blood618^_^

#26
wow.. ^^,

I think this is the last one...

How can I apply the [b] bbtags [/b]  (bbcodes) in that page?

::EDIT::
ANSWER: parse_bbc('message here');
::EDIT::

this is really cool... im starting to understand some parts in SMF ^^,

::EDIT::

I wanna learn more about the parts of the code...

I mean, by getting variables from database (in the code) by using this code...  (getting authors and getting everything for a topic things like that)...

I was reading the code and it looked the same... in some parts its not... I wish to learn every part of it...

i'll post another regarding my explanation about thw whole code... and please correct me if im wrong...  thanks :D  i just want to test if i understnad the whole code well...

blood618^_^

The Code Explanation based on my understandng...

$result = mysql_query("
SELECT
m.id_msg, m.subject, m.body, t.id_topic, t.id_board,
b.name AS bname, m.id_member
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}members AS mem, {$db_prefix}boards AS b
WHERE t.id_board = 1
AND b.id_board = 1
AND m.id_msg = t.id_first_msg
AND mem.id_member = m.id_member
ORDER BY t.id_topic DESC
LIMIT 5") or die(mysql_error());


This is a Small part of code in the file... and by this i will explain further...

$result = mysql_query("

This means the result that mysql_query (a Mysql Command) will have will be placed on the $result variable...

SELECT
m.id_msg, m.subject, m.body, t.id_topic, t.id_board,
b.name AS bname, m.id_member


I dont get this part that much... This selects the table id_msg in the database? i really dont get this part specially why it has prefixes like "m." or "t."

FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}members AS mem, {$db_prefix}boards AS b

means from your forum database prefix (eg. smf_) like smf_topics, messages and members are being called starting there... but again i dont know whats the "AS" mem "AS" B ...

although this looks like the prefix of the variables i still dont get it but it does sound like m.id_msg is M as the table name and id_msg is the column...

WHERE t.id_board = 1
AND b.id_board = 1
AND m.id_msg = t.id_first_msg
AND mem.id_member = m.id_member


somewhat like a condition where they initialize the variables... i dont get it why do they have to change the values for "AND m.id_msg = t.id_first_msg ---and--- AND mem.id_member = m.id_member"...

although im guessing... that it wont replace the variables inside the t.id_first_msg and m.id_member ???

ORDER BY t.id_topic DESC

it is being ORDERED  DESCending sort... in t.id_topic... meaning whoever has the highest id number topic  wll be the first one to be released...

NOTE: id_topic is the column for the numbers where latest and last a differentiated....

LIMIT 5") or die(mysql_error());

it is only limited by 5 and if the mysql_query failes all this arguments... it will stop and die... (die sounds like a harsh word but i think its also a command)



Next line of command is

while ($row = mysql_fetch_assoc($result))
{      //The variable which decides the MAX letters it can have.
$bodylen = 200;
// Limit the length of the message, if the option is set.
if (strlen(str_replace('<br />', "\n", $row['body'])) > $bodylen)
$row['body'] = htmlspecialchars(substr(str_replace('<br />', "\n", un_htmlspecialchars($row['body'])), 0, $bodylen-3) . '...', ENT_QUOTES);


okay next explanation:

while ($row = mysql_fetch_array($result))

i dont know what the mysql_fetch_array($result) is but if it equals to $row (which i also dont know how did it argumented since $row was not declared on the file.. and i dont know how would that equaled to mysql_fetch_array...) mysql_fetch_array it will be moved to the next function...

$bodylen = 200;

Maximum characters lenght...

if (strlen(str_replace('<br />', "\n", $row['body'])) > $bodylen)
$row['body'] = htmlspecialchars(substr(str_replace('<br />', "\n", un_htmlspecialchars($row['body'])), 0, $bodylen-3) . '...', ENT_QUOTES);


Honestly i have a little idea... This talks about the string...  but i dont know what it is because  dont know what are those commands and what are they used for....

=======================
Will be continuing on the next post.! :D

spottedhog

You got the arguement2 and arguement3 errors because you did not have the db_query function properly coded.  The db_query function requires this -->  , __FILE__, __LINE__  at the end of the query.  This serves as the mysql_error code by displaying the file and line number of the error, if there is one.

Dragooon

Ok well.
What you tried to explained actually you were more of asking questions :P
So Here is what it actually means.
$result = mysql_query("
SELECT
m.id_msg, m.subject, m.body, t.id_topic, t.id_board,
b.name AS bname, m.id_member
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}members AS mem, {$db_prefix}boards AS b
WHERE t.id_board = 1
AND b.id_board = 1
AND m.id_msg = t.id_first_msg
AND mem.id_member = m.id_member
ORDER BY t.id_topic DESC
LIMIT 5") or die(mysql_error());


Well You were right the mysql query is stored in $result so it doesent makes a difference to re-explain it.

Next was SELECT
m.id_msg, m.subject, m.body, t.id_topic, t.id_board,
b.name AS bname, m.id_member

It was selecting rows from table. Now in this m.id_message means id_message row from the table where it was m. I used this because of multiple table assigning.

Then comes the FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}members AS mem, {$db_prefix}boards AS b
Here we selected tables from the tables and assigned them to letters. Like messages table became m. So m.id_message meant id_message row from message table.

Then came ... WHERE t.id_board = 1
AND b.id_board = 1
AND m.id_msg = t.id_first_msg
AND mem.id_member = m.id_member


Well as said it decided conditions.

Rest of the code, I'll explain soon.

Advertisement: