News: When asking for support, it helps us and you, if you read the Posting Guidelines

Login  |  Register
HTML5 Icon HTML5 Icon
TP on Social Media
Welcome, Guest. Please login or register.
Did you miss your activation email?

October 18, 2019, 09:14:15 PM

Login with username, password and session length

Recent

Members
  • Total Members: 3756
  • Latest: Ocean
Stats
  • Total Posts: 189090
  • Total Topics: 20764
  • Online Today: 73
  • Online Ever: 629
  • (November 08, 2018, 01:36:54 PM)
Users Online
Users: 0
Guests: 36
Total: 36

Author Topic: Adding database info  (Read 3920 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]
<?php

mysql_connect
("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 »