Jump to content

Simple Sum not working - PHP forum didn't help


muddy004

Recommended Posts

Dear Freaks,

 

This is an odd question.  I've inherited a very old php application.  I attempted to upgrade it.  The application is used to add certain columns of data.  On the original server, three columns add just fine (output to a report).  On the upgraded server (newer mysql and php), the report displays zero for the three columns.

 

This is the code for adding the three columns:

# locations
      $sql_locs = "SELECT sum(C1NearHome)+sum(C2NearHome)+sum(C3NearHome),
      sum(C1NearWork)+sum(C2NearWork)+sum(C3NearWork), sum(C1NearSchool)+sum(C2NearSchool)+sum(C3NearSchool) FROM request WHERE YMDHMS >= $bgnDate AND YMDHMS <= $endDate";
      $res_locs = mysql_query($sql_locs);
      $nrow_locs = mysql_num_rows($res_locs);
      if ($nrow_locs > 0) {
         $row_locs = mysql_fetch_row($res_locs);
         $stats[$stindx . "nearHome"] = $row_locs[0];
         $stats[$stindx . "nearWork"] = $row_locs[1];
         $stats[$stindx . "nearSchool"] = $row_locs[2];
      }

 

This line:

sum(C1NearSchool)+sum(C2NearSchool)+sum(C3NearSchool)

isn't adding correctly.  The report on the new server shows zero, but on the old server, for example, the number is 4.  If I remove two of the sums and make it:

sum(C1NearSchool)

 

the report displays the total for that column.  When I add the two other sums back to the equation, I get zero again.

 

Any ideas what's wrong here?

 

Any help is greatly appreciated.

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.