Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> v2.3 RN Issues
Author Message
bigcooky
New Member
New Member



Joined: Jul 26, 2008
Posts: 4

PostPosted: Tue Oct 21, 2008 11:42 am Reply with quote

Seem to be getting this error in a few of my custom blocks.

Fatal error: Call to undefined function sql_query()

Code:
global $prefix, $dbi;

Code:
$result = sql_query("select lid, title, hits, url from ".$prefix."_links_links order by linkratingsummary DESC limit 0,$mainlinkstoshow", $dbi);


Any idea what might be causing it ?
 
View user's profile Send private message
bigcooky







PostPosted: Tue Oct 21, 2008 1:21 pm Reply with quote

FIXED

heres what i did for people who may encounter this same problem.

Code:
old code:


$result = sql_query("select lid, title, hits, url from ".$prefix."_links_links order by date DESC limit 0,$newlinkstoshow", $dbi);

while(list($lid, $title, $hits, $url) = sql_fetch_row($result, $dbi)) {
     $title2 = ereg_replace("_", " ", $title);
     $content .= "&nbsp;&nbsp;&nbsp;&nbsp;$a: <a href=\"$url\" target=\"_blank\">$title2</a><br/>";
      $a++;
}


Code:
fixed code:


$sql = "select lid, title, hits, url from ".$prefix."_links_links order by date DESC limit 0,$newlinkstoshow";
$result = $db->sql_query($sql);
while(list($lid, $title, $hits, $url) = $db->sql_fetchrow($result)) {
     $title2 = ereg_replace("_", " ", $title);
     $content .= "&nbsp;&nbsp;&nbsp;&nbsp;$a: <a href=\"$url\" target=\"_blank\">$title2</a><br/>";
      $a++;
}
 
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Tue Oct 21, 2008 1:27 pm Reply with quote

You are using v-e-r-y old code Wink

Look in mainfile.php and at line 218 you should see this block of code. Read the comments and make a decision as to which way you want to go. We recommend updating your code to use the $db logic instead but the choice is yours, at least for this release Smile

Code:
/*

 * The following two lines of code were moved and commented out in RN 2.30.00 to "test the waters" on
 * finding out what old modules/blocks/hacks/etc. are still using this SQL layer that is so
 * old it should be obsoleted.  If you really need these back, uncomment them back.  We will keep this
 * code this way for one more major release as well as keep the includes/sql_layer.php script.
 */
//@require_once(INCLUDE_PATH.'includes/sql_layer.php');
//$dbi = sql_connect($dbhost, $dbuname, $dbpass, $dbname);
 
View user's profile Send private message
bigcooky







PostPosted: Tue Oct 21, 2008 1:35 pm Reply with quote

Are the changes i made up to date? im not much of a coder =)
 
Raven







PostPosted: Tue Oct 21, 2008 1:41 pm Reply with quote

bigcooky wrote:
Are the changes i made up to date? im not much of a coder =)

Cheers :clap:

Also you should remove all instances of $dbi from your global statement after fixing your code.

Change
global $dbi;

To
global $db;
 
bigcooky







PostPosted: Tue Oct 21, 2008 1:45 pm Reply with quote

Thx very much Very Happy
 
CodyG
Life Cycles Becoming CPU Cycles



Joined: Jan 02, 2003
Posts: 714
Location: Vancouver Island

PostPosted: Tue Oct 21, 2008 3:11 pm Reply with quote

I've had the same issue with older module code... Instant Messenger, ZClassifieds, Friendfinder. So, the option in mainfile.php, to include older db calls, ie: using old $dbi, is a life saver.

Many of these older scripts are no longer supported, but they sure are nice to have and my users are going to miss them if they ever disappear. Unless there is a forum to get help updating these older scripts, I guess there is nothing to do but not worry until RN2.4 is on the horizon.

_________________
"We want to see if life is ubiquitous." D.Goldin 
View user's profile Send private message
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6433

PostPosted: Tue Oct 21, 2008 5:04 pm Reply with quote

Not sure 2.4 will fix the older scripts...

_________________
I search, therefore I exist...
nukeSEO - nukeFEED - nukePIE - nukeSPAM - nukeWYSIWYG
 
View user's profile Send private message
Loki
Worker
Worker



Joined: Oct 05, 2003
Posts: 107
Location: Illinois

PostPosted: Tue Oct 21, 2008 5:15 pm Reply with quote

There are numerous mods/blocks that use the old $dbi code. They will all need to be updated. Raven you might need to add this to the FAQ if it is not already in there.
 
View user's profile Send private message Visit poster's website
FireATST
RavenNuke(tm) Development Team



Joined: Jun 12, 2004
Posts: 654
Location: Ohio

PostPosted: Wed Nov 05, 2008 5:09 am Reply with quote

I have some older blocks that I need to try and update. Where can I find information on updating from the $dbi logic to the $db logic? I have searched and googled with not really any luck.
 
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
Palbin
Site Admin



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

PostPosted: Wed Nov 05, 2008 6:42 am Reply with quote

if you guys want help fixing some of these old blocks and modules just post a download or perferabley just the code in a seperat thread on the froums and I will help.

I am not looking to rewrite major mdoules, but you never know Smile

_________________
"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
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Wed Nov 05, 2008 7:01 am Reply with quote

Palbin wrote:
if you guys want help fixing some of these old blocks and modules just post a download or preferabley just the code in a seperate thread on the forums and I will help.
I am not looking to rewrite major modules, but you never know Smile

For those interested in this offer, please use the "blocks" or "modules" forums as appropriate not the RN 2.3 forums where a wider audience might find the information.
 
View user's profile Send private message Send e-mail
FireATST







PostPosted: Thu Nov 06, 2008 7:15 am Reply with quote

Palbin, thanks for your generousity, but I am looking to learn how to do it.....Smile You know the old saying, give a man a fish and feed him one day, or teach him to fish and feed him for a lifetime.....Smile (or something similiar to that)
 
Palbin







PostPosted: Thu Nov 06, 2008 9:16 am Reply with quote

Well generally speaking there only a few genral things you need do.

First is change the $dbi global (You block my have more globals)
Code:


global $prefix, $dbi;


Code:


global $prefix, $db;



Then you need to remove the $dbi from all the quries.
Code:


$result = sql_query("select lid, title, hits, url from ".$prefix."_links_links order by linkratingsummary DESC limit 0,$mainlinkstoshow", $dbi)


Code:


$result = sql_query("select lid, title, hits, url from ".$prefix."_links_links order by linkratingsummary DESC limit 0,$mainlinkstoshow")


Finally you have to change the "query functions"
Code:


sql_query("select lid, ti .........


Code:


$db->sql_query("select lid, ti .........


You need to be carefull because all the functions are not like sql_query were you just append the $db->. For example with the old $dbi way you used sql_fetch_row(), but with the new way it has to be written $db->sql_fetchrow(). There are only a couple of functions that you will need to change, so just check in the newer blocks if you need help with one. Off the top of my head I can't think of the other functions that are different from old to new.


Last edited by Palbin on Fri Nov 07, 2008 9:56 pm; edited 3 times in total 
Palbin







PostPosted: Thu Nov 06, 2008 9:20 am Reply with quote

There are several other things I also look at when updating old blocks. I look to see if $user_prefix is used correctly. (only matters if you use a different prefix for you users table in the db)

I also check the page with [ Only registered users can see links on this board! Get registered or login! ] to make sure it is compliant. This is not a must but just something I like to do.
 
CodyG







PostPosted: Thu Nov 06, 2008 10:44 am Reply with quote

Just a thought or two?Confused

Pablin ... Guardian ... How could we start a new topic in Blocks or Modules as many Old Mods have both block- *and* index.php. ?

G... any chance of starting another forum? Maybe titled Old Mod Updates To RN Standards ?? Smile Maybe a space to pick away at the fixing of these beloved old scripts. They might get some life support if we work together.

Just to keep it sane, I could only work on one script at a time and a 'programmer' I am not. I don't see the gaping flaws like I should. php/mysql, even with a large shelf of books and a six year learning curve, (a fish a month?) is still a beautiful mystery and I can only fiddle among the functions and variables.

An old mod could be declared good-to-go for RN, ie valid and secure. Or not, sadly requiring more life support than we can gather. Perhaps, a forum poll which gathers consensus on a small wish list of desired Old Module /Block scripts? and maybe it would inspire an old author or two?
 
Guardian2003







PostPosted: Thu Nov 06, 2008 10:55 am Reply with quote

I like the idea of "Converting to RN standards" though often times it is just a question of moving to a more efficient way of doing things rather a completely new approach. Kinda like using a washing machine instead of a dolly and bucket or a spin dryer instead of a mangle (yeah I remember them all).

It would be nice to see what Raven thinks as to where the best place would be for something like this. He may want to create a new forum altogether or maybe make use of a Wiki or.. something else.
 
Dawg
RavenNuke(tm) Development Team



Joined: Nov 07, 2003
Posts: 928

PostPosted: Fri Nov 07, 2008 5:54 am Reply with quote

I second the idea of a seperate place to work on and post these blocks. With some guidance I am sure we could get alot of these fixed. I for one would be happy to work on them.

What would really be needed....
Examples of the old code....and the new code. Do X like Z sort of thing.

Dawg
 
View user's profile Send private message
FireATST







PostPosted: Fri Nov 07, 2008 6:20 am Reply with quote

thanks Palbin for the explaination.
 
Susann
Moderator



Joined: Dec 19, 2004
Posts: 3191
Location: Germany:Moderator German NukeSentinel Support

PostPosted: Fri Nov 07, 2008 7:16 am Reply with quote

I will use the for hire forum to fix my old modules witch all use $dbi because I don´t like it that other people work for me without any financial reward.

Since Nuke 7.0 $dbi was changed to $db I believe we had enough time (5 years later) to fix our old blocks and modules cause if I remember correctly it was in the year 2003 when PHP Nuke 7.0 was published.
 
View user's profile Send private message
Dawg







PostPosted: Fri Nov 07, 2008 7:55 am Reply with quote

Susann, I don't really see this is quite that light. Maybe it is lost in translation. What I am asking for a place to post to work on things like this....for both people that are having problems and for people that have already fixed this block or that block.

I give to RN on a regular basis in both time and money. While I personaly am not the worlds greatest coder...I do fairly well with some simple direction and a few examples.

When I create something that is usable in RN. I post it here. I would also encourage others that can to do the same. I do not ask for or expect any reward, financial or otherwise. It is one way to contribute to the fine work that is done by the dev team.

Dawg
 
Susann







PostPosted: Fri Nov 07, 2008 8:20 am Reply with quote

Well, Palbin gave already a good example what is needed to change the old $dbi behavior.
The most will be able to do this alone also there are books available which explains this and the rest of user will post under blocks or modules if they are unsure how to change this.
I just use an other way because my old modules are very complex.

Beneed this Raven offers different services and if you have issues with your scripts and modules you can use his service.
 
Raven







PostPosted: Fri Nov 07, 2008 8:37 am Reply with quote

Guardian2003 wrote:
I like the idea of "Converting to RN standards" though often times it is just a question of moving to a more efficient way of doing things rather a completely new approach. Kinda like using a washing machine instead of a dolly and bucket or a spin dryer instead of a mangle (yeah I remember them all).

It would be nice to see what Raven thinks as to where the best place would be for something like this. He may want to create a new forum altogether or maybe make use of a Wiki or.. something else.


Will this structure work?
[ Only registered users can see links on this board! Get registered or login! ]
 
Guardian2003







PostPosted: Fri Nov 07, 2008 8:54 am Reply with quote

Fantastic, thanks Smile
 
Dawg







PostPosted: Fri Nov 07, 2008 10:26 am Reply with quote

BINGO....Give that man a Prize!

Dawg
 
Display posts from previous:       
Post new topic   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> v2.3 RN Issues

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 ©