| Author |
Message |
bigcooky New Member


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


Joined: Jul 26, 2008 Posts: 4
|
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++;
} |
|
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16986 Location: Kansas
|
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); |
|
|
|
|
 |
bigcooky New Member


Joined: Jul 26, 2008 Posts: 4
|
Posted:
Tue Oct 21, 2008 1:35 pm |
|
Are the changes i made up to date? im not much of a coder =) |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16986 Location: Kansas
|
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; |
|
|
|
 |
bigcooky New Member


Joined: Jul 26, 2008 Posts: 4
|
Posted:
Tue Oct 21, 2008 1:45 pm |
|
Thx very much  |
|
|
|
 |
CodyG Life Cycles Becoming CPU Cycles

Joined: Jan 02, 2003 Posts: 666 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. |
|
|
|
 |
kguske Site Admin

Joined: Jun 04, 2004 Posts: 6044
|
Posted:
Tue Oct 21, 2008 5:04 pm |
|
Not sure 2.4 will fix the older scripts... |
|
|
|
 |
Loki Worker


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

Joined: Jun 12, 2004 Posts: 633 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. |
|
|
 |
 |
Palbin Site Admin

Joined: Mar 30, 2006 Posts: 2456 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  |
|
|
|
 |
Guardian2003 Site Admin

Joined: Aug 28, 2003 Posts: 6373 Location: Vsetin, Czech Republic
|
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. |
|
|
|
 |
FireATST RavenNuke(tm) Development Team

Joined: Jun 12, 2004 Posts: 633 Location: Ohio
|
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) |
|
|
 |
 |
Palbin Site Admin

Joined: Mar 30, 2006 Posts: 2456 Location: Pittsburgh, Pennsylvania
|
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 |
|
|
 |
Palbin Site Admin

Joined: Mar 30, 2006 Posts: 2456 Location: Pittsburgh, Pennsylvania
|
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 to make sure it is compliant. This is not a must but just something I like to do. |
|
|
|
 |
CodyG Life Cycles Becoming CPU Cycles

Joined: Jan 02, 2003 Posts: 666 Location: Vancouver Island
|
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? |
|
|
|
 |
Guardian2003 Site Admin

Joined: Aug 28, 2003 Posts: 6373 Location: Vsetin, Czech Republic
|
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. |
|
|
|
 |
Dawg RavenNuke(tm) Development Team

Joined: Nov 07, 2003 Posts: 889
|
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 |
|
|
|
 |
FireATST RavenNuke(tm) Development Team

Joined: Jun 12, 2004 Posts: 633 Location: Ohio
|
Posted:
Fri Nov 07, 2008 6:20 am |
|
thanks Palbin for the explaination. |
|
|
 |
 |
Susann Moderator

Joined: Dec 19, 2004 Posts: 3143 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. |
|
|
|
 |
Dawg RavenNuke(tm) Development Team

Joined: Nov 07, 2003 Posts: 889
|
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 |
|
|
|
 |
Susann Moderator

Joined: Dec 19, 2004 Posts: 3143 Location: Germany:Moderator German NukeSentinel Support
|
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. |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16986 Location: Kansas
|
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?
|
|
|
|
 |
Guardian2003 Site Admin

Joined: Aug 28, 2003 Posts: 6373 Location: Vsetin, Czech Republic
|
Posted:
Fri Nov 07, 2008 8:54 am |
|
Fantastic, thanks  |
|
|
|
 |
Dawg RavenNuke(tm) Development Team

Joined: Nov 07, 2003 Posts: 889
|
Posted:
Fri Nov 07, 2008 10:26 am |
|
BINGO....Give that man a Prize!
Dawg |
|
|
|
 |
|
|
|
|