Ravens PHP Scripts: Forums
 

 

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



Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Fri Sep 09, 2005 2:53 pm Reply with quote

Dont know why I keep gettting the error

ERROR: .Query was empty



Code:
if (stristr($_SERVER['SCRIPT_NAME'], "join.php")) {

    Header("Location: ../../index.php");
    die();
}
require_once("mainfile.php");
include("header.php");
$module_name = basename(dirname(__FILE__));
global $module_name, $db, $prefix;
OpenTable();

#Campaign Mod is divided up into two opposing sides, usually Allies and Axis forces.
#Teams choose who they are fighting for when they join the campaign.
#
$query = $db->sql_query("SELECT Count (*) FROM " . $prefix . "_ladderteams WHERE army = 'Axis'");
$result = mysql_query($query) or die("ERROR: $query.".mysql_error());
$axiscount = $result;


Regular query pulls back 4 records in phpmyadmin

I am attempting to pull out how many units are in a given army and display them.

Code:
<b><div align="left">Current number of Axis units in combat. <?php echo $axiscount ?></div></b><BR>
 
View user's profile Send private message Visit poster's website ICQ Number
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Fri Sep 09, 2005 4:22 pm Reply with quote

Code:
$query = $db->sql_query("SELECT Count (*) FROM " . $prefix . "_ladderteams WHERE army = 'Axis'");

$result = mysql_query($query) or die("ERROR: $query.".mysql_error());

You can't do that. $query is already a result object. After that statement you need to do a $db->sql_fetchrow($query). Get rid of that mysql_query line.
 
View user's profile Send private message
Donovan







PostPosted: Fri Sep 09, 2005 5:32 pm Reply with quote

Thanks Raven.

Next problem Smile

http://www.eto-league.com/modules.php?name=NukeLadder&file=join

Why would I get a return of "Array"


Code:
$query = $db->sql_query("SELECT COUNT(*) FROM " . $prefix . "_ladderteams WHERE army = 'Axis'");

$result = $db->sql_fetchrow($query) or die("ERROR: $query.".mysql_error());
$axiscount = $result;
$query1 = $db->sql_query("SELECT COUNT(*) FROM " . $prefix . "_ladderteams WHERE army = 'Allied'");
$result1 = $db->sql_fetchrow($query1) or die("ERROR: $query.".mysql_error());
$alliedcount = $result1;


Code:


<div align="left">Current number of Allied units in combat. <?php echo $alliedcount ?></div><BR>
      <div align="left">Current number of Axis forces in combat. <?php echo $axiscount ?></div><BR><BR>
 
Raven







PostPosted: Fri Sep 09, 2005 6:57 pm Reply with quote

Your results are returned in an array object. You need to address them as
$result[0], $result[1],... $result[n] where n is the number of columns. In your case you are only selecting one column so you can use $result[0].
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

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 ©