najaru Posted April 4, 2011 Report Share Posted April 4, 2011 (edited) Hi michael. I try to understand how to transform a basic php file to a ipb integrate file (i want just to dont have hany connection to database. The file is this one (but i am not interested in this file, i whant just to print a list of one table fields.... or even just one field..... it's just for understand): <?php $conn= mysql_connect('localhost','ipb','ipb'); if(!$conn)die(mysql_error($conn)); $ris=mysql_select_db("ipb",$conn); if(!$ris)die(mysql_error()); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <?php $idf="2"; $msg="SELECT * FROM `topics`where forum_id=$idf ORDER BY `start_date` DESC LIMIT 0, 3 "; $query=mysql_query($msg); if(!$query) die(mysql_error()); $l=""; while($row= mysql_fetch_assoc($query)){ //Confronto if(strcasecmp($l,substr($row['title'],0,1))!=0){ $l=substr($row['title'],0,1); ?> <?php } ?> <a href="index.php?/topic/<?php echo $row['tid']."-".$row['title'] ?>" target="_blank"> <?php echo $row['title']?></a><?php if($row['description']!="") echo ("<font color='#000000'> - ".$row['description']."</font>") ?> <?php echo $row['seo_first_name']?></br> <?php } ?> </body> </html> in first php section there is the database connection $conn= mysql_connect('localhost','name','password'); Terabyte tell to use this: require_once( 'initdata.php' ); require_once( CP_DIRECTORY.'/sources/base/ipsRegistry.php' ); require_once( IPS_ROOT_PATH . 'sources/base/ipsController.php' ); $registry = ipsRegistry::instance(); $registry->init(); and this: ipsRegistry::DB()->funcName(); but i dont understand how to use this. My php is very very very very low level...... Edited April 4, 2011 by najaru Link to comment Share on other sites More sharing options...
Management Michael Posted April 5, 2011 Management Report Share Posted April 5, 2011 For your database connection, you can load up your forums conf_global.php file and use the login details from there. I use something similar on the main site here, I haven't had a chance to look into loading the IPB registry yet. require_once( "/path_to_forum_folder/conf_global.php" ); $INFO[] = array(); $username = $INFO['sql_user']; $database = $INFO['sql_database']; $password = $INFO['sql_pass']; $mysql = "localhost"; $tableprefix = $INFO['sql_tbl_prefix']; mysql_connect($mysql,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $msg="SELECT * FROM `{$tableprefix}topics` where forum_id=$idf ORDER BY `start_date` DESC LIMIT 0, 3 "; $query=mysql_query($msg); For your second script there, your testing this file in the same directory of your initdata.php file? So it can find the file? najaru 1 Link to comment Share on other sites More sharing options...
najaru Posted April 5, 2011 Author Report Share Posted April 5, 2011 ok i will try my purpose is to create a php, and display it as a iframe in joomla wordpress etc... for display the last ipb discussion for now i try it here http://www.rm-online.it/ (bottom right) but i prefere that mysql data are not present in this file Link to comment Share on other sites More sharing options...
najaru Posted April 5, 2011 Author Report Share Posted April 5, 2011 wow, fantastic, work good!!!!!!!!!!!! thanks ++++ Link to comment Share on other sites More sharing options...
najaru Posted April 5, 2011 Author Report Share Posted April 5, 2011 i have just correct this: $mysql = $INFO['sql_host']; Link to comment Share on other sites More sharing options...
najaru Posted April 6, 2011 Author Report Share Posted April 6, 2011 question: why this file work only if is in the same folder of config file? Link to comment Share on other sites More sharing options...
Management Michael Posted April 6, 2011 Management Report Share Posted April 6, 2011 question: why this file work only if is in the same folder of config file? It doesn't really need to be, as long as the path to the config file is setup, you can have them in different folders. So if you wanted this file on the home page and your forums are in a /forums/ folder, you'd need to make sure the path is correct. Link to comment Share on other sites More sharing options...
najaru Posted April 6, 2011 Author Report Share Posted April 6, 2011 now the config path is require_once( "conf_global.php" ); if i put my file in forums/folder1 how i have to modify my require_once( "conf_global.php" ); ? Link to comment Share on other sites More sharing options...
Management Michael Posted April 7, 2011 Management Report Share Posted April 7, 2011 If your file is going to be a directory below your forums folder you would need to change it to this. You can also put in the full path to the file (depends on your server) e.g. /home/username/public_html/forums/ require_once( "../forums/conf_global.php" ); Link to comment Share on other sites More sharing options...
najaru Posted April 7, 2011 Author Report Share Posted April 7, 2011 /web/htdocs/www.aaaaa.it/home/forums perfectly work good, many thanks Link to comment Share on other sites More sharing options...
Management Michael Posted April 8, 2011 Management Report Share Posted April 8, 2011 As the original issue is resolved, I'll close this topic. If you have any more problems, please don't hesitate to open a new topic. Michael Link to comment Share on other sites More sharing options...
Recommended Posts