Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
xGSTQ
Involved
Involved


Joined: Feb 03, 2006
Posts: 267
Location: UK

PostPosted: Fri Jan 22, 2010 9:36 am Reply with quote

ok so im converting an Evo module to work on RN

Its RottNAudio module

Ive not asked the owner of the module (RottNKorpse) because I have looked though is forum support section and he states PHPNuke is dead and this module will only work on Evo and Evo Extreme.. and that he has no intention to convert it any other distro.

However once I do get it all working okay, I will email him a asking for permission to release it to the RN community.

Anyway's that to one side, I got it working on Ravens Nuke, but with one small problem I just cant sort.

What I am stuck on is calling the Database from a database.php file that is included in a playlist.php file

The Evo database.php file is simply

Code:
include('../../config.php');

$dbcnx = mysql_connect("$dbhost","$dbuname","$dbpass");
$dbselect = mysql_select_db("$dbname");
if ((!$dbcnx) || (!$dbselect)) { echo "Can't connect to database"; }


And it calls the DB fine and works no problem

However to get the same thing working in RN I have to change the above code to
Code:
$dbhost = '******';

$dbuname = '******';
$dbpass = '******';
$dbname = '******';
$prefix = '******';
$dbcnx = mysql_connect("$dbhost","$dbuname","$dbpass");
$dbselect = mysql_select_db("$dbname");
if ((!$dbcnx) || (!$dbselect)) { echo "Can't connect to database"; }


that connects and it all works fine...

Basicly is there an easier way to do it so users don't have to input the DB details into the database.php file it uses ??

I tried to bypass the database.php by using the below code but that didn't work either

Code:
require_once ('mainfile.php');

global $db, $prefix;

$result = $db->sql_query("SELECT * FROM ".$prefix."_rottnaudio_config");
$song_order_sql = $db->sql_fetchrow($result);
$song_order = $song_order_sql['song_order'];
$playlist_sql = $db->sql_query("SELECT * FROM ".$prefix."_rottnaudio_songs ORDER BY ".$song_order." ASC") or die('Query failed: ' . mysql_error());


Any help or advice please
 
View user's profile Send private message Send e-mail Visit poster's website
Palbin
Site Admin


Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Fri Jan 22, 2010 4:05 pm Reply with quote

Code:


require_once ('mainfile.php');
global $db, $prefix;

$result = $db->sql_query("SELECT * FROM ".$prefix."_rottnaudio_config");
$song_order_sql = $db->sql_fetchrow($result);
$song_order = $song_order_sql['song_order'];
$playlist_sql = $db->sql_query("SELECT * FROM ".$prefix."_rottnaudio_songs ORDER BY ".$song_order." ASC") or die('Query failed: ' . mysql_error());


The above should work. There has to be some details you are not mentioning. If you wnat to send it to me I can take a look at it, but if it is a module and you are doing the above it should work fine.

_________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. 
View user's profile Send private message
xGSTQ
PostPosted: Fri Jan 22, 2010 4:55 pm Reply with quote

Ill pack it up in the morning and PM u a link m8, its baffled me... probably something really simple and daft that ive just over looked.

Thanks
 
eldorado
Involved
Involved


Joined: Sep 10, 2008
Posts: 424
Location: France,Translator

PostPosted: Fri Jan 22, 2010 8:40 pm Reply with quote

Weird lol , Palbin's technique here is the best to call DB without config.

Didn't you say it didn't work by directly calling config.php?

_________________
Only registered users can see links on this board! Get registered or login! (My RN site)- Only registered users can see links on this board! Get registered or login!(cod4 clan) - Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website MSN Messenger
Palbin
PostPosted: Fri Jan 22, 2010 8:50 pm Reply with quote

I have emailed the corrected files to xGSTQ. All that was needed was to define INCLUDE_PATH in database.php.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©