statistics page using mysql

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

Post Reply
spitfire_esquive
Forum Commoner
Posts: 37
Joined: Sun Nov 06, 2005 6:46 am

statistics page using mysql

Post by spitfire_esquive »

i have code here that is trying to get a lot of statistics (say for example, the number of queries that CSE N. Roldan is getting between *start date* and *end date*).

Code: Select all

//create variable names
    $startstat=$_POST['startstat'];
    $endstat=$_POST['endstat'];
    //connect to mysql
    $conn=mysql_pconnect('--','--','--');
    mysql_select_db('qlog');

//N. ROLDAN
$zuknroldan="SELECT *
from clientquery WHERE
prep_by='N. ROLDAN' AND
date_received BETWEEN '.$startstat.' AND '.$endstat.'";

    $resultnroldan=mysql_query($zuknroldan);

    $num_resultnroldan=mysql_num_rows($resultnroldan);
    
//R. CAUTON
$zukrcauton="SELECT *
from clientquery WHERE
prep_by='R. CAUTON' AND
date_received BETWEEN '.$startstat.' AND '.$endstat.'";

    $resultrcauton=mysql_query($zukrcauton);

    $num_resultrcauton=mysql_num_rows($resultrcauton);
it works for N. Roldan ($num_resultnroldan) but not for R. Cauton ($num_resultrcauton). Is this a correct way to do this? Can I only do one search string using one mysql connection? I've read somewhere that I need to do some stored procedures in MySQL.

Many thanks!
spitfire_esquive
Forum Commoner
Posts: 37
Joined: Sun Nov 06, 2005 6:46 am

Post by spitfire_esquive »

please disregard as prep_by=R. CAUTON is really zero in the database!!! 8O
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

spitfire_esquive wrote:please disregard as prep_by=R. CAUTON is really zero in the database!!! 8O
LOL!! So I take it this is solved?

Cheers,
BDKR
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

OK spitfire. Why don't you also try some error reporting. You're not even checking if the query succeded. That would be first place to start in my opinion.

Code: Select all

if(!$resultrcauton)
    { echo mysql_error()."<br>\n"; }

Try that before you attempt to get the number or rows returned.

Cheers
Post Reply