Page 1 of 1

statistics page using mysql

Posted: Tue Dec 27, 2005 1:48 am
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!

Posted: Tue Dec 27, 2005 3:50 am
by spitfire_esquive
please disregard as prep_by=R. CAUTON is really zero in the database!!! 8O

Posted: Tue Dec 27, 2005 7:43 am
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

Posted: Tue Dec 27, 2005 7:52 am
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