Jump to content

Butterbean

Members
  • Posts

    70
  • Joined

  • Last visited

Everything posted by Butterbean

  1. If I already have PHP, IIS and DB on the existing system and want to have that data all moved to another system, can I use web deploy 3.5 to do this merge?
  2. Greetings all. I have a small server on a Windows 7 Home Premium machine (32 bit). I am upgrading it to a new server (Lenovo think server 64 bit). I was hoping there was an easy way to migrate IIS 6 files from one server to another. I am not very versed in this. I was looking for a way to just copy the files to a thumb drive and then back to the new machine but it does not seem that simple. Any thoughts?
  3. So, I'm trying to fix this issue but really don't have the knowledge to do so. I am enrolled in a php course but for now I could really use your help. Below is what I've attempted to try to fix the issue. Can you please tell me what I have done wrong so far? I know there is a lot to clean up to make this code faster to query and more resilient and I will get to that soon. For now, I'm focusing on the issue when I reach 10M. Please see below. <?php $sql = ";WITH TOTAL_KWH_WINTER AS ( SELECT CONVERT(VARCHAR(10),cdate,111)AS trans_date, datepart(hh, cdate) as trans_hour, comm_id, MIN((total_energy_a+total_energy_b+total_energy_c)/100) AS minUsage, MAX((total_energy_a+total_energy_b+total_energy_c)/100) AS maxUsage, meter_multiplier FROM [radiogates].[dbo].[purge_data] LEFT OUTER JOIN [radiogates].[dbo].[ops_invoice] on [radiogates].[dbo].[purge_data].[comm_id] = [radiogates].[dbo].[ops_invoice].[meter_id] where comm_id='$comm_id'and meter_multiplier is not null group by comm_id, CONVERT(VARCHAR(10),cdate,111), datepart(hh, cdate), meter_multiplier ) SELECT *, datepart(weekday, trans_date) as trans_date_day, datepart(month, trans_date) as trans_date_month, if ((maxUsage - minUsage)*meter_multiplier)<0:{ ((maxUsage - minUsage)+10000000)*meter_multiplier); }else { ((maxUsage - minUsage)*meter_multiplier)as totalUsage} FROM TOTAL_KWH_WINTER where datepart(weekday, trans_date) IN ('1', '2', '3', '4', '5', '6', '7') AND DATEPART(MONTH, trans_date) IN ('10','11','12','1','2','3','4') and trans_date BETWEEN '$startdate2 00:00:01' AND '$enddate2 24:00:00' "; $query = sqlsrv_query($conn, $sql);if ($query === false){ exit("<pre>".print_r(sqlsrv_errors(), true));}while ($row = sqlsrv_fetch_array($query)){ $sumUsageKWH += $row[totalUsage];}sqlsrv_free_stmt($query);?>
  4. Thank you for referring to that topic. After revisiting it, I think I understand now.
  5. Hello everyone, <?php $sql = ";WITH TOTAL_KWH_WINTER AS ( SELECT CONVERT(VARCHAR(10),cdate,111)AS trans_date, datepart(hh, cdate) as trans_hour, comm_id, MIN((total_energy_a+total_energy_b+total_energy_c)/100) AS minUsage, MAX((total_energy_a+total_energy_b+total_energy_c)/100) AS maxUsage, meter_multiplier FROM [radiogates].[dbo].[purge_data] LEFT OUTER JOIN [radiogates].[dbo].[ops_invoice] on [radiogates].[dbo].[purge_data].[comm_id] = [radiogates].[dbo].[ops_invoice].[meter_id] where comm_id='$comm_id'and meter_multiplier is not null group by comm_id, CONVERT(VARCHAR(10),cdate,111), datepart(hh, cdate), meter_multiplier ) SELECT *, datepart(weekday, trans_date) as trans_date_day, datepart(month, trans_date) as trans_date_month, ((maxUsage - minUsage)*meter_multiplier) as totalUsage FROM TOTAL_KWH_WINTER where datepart(weekday, trans_date) IN ('1', '2', '3', '4', '5', '6', '7') AND DATEPART(MONTH, trans_date) IN ('10','11','12','1','2','3','4') and trans_date BETWEEN '$startdate2 00:00:01' AND '$enddate2 24:00:00' "; $query = sqlsrv_query($conn, $sql);if ($query === false){ exit("<pre>".print_r(sqlsrv_errors(), true));}while ($row = sqlsrv_fetch_array($query)){ $sumUsageKWH += $row[totalUsage];}sqlsrv_free_stmt($query);?> **************For whatever reason, my browser will not let me put this code where it needs to go, so its up top. Sorry for the inconvenience.************* My concern are code lines 4 through 15 I have PHP code that queryies MSSQL for data called kilowatt hours (kWh), set in a combination of three columns. kWh is set into the db table once every minute and it a value that starts at zero (0) at the beginning of the meters life, then continues until it reaches 10,000,000 before resetting back to zero (0). This happens over weeks, months or years, but it does happen. The code I have listed here makes no consideration of this reset. Since we are alsways querying between a start date and a stop date, we need to know the kWh usage between that period. So, we used maxUsage - minUsage and called that the totalUsage. That works great until the data reset at 10M. At that point, max usage will be some value (ex. 1 kWh), where min usage will be some value (ex. 9,999,999 kWh). the system breaks down at that point. I need to find an algorithm that helps me take into consideration this rolling number set. Thanks for any help!
  6. They would have to be created on the fly. The page where I'm including the buttons is in html. The one I'm mostly concerned with is the CSV file. I need to find a way where every time an html invoice is created, a NACHA certified file is created as a CSV file, then emailed to the customer. I think I can get started on this but its gonna be rocky.
  7. Somebody? Anybody? Hello ello o oo o o oo o oo o o [echoes]
  8. I have a button that brings up my systems printer.... <button onClick="window.print()">Print this page</button> I'm trying to find a way to do the same thing but giving me the ability to save-as to my CPU. What would be nice is if I could have separate buttons to save-as a PDF and one for CSV. Each would automatically save to a file, with a comfirmation that its saved. The location would be coded in PHP for the desired format, and all the user has to do is click the button and it is placed in the appropriate folded. is this possible and easy to do across ie, firefox and chrome? Thanks for any direction. .
  9. Based on what I see, I tried this... no luck. $query = sqlsrv_query($conn, $sql);if ($query === false){ exit("<pre>".print_r(sqlsrv_errors(), true));}while ($row = sqlsrv_fetch_array($query)){ echo "<tr> <td><a href='view_invoice.php?meter_id=$meter_id&subaccount=$subaccount&start_date=$row[start_date]'>$row[meter_id]</a></td> <td>" . date("F Y",strtotime($row['start_date'])) . "+1 month") . "</td><td>$row[invoice_no]</td><td>" . date_format($row['invoice_date'],'Y-m-d') . "</td><td><a href='approve_payment.php?meter_id=$meter_id&subaccount=$subaccount&start_date=$row[start_date]'>Pay Invoice</a></td> </tr>";}sqlsrv_free_stmt($query); ?> $query = sqlsrv_query($conn, $sql);if ($query === false){ exit("<pre>".print_r(sqlsrv_errors(), true));}while ($row = sqlsrv_fetch_array($query)){ echo "<tr> <td><a href='view_invoice.php?meter_id=$meter_id&subaccount=$subaccount&start_date=$row[start_date]'>$row[meter_id]</a></td> <td>" . date("F Y",strtotime($row['start_date'])) . "+1 month") "</td><td>$row[invoice_no]</td><td>" . date_format($row['invoice_date'],'Y-m-d') . "</td><td><a href='approve_payment.php?meter_id=$meter_id&subaccount=$subaccount&start_date=$row[start_date]'>Pay Invoice</a></td> </tr>";}sqlsrv_free_stmt($query); ?>
  10. Thank you for your help. In this case, 'start_date' is a date that is manually entered into php to query mssql for data. I'm using this start date in addition to this purpose to signify the month the bill was produced (which is at the end the 30 days that was queried by the bill. Unfortunately, i did not create an end_date..so now I need to add 1 month to the queried 'start_date' if that makes sense. The purpose for what Im doing it simply to prevent confusion in saving bill copies. Currently we are calling a bill with a start_date of January...a January bill. We really need to call it a February bill. Will this still work in this situation?
  11. I see why you would think that, however, if there is no data, the metering sends an empty packet with zero values. So there will be a row in mssql that has all zeros. Occasionally there is no row of data sent by the EMS, so if it doesnt exist, it doesnt mean that they were using zero energy, it just means that the data never reached the server ( in the timestamped period), so we look at the next timestamps. In that event I need a backup plan to look forward then backward until it finds data (that data can even be zero). This system never stops sending data, so if it doesnt make it to the server, there is some reason (something blocking the 900 MHz, internet down or electric down).
  12. I am looking for a way to have my 'start_date', echo ('start_date' + 1 month). I am looking at the line that reads .... date("F Y",strtotime($row['start_date'])). Does anyone have a suggestion. The date format read, July 2014 or alphabetical full month, numerical full year. Thank you in advance. <?php $query = sqlsrv_query($conn, $sql);if ($query === false){ exit("<pre>".print_r(sqlsrv_errors(), true));}while ($row = sqlsrv_fetch_array($query)){ echo "<tr> <td><a href='view_invoice.php?meter_id=$meter_id&subaccount=$subaccount&start_date=$row[start_date]'>$row[meter_id]</a></td> <td>" . date("F Y",strtotime($row['start_date'])) . "<td>$row[invoice_no]</td><td>" . date_format($row['invoice_date'],'Y-m-d') . "<td>$row[amount_paid]</td>" . "<td>$row[payment_date]</td>" . "<td>$row[check_number]</td>" ;}sqlsrv_free_stmt($query); ?>
  13. I have an energy monitoring system that I am building. This EMS gathers data once per minute and drops that data into a mssql db. I have php set up to interpret the values and allow the customer to query the mssql for data for a peak value within a 15 minute interval. The user enters the 15 minute interval into the web app, along with the timeperiod (15 minute interval in question) example (2014-10-16 at 07:30:00 - 07:44:59 ). Sometimes there is no data in that interval because there was nothing reported (due to power outages or internet connection issue). When there is no data to report, there is not even an entry row set in mssql, therefore the time and date it is querying is not present. I am trying to find a way that if php queries mssql and the row that is queried does not exist, have php look forward than backwards simultaneously until it finds any value (it can even be a zero as long as its a value) to report. I would think I could cover any situation including a major power outage by looking forward three (3) days and back three (3) days. I'm not sure where to even start with something like this. Does anyone have a suggestion on how to start?
  14. I figured it out. There was a bug with MSSQL2008R2 that prevented it. No matter how many times I tried to uninstall and reinstall it, it never created a database. This was easily fixed by downloading 2014. The PHP was written with a login and password and connected to my work db. When I tried to set up a home instance, for development, I couldnt get it work with having the pw's set up. The work around was to just remove the username and password from the code, but I couldnt never figure out how.
  15. I know that I have posted a similar question to this but I am still having some confusion that I hoped I could clear up. Thank you all for being patient with and helping me clean up this mess. Below is the code that is spitting out the bottom error messages. So, I understand that the way to define a variable which uses += and not send it into a loop, generating a notice is this.. Using the top example $meter_multiplier=0; while ($row5 = sqlsrv_fetch_array($query5)){ meter_multiplier += $row5['meter_multiplier']; } versus... $meter_multiplier += $row5['meter_multiplier']; how can I implement this type of statment below. Should the php be called another name and reference sql that way, so the names are different? example $meter_multiplier=0; while ($row5 = sqlsrv_fetch_array($query5)){ meter_multiplier += $row5['meter_mult']; <?php $sql5 = "select meter_id, subaccount_number, service_name, service_address, service_address2, service_city, service_st, service_zip, service_contact, basic_charge, energy_charge, base_rate, intermediate_rate, peak_rate, meter_multiplier, raw_material_price FROM [radiogates].[dbo].[ops_invoice] where meter_id ='$comm_id' and subaccount_number='$session_id'";$query5 = sqlsrv_query($conn, $sql5);if ($query5 === false){ exit("<pre>".print_r(sqlsrv_errors(), true));}while ($row5 = sqlsrv_fetch_array($query5)){ $meter_multiplier += $row5['meter_multiplier']; $raw_material_price += $row5['raw_material_price']; $basic_charge += $row5['basic_charge']; $peak_rate += $row5['peak_rate']; $intermediate_rate += $row5['intermediate_rate']; $energy_charge += $row5['energy_charge']; $base_rate += $row5['base_rate']; $account_number = $row5['meter_id']; $service_name = $row5['service_name']; $service_address = $row5['service_address']; $service_address2 = $row5['service_address2']; $service_city = $row5['service_city']; $service_st = $row5['service_st']; $service_zip = $row5['service_zip'];} sqlsrv_free_stmt($query5); ?> Notice: Undefined variable: meter_multiplier in C:\xampp1\htdocs\Utrack\invoice.php on line 335 Notice: Undefined variable: raw_material_price in C:\xampp1\htdocs\Utrack\invoice.php on line 335 Notice: Undefined variable: basic_charge in C:\xampp1\htdocs\Utrack\invoice.php on line 335 Notice: Undefined variable: peak_rate in C:\xampp1\htdocs\Utrack\invoice.php on line 335 Notice: Undefined variable: intermediate_rate in C:\xampp1\htdocs\Utrack\invoice.php on line 335 Notice: Undefined variable: energy_charge in C:\xampp1\htdocs\Utrack\invoice.php on line 335 Notice: Undefined variable: base_rate in C:\xampp1\htdocs\Utrack\invoice.php on line 335
  16. That is very good to know. Thank you both for the help.
  17. I would assume no one wants to plow through 500 lines of code but I would be more than happy to post if it you like.
  18. Here are some errors that were perfectly fine with a previous version of PHP.. Notice: Undefined variable: sumUsageKWH in C:\xampp1\htdocs\Utrack\invoice.php on line 71 Notice: Undefined variable: sumUsageWKWi in C:\xampp1\htdocs\Utrack\invoice.php on line 146 Notice: Undefined variable: sumUsageWKWp in C:\xampp1\htdocs\Utrack\invoice.php on line 168 Notice: Use of undefined constant meter_multiplier - assumed 'meter_multiplier' in C:\xampp1\htdocs\Utrack\invoice.php on line303 Notice: Undefined variable: meter_multiplier in C:\xampp1\htdocs\Utrack\invoice.php on line 303 Notice: Use of undefined constant raw_material_price - assumed 'raw_material_price' in C:\xampp1\htdocs\Utrack\invoice.phpon line 303 Notice: Undefined variable: raw_material_price in C:\xampp1\htdocs\Utrack\invoice.php on line 303 Notice: Use of undefined constant basic_charge - assumed 'basic_charge' in C:\xampp1\htdocs\Utrack\invoice.php on line 303 Notice: Undefined variable: basic_charge in C:\xampp1\htdocs\Utrack\invoice.php on line 303
  19. With a prior version of Php, this code was acceptable. $query = sqlsrv_query($conn, $sql);if ($query === false){ exit("<pre>".print_r(sqlsrv_errors(), true));}while ($row = sqlsrv_fetch_array($query)){ $sumUsageKWH += $row[totalUsage];}sqlsrv_free_stmt($query);?> Now, with php 5.6.3, I have to add a couple of things. $query = sqlsrv_query($conn, $sql);if ($query === false){ exit("<pre>".print_r(sqlsrv_errors(), true));}while ($row = sqlsrv_fetch_array($query)){ $sumUsageKWH += $row['totalUsage'];}sqlsrv_free_stmt($query);?> due to an error prompt. Once I make the corrections, I have a new errors all over the place. Is there a difference in defining a variable with 5.6.3?
  20. Sorry, I botched that. It works now. Thank you.
  21. I am still getting this error. $sumUsageKWH=0; while ($row = sqlsrv_fetch_array($query)) {$sumUsageKWH += $row['totalUsage'];} Parse error: syntax error, unexpected '=' in C:\xampp1\htdocs\Utrack\invoice.php on line 75
  22. Thank you. I have take a full year of coding in school and have gotten more out of this forum in 1 month than sitting in a class. I appreciate the help.
  23. I'm being told I have an undefined variable. Similar to sumUsagekWH (in the code below) there are other placeholders called sumUsageKHW, sumUsageWKWp, sumUsageWKWi and so on. Each script of code looks similar to below where the 'totalUsage' is added into sumUsageKHW, sumUsageKHE and so on. All references are highlighted red below to make it easier to follow. So, if I am only using these sumUsagesXXXX's as placeholders for the following post.... <input name="electric_charge_total" type="hidden" id="electric_charge_total" value="<?php echo number_format($basic_charge + ($sumUsageKWH * $energy_charge) + ($sumUsageWKWp * $peak_rate) + ($sumUsageWKWi * $intermediate_rate) + ( ($sumUsageWKW+$sumUsageWEW) * $base_rate),"2"); ?>" align="right"/> how to I define them in PHP? Based on the code below, they are only used as a way to introduce totalUsage ( it looks silly the way it was done, but later the code will be expanded so it makes sense). What I mean is that totalUsage is being entered (in the below case) into sumUsageKWH from the $sumUsageKWH += $row[totalUsage] Notice: Undefined variable: sumUsageKWH in C:\xampp1\htdocs\Utrack\invoice.php on line 73 <?php $sql = ";WITH TOTAL_KWH_WINTER AS ( SELECT CONVERT(VARCHAR(10),cdate,111)AS trans_date, datepart(hh, cdate) as trans_hour, comm_id, MIN((total_energy_a+total_energy_b+total_energy_c)/100) AS minUsage, MAX((total_energy_a+total_energy_b+total_energy_c)/100) AS maxUsage, meter_multiplier FROM [radiogates].[dbo].[purge_data] LEFT OUTER JOIN [radiogates].[dbo].[ops_invoice] on [radiogates].[dbo].[purge_data].[comm_id] = [radiogates].[dbo].[ops_invoice].[meter_id] where comm_id='$comm_id'and meter_multiplier is not null group by comm_id, CONVERT(VARCHAR(10),cdate,111), datepart(hh, cdate), meter_multiplier ) SELECT *, datepart(weekday, trans_date) as trans_date_day, datepart(month, trans_date) as trans_date_month, ((maxUsage - minUsage)*meter_multiplier) as totalUsage FROM TOTAL_KWH_WINTER where datepart(weekday, trans_date) IN ('1', '2', '3', '4', '5', '6', '7') AND DATEPART(MONTH, trans_date) IN ('10','11','12','1','2','3','4') and trans_date BETWEEN '$startdate2 00:00:01' AND '$enddate2 24:00:00' "; $query = sqlsrv_query($conn, $sql); if ($query === false){ exit("<pre>".print_r(sqlsrv_errors(), true));}while ($row = sqlsrv_fetch_array($query)) { $sumUsageKWH += $row[totalUsage];}sqlsrv_free_stmt($query);?>
×
×
  • 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.