PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
davidprogramer
Forum Commoner
Posts: 64 Joined: Mon Nov 28, 2005 6:11 pm
Post
by davidprogramer » Wed Feb 15, 2006 3:06 am
I can't figure out why this wont give the desired results...
It lists Home and that works fine. But the for loop doesn't work at all.
Code: Select all
$sql_ladders = sql_query("SELECT ladder_id, ladder_name FROM ".$prefix."_league_ladders");
$content .= "<br><br><center><form name=\"form1\" method=\"post\">
<select name=\"menu1\">
<option value=\"modules.php?name=League\">Home</option>";
for ($m=1; $m < sql_num_rows($sql_ladders)+1; $m++) {
list($ladder_id, $ladder_name) = sql_fetch_row($sql_ladders);
$content .= "<option value=\"modules.php?name=League&file=ladder&lid=$ladder_id\">$ladder_name</option>";
}
$content .= "</select>
<br><center><input type=\"button\" name=\"Button1\" value=\"Go\" onClick=\"MM_jumpMenuGo('menu1','parent',0)\">
</form>";
Last edited by
davidprogramer on Wed Feb 15, 2006 4:14 am, edited 1 time in total.
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed Feb 15, 2006 3:59 am
Have you written this code yourself?
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed Feb 15, 2006 4:12 am
sql_query isn't a PHP function.
Neither is sql_num_rows or sql_fetch_row.
Im sure PHP nuke uses the above like this.
$db->sql_fetch_row
$db->sql_query
$db->sql_num_rows
davidprogramer
Forum Commoner
Posts: 64 Joined: Mon Nov 28, 2005 6:11 pm
Post
by davidprogramer » Wed Feb 15, 2006 4:16 am
Actually you are correct. I have seen that in a few of the other block files. How would I incorporate that into my code though? When using the pointers, my list(code here) doesnt work.
For example:
Code: Select all
$sql_ladders = $db->sql_query("SELECT ladder_id, ladder_name FROM ".$prefix."_league_ladders");
$content .= "<br><br><center><form name=\"form1\" method=\"post\">
<select name=\"menu1\">
<option value=\"modules.php?name=League\">Home</option>";
for ($m=1; $m < $db->sql_num_rows($sql_ladders)+1; $m++) {
list($ladder_id, $ladder_name) = $db->sql_fetch_row($sql_ladders);
$content .= "<option value=\"modules.php?name=League&file=ladder&lid=$ladder_id\">$ladder_name</a></option>";
}
$content .= "</select>
<br><center><input type=\"button\" name=\"Button1\" value=\"Go\" onClick=\"MM_jumpMenuGo('menu1','parent',0)\">
</form>";
The code above causes this to happen:
Fatal error: Call to a member function on a non-object in /home/aowarsco/public_html/blocks/block-League.php on line 18
Last edited by
davidprogramer on Wed Feb 15, 2006 4:19 am, edited 1 time in total.
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed Feb 15, 2006 4:20 am
Which is line 18
davidprogramer
Forum Commoner
Posts: 64 Joined: Mon Nov 28, 2005 6:11 pm
Post
by davidprogramer » Wed Feb 15, 2006 4:21 am
hahaha sorry about that
line 18 would be :
Code: Select all
$sql_ladders = $db->sql_query("SELECT ladder_id, ladder_name FROM ".$prefix."_league_ladders");
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed Feb 15, 2006 4:25 am
Im guessing you haven't created an instance of $db...or trying to use it before it has been declared
Usually something like this
Code: Select all
$db = new database({connectioninfo})
...but im not too familiar with PHP Nuke
davidprogramer
Forum Commoner
Posts: 64 Joined: Mon Nov 28, 2005 6:11 pm
Post
by davidprogramer » Wed Feb 15, 2006 4:28 am
That actually worked...
I declared $db as a global variable at the top of the script. Now the following line is giving me an error:
Code: Select all
for ($m=1; $m < $db->sql_num_rows($sql_ladders)+1; $m++) {
Fatal error: Call to undefined function: sql_num_rows() in /home/aowarsco/public_html/blocks/block-League.php on line 25
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed Feb 15, 2006 4:31 am
post the whole code for block-League.php
davidprogramer
Forum Commoner
Posts: 64 Joined: Mon Nov 28, 2005 6:11 pm
Post
by davidprogramer » Wed Feb 15, 2006 4:32 am
Code: Select all
<?php
if ( !defined('BLOCK_FILE') ) {
Header("Location: ../index.php");
die();
}
global $db;
// Links
$content .= "<img src=\"images/arrow.gif\" border=\"0\" alt=\"\"> <a href=\"modules.php?name=League\">Home</a>";
$content .= "<br><img src=\"images/arrow.gif\" border=\"0\" alt=\"\"> <a href=\"modules.php?name=League&file=hall_of_fame\">Hall of Fame</a>";
$content .= "<br><img src=\"images/arrow.gif\" border=\"0\" alt=\"\"> <a href=\"modules.php?name=Forums\">Forums</a>";
$content .= "<br><img src=\"images/arrow.gif\" border=\"0\" alt=\"\"> <a href=\"modules.php?name=Members_List\">Members</a>";
$content .= "<br><img src=\"images/arrow.gif\" border=\"0\" alt=\"\"> <a href=\"modules.php?name=League&file=staff\">Staff</a>";
$content .= "<br><img src=\"images/arrow.gif\" border=\"0\" alt=\"\"> <a href=\"modules.php?name=Private_Messages\">Messages</a>";
$content .= "<br><img src=\"images/arrow.gif\" border=\"0\" alt=\"\"> <a href=\"modules.php?name=FAQ\">Support</a>";
$content .= "<br><img src=\"images/arrow.gif\" border=\"0\" alt=\"\"> <a href=\"modules.php?name=Statistics\">League Stats</a>";
$content .= "<br><img src=\"images/arrow.gif\" border=\"0\" alt=\"\"> <a href=\"modules.php?name=Members_List\">Members</a>";
// Begin Dropdown Menu Code
$sql_ladders = $db->sql_query("SELECT ladder_id, ladder_name FROM ".$prefix."_league_ladders");
$content .= "<br><br><center><form name=\"form1\" method=\"post\">
<select name=\"menu1\">
<option value=\"modules.php?name=League\">Home</option>";
for ($m=1; $m < $db->sql_num_rows($sql_ladders)+1; $m++) {
list($ladder_id, $ladder_name) = $db->sql_fetch_row($sql_ladders);
$content .= "<option value=\"modules.php?name=League&file=ladder&lid=$ladder_id\">$ladder_name</a></option>";
}
$content .= "</select>
<br><center><input type=\"button\" name=\"Button1\" value=\"Go\" onClick=\"MM_jumpMenuGo('menu1','parent',0)\">
</form>";
?>
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed Feb 15, 2006 4:36 am
are you including this file in another file?
if so, show me the other file
davidprogramer
Forum Commoner
Posts: 64 Joined: Mon Nov 28, 2005 6:11 pm
Post
by davidprogramer » Wed Feb 15, 2006 4:38 am
No, I am just activating it the default way through the admin control panel of phpNuke.
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed Feb 15, 2006 4:38 am
im not sure then...im dont know PHP Nuke well enough to help you further
davidprogramer
Forum Commoner
Posts: 64 Joined: Mon Nov 28, 2005 6:11 pm
Post
by davidprogramer » Wed Feb 15, 2006 4:41 am
Alright, Thanks for trying
Can anyone else provide some insight?