Jump to content

different sql results


adzie

Recommended Posts

Hi people,

 

I have a small dilema i hope you can provide some advice or tips to try and resolve

 

I have two servers (in the process of moving servers)

 

I have copied over the database and scripts.

 

the results the SAME script provides is different on each server, the script it designed to total members online time, each session creates a record of duration online

 

I have manually checked the amount  of records and all appears to be normal.

 

Both windows servers.

 

any pointers?

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/92934-different-sql-results/
Share on other sites

sorrry about that

 


<?php

error_reporting(E_ALL);

$hostName = 
$userName = 
$password = 
$dbName = 


mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");
mysql_select_db($dbName) or die("Unable to select database $dbName");


$query_hours = "SELECT sec_to_time(sum(time_to_sec(t2.duration))) AS duration_sum FROM members t1, member_time t2 WHERE t1.member_num=t2.mnum";
$result_hours = mysql_query($query_hours);
if (mysql_numrows($result_hours) > 0)
{
$rtime = mysql_result($result_hours,0,"duration_sum");
$htime = substr($rtime,0,5);
$time = ($rtime + 7000);
}
$sql2="select * members";
$query2 = mysql_query($sql2);
$member = mysql_numrows($query2);
if($member == 0)
{
$avg = "0";
$time = "0:00:00";
}
else
{
$avg = $time/$member;
$avg = substr($avg,0, strpos($avg,".")+3);
}
?>

Link to comment
https://forums.phpfreaks.com/topic/92934-different-sql-results/#findComment-476134
Share on other sites

You need to do some old fashion debugging. Echo out the values to find which one is not correct, then work back from there to find the problem.

 

With what you have posted so far, we don't know what the results should be and what you are getting when they are not correct. Which means the best you can get are guesses. Post your data with both the correct and incorrect answers.

Link to comment
https://forums.phpfreaks.com/topic/92934-different-sql-results/#findComment-476160
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.