Author |
Message |
bigcooky
New Member
![New Member New Member](modules/Forums/images/ranks/1star.gif)
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: Jul 26, 2008
Posts: 4
|
Posted:
Tue Oct 21, 2008 11:42 am |
|
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 ? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
bigcooky
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Oct 21, 2008 1:21 pm |
|
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 .= " $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 .= " $a: <a href=\"$url\" target=\"_blank\">$title2</a><br/>";
$a++;
}
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
Site Admin/Owner
![](modules/Forums/images/avatars/45030c033f18773153cd2.gif)
Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Tue Oct 21, 2008 1:27 pm |
|
You are using v-e-r-y old code
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
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);
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
bigcooky
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Oct 21, 2008 1:35 pm |
|
Are the changes i made up to date? im not much of a coder =) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Oct 21, 2008 1:41 pm |
|
bigcooky wrote: | Are the changes i made up to date? im not much of a coder =) |
Also you should remove all instances of $dbi from your global statement after fixing your code.
Change
global $dbi;
To
global $db; |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
bigcooky
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Oct 21, 2008 1:45 pm |
|
Thx very much ![Very Happy](modules/Forums/images/smiles/icon_biggrin.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
CodyG
Life Cycles Becoming CPU Cycles
![](modules/Forums/images/avatars/186c8977515afcc3ed82a.jpg)
Joined: Jan 02, 2003
Posts: 714
Location: Vancouver Island
|
Posted:
Tue Oct 21, 2008 3:11 pm |
|
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 |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
kguske
Site Admin
![](modules/Forums/images/avatars/41f0b40a419280935f3a0.gif)
Joined: Jun 04, 2004
Posts: 6437
|
Posted:
Tue Oct 21, 2008 5:04 pm |
|
Not sure 2.4 will fix the older scripts... |
_________________ I search, therefore I exist...
Only registered users can see links on this board! Get registered or login! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Loki
Worker
![Worker Worker](modules/Forums/images/ranks/3stars.gif)
![](modules/Forums/images/avatars/4acf103e48de6aa494ee4.jpg)
Joined: Oct 05, 2003
Posts: 107
Location: Illinois
|
Posted:
Tue Oct 21, 2008 5:15 pm |
|
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. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
FireATST
RavenNuke(tm) Development Team
![](modules/Forums/images/avatars/1890b00a421a4615ecd23.jpg)
Joined: Jun 12, 2004
Posts: 654
Location: Ohio
|
Posted:
Wed Nov 05, 2008 5:09 am |
|
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. |
|
|
![ICQ Number ICQ Number](themes/RavenIce/forums/images/lang_english/icon_icq_add.gif) |
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
Site Admin
![](modules/Forums/images/avatars/Dilbert/Dilbert_-_Dogbert_King.gif)
Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania
|
Posted:
Wed Nov 05, 2008 6:42 am |
|
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](modules/Forums/images/smiles/icon_smile.gif) |
_________________ "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. |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Guardian2003
Site Admin
![](modules/Forums/images/avatars/125904890252d880f79f312.png)
Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam
|
Posted:
Wed Nov 05, 2008 7:01 am |
|
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 |
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. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
FireATST
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Nov 06, 2008 7:15 am |
|
Palbin, thanks for your generousity, but I am looking to learn how to do it..... 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..... (or something similiar to that) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Nov 06, 2008 9:16 am |
|
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 |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Nov 06, 2008 9:20 am |
|
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 http://www.htmlvalidator.com/ to make sure it is compliant. This is not a must but just something I like to do. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
CodyG
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Nov 06, 2008 10:44 am |
|
Just a thought or two?
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 ?? 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? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Guardian2003
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Nov 06, 2008 10:55 am |
|
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. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Dawg
RavenNuke(tm) Development Team
![](modules/Forums/images/avatars/46907b8543f928e08c8d7.gif)
Joined: Nov 07, 2003
Posts: 928
|
Posted:
Fri Nov 07, 2008 5:54 am |
|
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 |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
FireATST
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Nov 07, 2008 6:20 am |
|
thanks Palbin for the explaination. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Susann
Moderator
![](modules/Forums/images/avatars/4e3210db4efb891870d79.gif)
Joined: Dec 19, 2004
Posts: 3191
Location: Germany:Moderator German NukeSentinel Support
|
Posted:
Fri Nov 07, 2008 7:16 am |
|
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. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Dawg
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Nov 07, 2008 7:55 am |
|
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 |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Susann
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Nov 07, 2008 8:20 am |
|
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. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Nov 07, 2008 8:37 am |
|
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?
http://www.ravenphpscripts.com/forumsindex-c-32.html |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Guardian2003
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Nov 07, 2008 8:54 am |
|
Fantastic, thanks ![Smile](modules/Forums/images/smiles/icon_smile.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Dawg
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Nov 07, 2008 10:26 am |
|
BINGO....Give that man a Prize!
Dawg |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|