vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   SQL Count error (https://vborg.vbsupport.ru/showthread.php?t=151705)

jasharen 07-08-2007 06:12 PM

SQL Count error
 
I am having a problem using a datamanager to return a record count for me. The sql server query returns 41 records and the datamanager entry returns 46.

PHP Code:

Datamanager SQL statement:
        
SELECT COUNT(*) as count FROM " . TABLE_PREFIX . "companies"

        
$result     = $db->query_read($dataman->fetch_count());
        
$list       = mysql_fetch_object($result);
        
$totalcompanies = $list->count

Any idea why this would be happening? Its driving me nuts lol

PHP Code:

$dbhost 'localhost';
$dbuser 'root';
$dbpass '';

$conn mysql_connect($dbhost$dbuser$dbpass) or die                      ('Error connecting to mysql');

$dbname 'mydb';
mysql_select_db($dbname$conn);
  
$result     mysql_query("select count(*) as count from companies");
  
$list       mysql_fetch_object($result);
  
$totalcompanies $list->count;
  echo 
$totalcompanies;
mysql_close($con); 

When the above code is run it returns 41...

nm /sigh

My own stupidity.

analog2112 07-09-2007 01:28 AM

Are you using MySQL 5? I saw this same sort of thing when I did a "select count (*)", just for kicks try replacing the wildcard with a column name and see what you get "select count (some_column_in_companies)"

jasharen 09-12-2007 03:41 AM

In this case I was connected to two different databases. Almost carbon copies of each other, but one was hitting the *live* database and the other was hitting the development db.

All I can say is I was tired at the time lol


All times are GMT. The time now is 05:47 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01024 seconds
  • Memory Usage 1,719KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete