TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,022
  • Total Topics: 21,332
  • Online today: 899
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 712
  • Total: 713
  • @rjen

global variables and functions

Started by osquitar, July 10, 2007, 10:59:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

osquitar

Can I take variables and functions used in TP code for my own PHP articles? Is there any document to learn how do this?

Example:

I tried this:

$request=db_query("SELECT * FROM smf_member)

Is $request a global variable?
Is db_query a global function?

Jpg

#1
Well $request is usually when you want to get something from the Mysql database[Hence the prefix db]...
You can but you'll need to know basic php first. What are you trying to accomplish anyway?

jacortina

$request is a local variable.

db_query is a function defined in Sources/Subs.php . That's part of base SMF (not TP). I think they a databse of functions was started over on the SMF site, but I haven't looked it over.

Subs.php should be loaded (and the functions therein should be available) by the time any blocks or articles are evaluated.

One thing I note is that your query lacks a closing quote. Another is that the table I think you want is named smaf_members. db_query also takes three arguments (though I'm not exactly sure how the last two are used)

Try:
$request=db_query("SELECT * FROM smf_members", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
{
echo $row['ID_MEMBER'], ' - ', $row['realName'], '<br />';
}
mysql_free_result($request);


That will print out all of your members numbers and names.

This website is proudly hosted on Crocweb Cloud Website Hosting.