I don't get this one o.o
---------- Post added at 06:29 PM ---------- Previous post was at 06:29 PM ----------
If I use that then you get:
In the site I get this:PHP Code:<?php
$connection = odbc_connect('GunzDB','sa', 'password')
or die('Cant connect to the server');
$sqlquery="SELECT COUNT(*) FROM Account";
$execquery=odbc_exec($connection,$sqlquery);
echo "Total Accounts: ".$execquery." - ";
//close connection
odbc_close($connection);
?>
PHP Code:Total Accounts: Resource id #3 -
Last edited by BGRick; 22-02-11 at 07:10 PM.
Oh my bad.
PHP: odbc_num_rows - ManualPHP Code:<?php
$cxn = odbc_connect("GunzDB", "sa", "pass");
$sql = "SELECT * FROM Account'";
$res = odbc_exec($cxn, $sql);
$items = 0;
while ($row = odbc_fetch_array($res))
{
$items++;
}
odbc_free_result($res);
echo "<br>total No. of rows: $items";
?>
That gives errors like hell...
PHP Code:<?php
$con = odbc_connect
("Driver={SQL Server};
Server={host\SQLEXPRESS};
Database={GunzDB}",
sa, mypass) or die();
# function num_rows ODBC
function num_rows($query)
{
$items = 0;
while( odbc_fetch_row($query) )
{
$items++;
}
odbc_free_result($query);
return $items;
}
# account
$sql = "SELECT * FROM Account";
$res = odbc_exec($con, $sql);
# char
$sql2 = "SELECT * FROM Character";
$res2 = odbc_exec($con, $sql2);
# clan
$sql3 = "SELECT * FROM Clan";
$res3 = odbc_exec($con, $sql3);
$acc = num_rows($res);
$char = num_rows($res2);
$clan = num_rows($res3);
echo "Nº total of accounts: ".$acc;
echo "<br>";
echo "Nº total of characters: ".$char;
echo "<br>";
echo "Nº total of clans: ".$clan;
echo "<br>";
?>
Last edited by mutter; 22-02-11 at 07:41 PM.
That didn't worked but with your script I got it working ;)
Config.php:PHP Code:<?php include ("config.php") ?>
<?php
# function num_rows ODBC
function num_rows($query)
{
$items = 0;
while( odbc_fetch_row($query) )
{
$items++;
}
odbc_free_result($query);
return $items;
}
# account
$sql = "SELECT * FROM Account";
$res = odbc_exec($connect, $sql);
# char
$sql2 = "SELECT * FROM Character";
$res2 = odbc_exec($connect, $sql2);
# clan
$sql3 = "SELECT * FROM Clan";
$res3 = odbc_exec($connect, $sql3);
$acc = num_rows($res);
$char = num_rows($res2);
$clan = num_rows($res3);
echo "Nº total of accounts: ".$acc;
echo "<br>";
echo "Nº total of characters: ".$char;
echo "<br>";
echo "Nº total of clans: ".$clan;
echo "<br>";
?>
So thanks man!PHP Code:<?php
$dns="GunzDB";
$user="sa";
$pass="password";
$connect=odbc_connect($dns, $user, $pass) or die ("Couldn't connect to the database, we're sorry...");
odbc_exec($connect,"use GunzDB");
?>
/close request