Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
pnclthnmstsh
Regular
Regular



Joined: Oct 23, 2005
Posts: 54
Location: Portland, Or

PostPosted: Thu May 07, 2009 4:42 pm Reply with quote

Maybe someone can help me with this problem. I'm getting a call to undefined function error in this bit of code. The function sql_query isn't defined. The way the code is written doesn't look quite right to do the job but what do I know. This module worked fine with old ravennuke versions so I'm wondering what I've missed to define this and get it to talk to the database.

Code:
sql_query("CREATE TABLE IF NOT EXISTS $prefix"._humpa_chess." (gameid INT (15) not null AUTO_INCREMENT, playerw TEXT not null, playerb TEXT not null, epd CHAR(100), epd1back CHAR(100), epd2back CHAR(100), epd3back CHAR(100), whosmove TEXT not null, gamedate INT(15) not null, gameover TEXT, emailw CHAR(50), emailb CHAR(50), gamepass TEXT not null, PRIMARY KEY (gameid), UNIQUE (gameid))", $dbi);


sql_query("CREATE TABLE IF NOT EXISTS $prefix"._humpa_chess_moves." (mid INT (15) not null, gameid INT (15) not null, movecount INT (15) not null, movecountrow INT (15) not null, epd1 CHAR(100), epd2 CHAR(100), epd3 CHAR(100), epd4 CHAR(100), epd5 CHAR(100), epd6 CHAR(100), epd7 CHAR(100), epd8 CHAR(100), epd9 CHAR(100), epd10 CHAR(100), INDEX (gameid))", $dbi);

sql_query("CREATE TABLE IF NOT EXISTS $prefix"._humpa_chess_comments." (cid INT (15) not null AUTO_INCREMENT, commdate INT(15), name TEXT, comment TEXT, gameid INT (15) not null, PRIMARY KEY (cid), INDEX (gameid))", $dbi);

if ($epd == "humpaepd"){
   $result = sql_query("SELECT epd FROM $prefix"._humpa_chess." WHERE gameid='$gameid'", $dbi);
   list($epd) = sql_fetch_row($result, $dbi);
   header("Location: modules.php?name=Humpa_Chess&file=ChessIndexFrames&epd=$epd&gameid=$gameid");
      die();
}

if (!isset($epd)) {
   $result = sql_query("SELECT epd, playerw, playerb, gameid, gamedate FROM $prefix"._humpa_chess." ORDER BY gamedate DESC LIMIT 1", $dbi);
   if (sql_num_rows($result, $dbi) > 0) {
   list($epd, $playerw, $playerb, $gameid, $gamedate) = sql_fetch_row($result, $dbi);
      if (($playerw == "Open Game") OR ($playerb == "Open Game")) {
         header("Location: modules.php?name=Humpa_Chess&file=ChessIndexPlayerFrames&epd=$epd&opengame=yes&gameid=$gameid");
         die();
      }
      header("Location: $YourNukeRoot/modules.php?name=Humpa_Chess&file=ChessIndexFrames&epd=$epd&gameid=$gameid");
   } else {
      echo "<html><body bgcolor=\"$chessbgcolor\" text=\"$chesstextcolor\" link=\"$linkcolor\" vlink=\"$vlinkcolor\" alink=\"$alinkcolor\">";
      echo "<center><font size=4>"._NoGamesYet."<a href=\"modules.php?name=Humpa_Chess&file=ChessNewGameFrames\">"._CreateOne."</a>?";
      echo "</body></html>";
      die();
   }
} else {
   $result = sql_query("SELECT gamedate, playerb, playerw, whosmove, gameover FROM $prefix"._humpa_chess." WHERE gameid='$gameid'", $dbi);
   list($gamedate, $playerb, $playerw, $whosmove, $gameover) = sql_fetch_row($result, $dbi);
}



Thanks for any suggestions

_________________
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website Yahoo Messenger
nuken
RavenNuke(tm) Development Team



Joined: Mar 11, 2007
Posts: 2024
Location: North Carolina

PostPosted: Thu May 07, 2009 5:03 pm Reply with quote

It is using the old $dbi logic. You could convert it like so:
Code:
$db->sql_query("CREATE TABLE IF NOT EXISTS $prefix"._humpa_chess." (gameid INT (15) not null AUTO_INCREMENT, playerw TEXT not null, playerb TEXT not null, epd CHAR(100), epd1back CHAR(100), epd2back CHAR(100), epd3back CHAR(100), whosmove TEXT not null, gamedate INT(15) not null, gameover TEXT, emailw CHAR(50), emailb CHAR(50), gamepass TEXT not null, PRIMARY KEY (gameid), UNIQUE (gameid))");


$db->sql_query("CREATE TABLE IF NOT EXISTS $prefix"._humpa_chess_moves." (mid INT (15) not null, gameid INT (15) not null, movecount INT (15) not null, movecountrow INT (15) not null, epd1 CHAR(100), epd2 CHAR(100), epd3 CHAR(100), epd4 CHAR(100), epd5 CHAR(100), epd6 CHAR(100), epd7 CHAR(100), epd8 CHAR(100), epd9 CHAR(100), epd10 CHAR(100), INDEX (gameid))");

$db->sql_query("CREATE TABLE IF NOT EXISTS $prefix"._humpa_chess_comments." (cid INT (15) not null AUTO_INCREMENT, commdate INT(15), name TEXT, comment TEXT, gameid INT (15) not null, PRIMARY KEY (cid), INDEX (gameid))");

if ($epd == "humpaepd"){
   $result = $db->sql_query("SELECT epd FROM $prefix"._humpa_chess." WHERE gameid='$gameid'");
   list($epd) = $db->sql_fetchrow($result);
   header("Location: modules.php?name=Humpa_Chess&file=ChessIndexFrames&epd=$epd&gameid=$gameid");
      die();
}

if (!isset($epd)) {
   $result = $db->sql_query("SELECT epd, playerw, playerb, gameid, gamedate FROM $prefix"._humpa_chess." ORDER BY gamedate DESC LIMIT 1");
   if ($db->sql_numrows($result) > 0) {
   list($epd, $playerw, $playerb, $gameid, $gamedate) = $db->sql_fetchrow($result);
      if (($playerw == "Open Game") OR ($playerb == "Open Game")) {
         header("Location: modules.php?name=Humpa_Chess&file=ChessIndexPlayerFrames&epd=$epd&opengame=yes&gameid=$gameid");
         die();
      }
      header("Location: $YourNukeRoot/modules.php?name=Humpa_Chess&file=ChessIndexFrames&epd=$epd&gameid=$gameid");
   } else {
      echo "<html><body bgcolor=\"$chessbgcolor\" text=\"$chesstextcolor\" link=\"$linkcolor\" vlink=\"$vlinkcolor\" alink=\"$alinkcolor\">";
      echo "<center><font size=4>"._NoGamesYet."<a href=\"modules.php?name=Humpa_Chess&file=ChessNewGameFrames\">"._CreateOne."</a>?";
      echo "</body></html>";
      die();
   }
} else {
   $result = $db->sql_query("SELECT gamedate, playerb, playerw, whosmove, gameover FROM $prefix"._humpa_chess." WHERE gameid='$gameid'");
   list($gamedate, $playerb, $playerw, $whosmove, $gameover) = $db->sql_fetchrow($result);
}


or do this: Only registered users can see links on this board! Get registered or login!

_________________
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Send e-mail Visit poster's website
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Thu May 07, 2009 5:04 pm Reply with quote

The use of $dbi vs $db. Search the forums on '$dbi'.
 
View user's profile Send private message
pnclthnmstsh







PostPosted: Thu May 07, 2009 5:56 pm Reply with quote

Thanks! That did the trick and was able to fix the rest of the broken files in that mod with your help.
 
nuken







PostPosted: Thu May 07, 2009 6:07 pm Reply with quote

cool.
 
pnclthnmstsh







PostPosted: Thu May 07, 2009 6:11 pm Reply with quote

Ooops, found another problem in this line that I can't find the answer to.
Call to undefined method
Code:
$total1 = $db->mysql_fetch_array(mysql_query("SELECT COUNT(gameid) AS total1 FROM ".$prefix."_humpa_chess"));
 
nuken







PostPosted: Thu May 07, 2009 6:14 pm Reply with quote

try this
Code:
$total1 = $db->sql_fetchrow($db->sql_query("SELECT COUNT(gameid) AS total1 FROM ".$prefix."_humpa_chess"));
 
pnclthnmstsh







PostPosted: Thu May 07, 2009 6:16 pm Reply with quote

Perfect!
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

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 ©