Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media


Welcome, Guest. Please login or register.
Did you miss your activation email?

September 26, 2020, 11:21:13 AM

Login with username, password and session length
  • Total Posts: 190994
  • Total Topics: 20891
  • Online Today: 107
  • Online Ever: 917
  • (January 21, 2020, 09:02:26 AM)
Users Online
Users: 1
Guests: 81
Total: 82

Author Topic: Adding database info  (Read 4250 times)

0 Members and 1 Guest are viewing this topic.

Offline rebelrose

  • Friends
  • *
  • Posts: 945
Adding database info
« on: June 04, 2007, 05:08:31 PM »
Is it possible to put information from a database that is not on the same site into a block?

Offline IchBin

  • Developer
  • *
  • Posts: 16228
    • My Website
Re: Adding database info
« Reply #1 on: June 04, 2007, 05:39:40 PM »
If you're calling data directly from the database it has to be configure to allow the connection from the place that you're calling it from. MySQL DB's are configured by default to only allow connections from inside the same machine.
Other ways you can do it is to have a cronjob export your data to a file at certain times of the day. Then you can have a script pickup the info in that file and do what you need with it.

Offline rebelrose

  • Friends
  • *
  • Posts: 945
Re: Adding database info
« Reply #2 on: June 04, 2007, 05:40:58 PM »
Thank You IchBinâ„¢  :)

Nikki Sixx

  • Guest
Re: Adding database info
« Reply #3 on: June 04, 2007, 06:18:12 PM »
I suppose this scenario would work:

You must be granted a MySQL user account with the privilege "SELECT" (or "ALL") from the SMF database where the block is you want to copy. Your Web server's hostname or IP address must also be permitted to access the MySQL database where that SMF database is housed. You can use this PHP script-

Code: [Select]

("your-servers-hostname/IP""your-given-username""your-given-password") or die(mysql_error());

mysql_select_db("their-SMF-database") or die(mysql_error());

$sql 'SELECT * FROM 'smf_tp_blocks' WHERE ( ('smf_tp_blocks' . 'id' = ?? ) ) ';


and where "??" (no surrounding quotes in query) would be the numerical value of the block you wish to copy from their table/database.

In PHPMyAdmin or whatever you like, create a new row in the "smf_tp_blocks" table of your database and enter the same numerical value in the "id" field (both must match). Another PHP script (which I can not write :P) can then import the row's field values you got from the above script which dynamically gathered the block from the other SMF forum you wanted.
« Last Edit: June 04, 2007, 06:21:40 PM by Nikki Sixx »