PHP Web Host - Quality Web Hosting For All PHP Applications Free RavenNuke(tm) Add Ons
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   This topic is locked: you cannot edit posts or make replies.
Author Message
bigcooky
New Member
New Member


Joined: Jul 26, 2008
Posts: 4

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

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
New Member
New Member


Joined: Jul 26, 2008
Posts: 4

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

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++;
}
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16986
Location: Kansas

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

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 Visit poster's website AIM Address Yahoo Messenger
bigcooky
New Member
New Member


Joined: Jul 26, 2008
Posts: 4

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

Are the changes i made up to date? im not much of a coder =)
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16986
Location: Kansas

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

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;
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
bigcooky
New Member
New Member


Joined: Jul 26, 2008
Posts: 4

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

Thx very much Very Happy
View user's profile Send private message
CodyG
Life Cycles Becoming CPU Cycles


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

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

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.
View user's profile Send private message
kguske
Site Admin


Joined: Jun 04, 2004
Posts: 6044

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

Not sure 2.4 will fix the older scripts...
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 Back to top

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: 633
Location: Ohio

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

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: 2456
Location: Pittsburgh, Pennsylvania

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

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
View user's profile Send private message
Guardian2003
Site Admin


Joined: Aug 28, 2003
Posts: 6373
Location: Vsetin, Czech Republic

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

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 Visit poster's website
FireATST
RavenNuke(tm) Development Team


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

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

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)
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
Palbin
Site Admin


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

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

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
View user's profile Send private message
Palbin
Site Admin


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

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

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 the forums!
to make sure it is compliant. This is not a must but just something I like to do.
View user's profile Send private message
CodyG
Life Cycles Becoming CPU Cycles


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

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

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?
View user's profile Send private message
Guardian2003
Site Admin


Joined: Aug 28, 2003
Posts: 6373
Location: Vsetin, Czech Republic

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

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.
View user's profile Send private message Send e-mail Visit poster's website
Dawg
RavenNuke(tm) Development Team


Joined: Nov 07, 2003
Posts: 889

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

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
RavenNuke(tm) Development Team


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

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

thanks Palbin for the explaination.
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
Susann
Moderator


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

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

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 Visit poster's website
Dawg
RavenNuke(tm) Development Team


Joined: Nov 07, 2003
Posts: 889

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

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
View user's profile Send private message
Susann
Moderator


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

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

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.
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16986
Location: Kansas

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

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 to the forums!
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Guardian2003
Site Admin


Joined: Aug 28, 2003
Posts: 6373
Location: Vsetin, Czech Republic

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

Fantastic, thanks Smile
View user's profile Send private message Send e-mail Visit poster's website
Dawg
RavenNuke(tm) Development Team


Joined: Nov 07, 2003
Posts: 889

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

BINGO....Give that man a Prize!

Dawg
View user's profile Send private message
Display posts from previous:       
Post new topic   This topic is locked: you cannot edit posts or make replies.

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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum