ehpratah 48 Posting Whiz in Training

Hi Hericles,

What is the query trying to do?

The query is fetching all the record frm 3 tables using inner join and I am using pagination displaying it.

I tried adding Indexes in all the column that im searching or connecting with and it improves that over all performance of the system. I am on the observation part now. hope that it fix the problem permanently.

I'll close this thread later on when i validated that the solution is effective.

Thanks!

ehpratah 48 Posting Whiz in Training

Hi Everyone!

I have an application that has thousand of records. the problem that i am having right now is that my website is performing slow.when i am trying to swtich to other link on the site which have a query running on the background it takes ages to load. i already tried using cloudflare to optimize the system but the slow querying still persist. can anybody have an idea that can help me optmize the poor performace of my database?

By the way the system is hosted in a dedicated server but the resources consumption is very high.

Thanks Neil.

ehpratah 48 Posting Whiz in Training

Hi never find got it already.thanks!

ehpratah 48 Posting Whiz in Training

Hi Diafol!

Thanks for that but how can i remove the "" on the numbers?
[["Boat + Cab","3"],["Bus + Boat","41040"],["Bus + Boat + Cab","840"],["Bus Only","14343.75"],["Door to Door","674973.75"]]

the format should look like this.

[["Boat + Cab",3],["Bus + Boat",41040],["Bus + Boat + Cab",840],["Bus Only",14343.75],["Door to Door",674973.75]]

thanks

ehpratah 48 Posting Whiz in Training

Hi Guys!

I cant find a way to show my data array the way i need it to be hope you can help me. i already tried using array_push(), json_encode() but still no result. basically what i am getting is like this

Array ( [0] => Array ( [name] => Boat + Cab [TOTAL] => 3 ) 
                [1] => Array ( [name] => Bus + Boat [TOTAL] => 41040 )
                [2] => Array ( [name] => Bus + Boat + Cab [TOTAL] => 840 ) 
                [3] => Array ( [name] => Bus Only [TOTAL] => 14343.75 ) 
                [4] => Array ( [name] => Door to Door [TOTAL] => 691073.75 ) )

But i need the data in this format

                    ['Boat + Cab', 3],
                    ['Bus + Boat', 41040],
                    ['BUS + BOAT', 1000],
                    ['Bus + Boat + Cab', 840]
                    ....etc

What should i do?

Thanks Neil,

ehpratah 48 Posting Whiz in Training

Try looking at Inner join and count()

http://www.w3schools.com/sql/sql_join_inner.asp

ribrahim commented: Thank you for the link +0
ehpratah 48 Posting Whiz in Training

WOW thats it? holycow im stuck on that for 2 days and you answered it very casually with

Yes exactly put line 17-18 inside while loop.

Where are you d past days men?heheheh

ITs WORKING FINE NOW!!!

THANKS ALOT

NEIL:)

happygeek commented: Tell your friends :) +13
ehpratah 48 Posting Whiz in Training

Hi! thank you for giving your inputs on this matter.

To answer you on

Before line number 100 that is before ending while loop break the loop

break;
} //end of while

I tried adding the break ; but it only generate 1 exel file in contrast with the record

fix the while loop query code (LINE 21), it is giving more then one record i guess.

Yes it is giving me 1 or more records which is correct. coz for that day there are several client that have a billing duedate.

for

If you generating mulitple files, then intialise excel object inside while loop and after generating file, destroy it before while loop ends.

Yes and No. it depends on the client duedate whether it will create 1 or more excel file.
Also what do you mean by ?

intialise excel object inside while loop

Do i need to put line 17 and 18 inside my while loop?

Thanks Neil

`

ehpratah 48 Posting Whiz in Training

Anyone has an idea?

ehpratah 48 Posting Whiz in Training

Hi!

Im creating individual excel file base on the duedate and client name of a reservation and sending it automatically on that date.but im having a trouble dispalying the SUM/ Grandtotal of each excel summary that i created. the grandtotal inside my while loop is also incrementing. i dont now what i am doing wrong.

Example

for today i have 4 Client that has a duedate today. and the script automatically generated the excel file summary of each client.

Client 1. 7 STONES

1.jpg

Client 2. Your Travel Planner

2.jpg

Client 3. ZOEMIE

3.jpg

And the Last Zulu Plaza . Notice that this one has no problem dispalying trhe Grandtotal

4.jpg

You can see that from the First excel file to the 3rd it has a duplicate Grandtotal

This is the Script that i used creating the excel files.

<?php
error_reporting(E_ALL);
include '../includes/pdo_config.php';
include '../includes/phpexcel_config.php';
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');

date_default_timezone_set('Asia/Manila');

/** PHPExcel_IOFactory */
require_once dirname(__FILE__) . '/Classes/PHPExcel/IOFactory.php';

$today = date('Y-m-d');

$objReader = PHPExcel_IOFactory::createReader('Excel5');
$objPHPExcel = $objReader->load("templates/Billing.xls");

try {
    $getname=$con->prepare("SELECT msicph_globalsouthwest.accounts_info.name,
                                                   msicph_globalsouthwest.accounts_info.email
                                                    FROM msicph_globalsouthwest.accounts_info
                                                      WHERE msicph_globalsouthwest.accounts_info.name
                                                       IN ( SELECT msicph_southwest.reservations.resfor
                                                         FROM msicph_southwest.reservations
                                                          WHERE msicph_southwest.reservations.`duedate` = DATE_SUB(CURDATE(), INTERVAL - 3 DAY))");
    $getname->execute();
    $i = 0;
    ob_start();
    while ($dataname = $getname->fetch(PDO::FETCH_ASSOC)) {

                $resfor=$dataname['name'];
                $email=$dataname['email'];

                $stmts = $con->prepare("SELECT * FROM reservations WHERE resfor='$resfor' and 
                                                `duedate` = DATE_SUB(CURDATE(), INTERVAL - 3 DAY)"); 
                $stmts->execute();
                $objPHPExcel->getActiveSheet()->setCellValue('I1', PHPExcel_Shared_Date::PHPToExcel(time()));

                $baseRow = 5;

                $run = 0; …
ehpratah 48 Posting Whiz in Training

Got it! Line 45 is the one causing the problem..i just remove that line and everything working fine.

jkon commented: It says that I answered that one but you did. +1 because you answered the questions (although the error was in the use of this external class) +8
ehpratah 48 Posting Whiz in Training

Hi JKON! this is the dump file for the client name

CREATE TABLE IF NOT EXISTS `accounts_info` (
  `aid` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `email` varchar(50) NOT NULL,
  `contact_no` varchar(50) NOT NULL,
  `address` varchar(100) NOT NULL,
  `accred_no` varchar(50) NOT NULL,
  `bill_term` int(2) NOT NULL,
  `cashbond` float NOT NULL,
  `contact_person` varchar(100) NOT NULL,
  PRIMARY KEY (`aid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=253 ;

--
-- Dumping data for table `accounts_info`
--

INSERT INTO `accounts_info` (`name`) VALUES
('Zulu Plaza'),
('ZOEMIE'),
('Your Travel Planner'),
('WILLYS'),
('WHITE HOUSE'),
('WHITE CORAL'),
('WEST CLIFF VILLA'),
('Water Color'),
('Villa Romero'),
('VILLA ROMERO'),
('VICTORY BEACH'),
('VELIS INN'),
('TWO SEASONS'),
('TROPICS'),
('Travel Planner'),
('TONGLEN'),
('THE TIDES'),
('THE PALMS '),
('The Lind'),
('Tans Guesthouse'),
('Taj'),
('SURFSIDE'),
('SUR BEACH '),
('SPR Boracay'),
('SOL MARINA'),
('Sitio boracay'),
('SIMPLE TRAVEL'),
('SHANGRILA'),
('Serendipity/Secret Garden'),
('SEA WIND'),
('SEA BIRD'),
('SAND CASTLE'),
('ROYAL PARK'),
('RESIDENCIA'),
('RED COCONUT'),
('REAL MARIS'),
('RAKSO TRAVEL'),
('POP PEARL OF THE PACIFIC'),
('Paradiso'),
('PARADISE GARDEN'),
('Panorama'),
('ORCHIDS'),
('Oirent Beach'),
('ONE CRESENT'),
('OCEAN CLUB'),
('NIGI NIGI MAIN NU NOOS'),
('NANDANA'),
('My Boracay Guide'),
('MR. HOLIDAY'),
('MORNING BEACH'),
('MONACO SUITES'),
('MITOS PLACE'),
('MILFLORES'),
('MICROTEL'),
('Metropolitan Doctors'),
('MAXIMA'),
('MANILA TRAVEL '),
('MANGO RAY'),
('LUGAR BONITO'),
('LINGGANAY'),
('LE SOLEIL'),
('LAS BRISAS'),
('LA RESERVE'),
('LA ISLA BONITA'),
('LA CARMELA'),
('JONYS'),
('ISLAND STAFF'),
('ISLAND JEWEL INN'),
('Isla Gecko'),
('HOTEL SOFIA'),
('HEY JUDE-SOUTHBEACH'),
('HEY JUDE'),
('HENNAN LAGOON'),
('HENNAN GARDEN'),
('Hannah Hotel'),
('Guillius Italian'),
('GRAND VISTA'),
('GRAND PRIX HIDEAWAY'),
('GRAND BORACAY'),
('GOLDEN PHEONIX'),
('Go Discover'),
('FRIDAYS'),
('FTC BORACAY'),
('Ferra Hotel'),
('FRENDZ RESORT'),
('FAT JIMMYS'),
('FAITHFULLY'),
('FAIRWAYS'),
('ESTACIO UNO'), …
ehpratah 48 Posting Whiz in Training

also i'll post again the sql dump here without the contact info when i reach home. sorry im on mobile

ehpratah 48 Posting Whiz in Training

Hi jkon sorry for the late response. my sql dump was cleaned by a mod because of the sensitive data that was posted thats why it didn't match.basically what im trying to do is send an .xls invoice to the client 3 days before the duedate. what i am trying to do right now is collect all the reservations of each client dynamically and create individual.xls file for it. on the first image i said that the last record should not be there because its a transaction of the second image. i use the resfor field as identifier on the 2nd select statement to group all the data.

hope i explained it clearly :)

thanks,!!

ehpratah 48 Posting Whiz in Training

Anybody have an idea whats wrong im doing?

ehpratah 48 Posting Whiz in Training

Also this are the sql dump if you wanna check it:)

CREATE TABLE IF NOT EXISTS `accounts_info` (
  `aid` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `email` varchar(50) NOT NULL,
  `contact_no` varchar(50) NOT NULL,
  `address` varchar(100) NOT NULL,
  `accred_no` varchar(50) NOT NULL,
  `bill_term` int(2) NOT NULL,
  `cashbond` float NOT NULL,
  `contact_person` varchar(100) NOT NULL,
  PRIMARY KEY (`aid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=252 ;

--
-- Dumping data for table `accounts_info`
--

INSERT INTO `accounts_info` (`aid`, `name`, `email`, `contact_no`, `address`, `accred_no`, `bill_term`, `cashbond`, `contact_person`) VALUES
(161, 'Zulu Plaza', 'test@example.com', '', '', '', 7, 0, 'vicky'),
(160, 'ZOEMIE', '', '', 'ILIG ILIGAN COVE BRGY. YAPAK MALAY AKLAN', '', 7, 0, 'MS. AGEL TIPAY')


CREATE TABLE IF NOT EXISTS `reservations` (
  `resid` int(11) NOT NULL AUTO_INCREMENT,
  `foname` varchar(50) NOT NULL,
  `resnum` varchar(20) NOT NULL,
  `resfor` varchar(100) NOT NULL,
  `name` varchar(100) NOT NULL,
  `total_adult` int(11) NOT NULL,
  `total_senior` int(11) NOT NULL,
  `total_child` int(11) NOT NULL,
  `email` varchar(100) NOT NULL,
  `rental_date` date NOT NULL,
  `rental_time` time NOT NULL,
  `depart_date` date NOT NULL,
  `depart_time` time NOT NULL,
  `service_type` varchar(100) NOT NULL,
  `vehicle_type` varchar(100) NOT NULL,
  `modetrans` varchar(20) NOT NULL,
  `from` varchar(100) NOT NULL,
  `to` varchar(100) NOT NULL,
  `remark` varchar(500) NOT NULL,
  `note` varchar(250) NOT NULL,
  `rates` float NOT NULL,
  `total_extras` float NOT NULL,
  `total_rates` float NOT NULL,
  `grand_total` float NOT NULL,
  `payment_type` varchar(50) NOT NULL,
  `payment_info` varchar(50) NOT NULL,
  `status` varchar(10) NOT NULL,
  `payment_stat` varchar(25) NOT NULL,
  `duedate` date NOT NULL,
  `active` int(5) NOT NULL DEFAULT '1',
  PRIMARY KEY (`resid`),
  UNIQUE KEY `resnum` (`resnum`)
) …
ehpratah 48 Posting Whiz in Training

Hi jkon i am still orienting my self to pdo and still getting the feel of it.dont know yet most of the tricks and other stuffs. The "../includes/pdo_config.php" is just the database config of one of the table.(im using 2 db on this case) by the way i updated my script and its almost working but im still getting a wild data that should not be included in one of the excel file that the script generates.

kindly look on my updated script pls

<?php
error_reporting(E_ALL);
include '../includes/pdo_config.php'; // database msicph_southwest and table reservations config
include '../includes/phpexcel_config.php'; // database msicph_globalsouthwest and table accounts_info
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');

date_default_timezone_set('Europe/London');

/** PHPExcel_IOFactory */
require_once dirname(__FILE__) . '/Classes/PHPExcel/IOFactory.php';

$today = date('Y-m-d');


$objReader = PHPExcel_IOFactory::createReader('Excel5');
$objPHPExcel = $objReader->load("templates/Billing.xls");

try {
                         $getname=$conn->prepare("SELECT msicph_globalsouthwest.accounts_info.name
                                                  FROM msicph_globalsouthwest.accounts_info
                                                 WHERE msicph_globalsouthwest.accounts_info.name IN (
                                                SELECT msicph_southwest.reservations.resfor
                                                FROM msicph_southwest.reservations)"); 
                         $getname->execute();
                         while ($dataname = $getname->fetch(PDO::FETCH_ASSOC)) {

                                    $resfor=$dataname['name'];

                                    $stmts = $con->prepare("SELECT * FROM reservations WHERE 
                                                `duedate` = DATE_SUB(CURDATE(), INTERVAL - 3 DAY) and resfor='$resfor'"); 
                                    $stmts->execute();
                                    $objPHPExcel->getActiveSheet()->setCellValue('I1', PHPExcel_Shared_Date::PHPToExcel(time()));

                                    $baseRow = 5;

                                    foreach($stmts as $r => $dataRow) {
                                    $billname=$dataRow['resfor'];

                                    $rental_date=$dataRow['rental_date'];
                                    $rental_time=$dataRow['rental_time'];
                                    $row = $baseRow + $r;
                                    $objPHPExcel->getActiveSheet()->insertNewRowBefore($row,1);

                                    $objPHPExcel->getActiveSheet()->setCellValue('A'.$row, $dataRow['resnum'])
                                                          ->setCellValue('B'.$row, $dataRow['name'])
                                                          ->setCellValue('C'.$row, date('M d, Y', strtotime($dataRow['rental_date']))." / ".$dataRow['rental_time'])
                                                          ->setCellValue('D'.$row, $dataRow['service_type'])
                                                          ->setCellValue('E'.$row, $dataRow['modetrans'])
                                                          ->setCellValue('F'.$row, $dataRow['from'])
                                                          ->setCellValue('G'.$row, $dataRow['to'])
                                                          ->setCellValue('H'.$row, $dataRow['duedate'])
                                                          ->setCellValue('I'.$row, $dataRow['total_rates']);
                                    }  // end of foreachloop


                            //END OF FOREACH
                                $add=$r + 10;
                                $last=$r + 5;
                                $basecell="I".$add;

                                $objPHPExcel->getActiveSheet()->setCellValue($basecell,'=SUM(I4'.':I'.$last.')');
                                $objPHPExcel->getActiveSheet()->removeRow($baseRow-1,1);


                                $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
                                $objWriter->save(str_replace(__FILE__,'excelfiles/'.$resfor.'.xls',__FILE__));

                                //$objWriter->save(str_replace('.php', '.xls', __FILE__));
                                echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, …
ehpratah 48 Posting Whiz in Training

anybody has an idea what am i doing wrong? when i try to creat a excel file base on the list of name i got from the reservations table using a loop im not getting the right data on the excel file.

ehpratah 48 Posting Whiz in Training

notice the select query on both script. I dont know if the problem is the while loop or the foreach..

ehpratah 48 Posting Whiz in Training

But when i try to get a specific resfor its working the way it should be

Working script

<?php
error_reporting(E_ALL);

ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');

date_default_timezone_set('Europe/London');

/** PHPExcel_IOFactory */
require_once dirname(__FILE__) . '/Classes/PHPExcel/IOFactory.php';

$today = date('Y-m-d');


$objReader = PHPExcel_IOFactory::createReader('Excel5');
$objPHPExcel = $objReader->load("templates/Billing.xls");

try {


             include '../includes/pdo_config.php';
                         $stmts = $con->prepare("SELECT * FROM reservations WHERE 
                                                `duedate` = DATE_SUB(CURDATE(), INTERVAL - 3 DAY) and resfor='7 STONES' "); 
                          $stmts->execute();
                          $result = $stmts->setFetchMode(PDO::FETCH_ASSOC);


                        $objPHPExcel->getActiveSheet()->setCellValue('I1', PHPExcel_Shared_Date::PHPToExcel(time()));

                        $baseRow = 5;

                        foreach($stmts as $r => $dataRow) {
                           $billname=$dataRow['resfor'];

                            $rental_date=$dataRow['rental_date'];
                            $rental_time=$dataRow['rental_time'];
                            $row = $baseRow + $r;
                            $objPHPExcel->getActiveSheet()->insertNewRowBefore($row,1);

                            $objPHPExcel->getActiveSheet()->setCellValue('A'.$row, $dataRow['resnum'])
                                                          ->setCellValue('B'.$row, $dataRow['name'])
                                                          ->setCellValue('C'.$row, date('M d, Y', strtotime($dataRow['rental_date']))." / ".$dataRow['rental_time'])
                                                          ->setCellValue('D'.$row, $dataRow['service_type'])
                                                          ->setCellValue('E'.$row, $dataRow['modetrans'])
                                                          ->setCellValue('F'.$row, $dataRow['from'])
                                                          ->setCellValue('G'.$row, $dataRow['to'])
                                                          ->setCellValue('H'.$row, $dataRow['duedate'])
                                                          ->setCellValue('I'.$row, $dataRow['total_rates']);


                            }
                               $add=$r + 10;
                                $last=$r + 5;
                                $basecell="I".$add;

                                $objPHPExcel->getActiveSheet()->setCellValue($basecell,'=SUM(I4'.':I'.$last.')');
                                $objPHPExcel->getActiveSheet()->removeRow($baseRow-1,1);

                                $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
                                $objWriter->save(str_replace(__FILE__,'excelfiles/'.$billname.'.xls',__FILE__));

                                                                //$objWriter->save(str_replace('.php', '.xls', __FILE__));
                                echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;

                                // Echo done
                                echo date('H:i:s') , " Done writing file" , EOL;
                                echo 'File has been created in ' , getcwd() , EOL;












  } // TRY
 catch(PDOException $e) {
    //echo "Error: " . $e->getMessage();

}
$con = null;
ehpratah 48 Posting Whiz in Training

Hi Everyone!

Can anybody point me to the right direction or check what am i doing wrong. Im trying to export data from php to excel using phpexcel( which is working fine if im am only getting 1 specific record). but when i tried adding a loop to create a workbook im having a problem. the data does not match the actual record from DB

this is the script

Currently editing:  
/home/msicph/public_html/sedaatria/demo/toexcel/genexcel.php
 Encoding:    Reopen  Switch to Code Editor     Close  Save

<?php
error_reporting(E_ALL);

ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');

date_default_timezone_set('Europe/London');

/** PHPExcel_IOFactory */
require_once dirname(__FILE__) . '/Classes/PHPExcel/IOFactory.php';

$today = date('Y-m-d');


$objReader = PHPExcel_IOFactory::createReader('Excel5');
$objPHPExcel = $objReader->load("templates/Billing.xls");

try {
include '../includes/global_config.php';

            $q1= $con->prepare("SELECT name FROM accounts_info"); 
            $q1->execute();
            include '../includes/pdo_config.php';
            while ($row = $q1->fetch())  {
            $name=$row['name'];




                         $stmts = $con->prepare("SELECT * FROM reservations WHERE 
                                                `duedate` = DATE_SUB(CURDATE(), INTERVAL - 3 DAY) and resfor='$name' "); 
                          $stmts->execute();



                        $objPHPExcel->getActiveSheet()->setCellValue('I1', PHPExcel_Shared_Date::PHPToExcel(time()));

                        $baseRow = 5;

                        foreach($stmts as $r => $dataRow) {
                           $billname=$dataRow['resfor'];

                            $rental_date=$dataRow['rental_date'];
                            $rental_time=$dataRow['rental_time'];
                            $row = $baseRow + $r;
                            $objPHPExcel->getActiveSheet()->insertNewRowBefore($row,1);

                            $objPHPExcel->getActiveSheet()->setCellValue('A'.$row, $dataRow['resnum'])
                                                          ->setCellValue('B'.$row, $dataRow['name'])
                                                          ->setCellValue('C'.$row, date('M d, Y', strtotime($dataRow['rental_date']))." / ".$dataRow['rental_time'])
                                                          ->setCellValue('D'.$row, $dataRow['service_type'])
                                                          ->setCellValue('E'.$row, $dataRow['modetrans'])
                                                          ->setCellValue('F'.$row, $dataRow['from'])
                                                          ->setCellValue('G'.$row, $dataRow['to'])
                                                          ->setCellValue('H'.$row, $dataRow['duedate'])
                                                          ->setCellValue('I'.$row, $dataRow['total_rates']);

                                $add=$r + 10;
                                $last=$r + 5;
                                $basecell="I".$add;

                                $objPHPExcel->getActiveSheet()->setCellValue($basecell,'=SUM(I4'.':I'.$last.')');
                                $objPHPExcel->getActiveSheet()->removeRow($baseRow-1,1);

                                $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
                                $objWriter->save(str_replace(__FILE__,'excelfiles/'.$name.'.xls',__FILE__));

                                //$objWriter->save(str_replace('.php', '.xls', __FILE__));
                                echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;

                                // Echo done
                                echo date('H:i:s') , " Done writing file" , EOL;
                                echo 'File has been created in ' , getcwd() , EOL;

                            } //END OF FOREACH


            } …
ehpratah 48 Posting Whiz in Training

Foud the problem. it seems that the on access scanning of sophos is the one causing of the bugs.

ehpratah 48 Posting Whiz in Training

Hi

Has anyone of you having a problem opening firefox , google chrome and thunderbird since yesterday? coz almost all of our unit that is running in ubuntu and Zorin OS are experiencing the same bugs.. i already tried updating and upgrading the OS but still having the error and i also tried re installing the applications but im not getting any progress..

ehpratah 48 Posting Whiz in Training

Hi as cereal been pointing out you just need to add your "phpmailer " /sending code on your form action like

<form action="phpmailer.php" method="post">

after that you need to pass the data from your form to the phpmailer.php script that you wrote like this

<?php
require 'PHPMailerAutoload.php';

//======= this is the data form your form====
$name=$_POST['name'];
$email=$_POST['email'];
$website=$_POST['website'];
 $query=$_POST['query'];
//===========end=======

$mail = new PHPMailer;
//$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = 'localhost';
$mail->SMTPAuth = true;
$mail->Username = 'reply_office@---.com';
$mail->Password = '---';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->From = 'reply_office@---.com';
$mail->FromName = 'Mailer';
$mail->addAddress('office@---.com');
$mail->isHTML(true);
$mail->Subject = 'Here is the subject';
$mail->Body    = 'My name is $name. you can send me an email at $email and visit my webpage at $website and my asdfghj is $query';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}

?>

after you made the changes you are ready to Go.

ehpratah 48 Posting Whiz in Training

can you run this script?

<?php
echo phpinfo();
?>

please read http://php.net/manual/en/function.date-diff.php to better understand why you are getting that error message. Another thing your date_default_timezone is not correct please refer to this list for the correct timezone.

ronjacob012 commented: will help you as soon as possible +0
ehpratah 48 Posting Whiz in Training

According to the php manual, date_diff is only available in PHP 5.3+ so thats why you are getting a fatal error. check the version of your php by echoing phpinfo();

ehpratah 48 Posting Whiz in Training

please be more specific what error are you getting? the sample i gave you is working perfectly on my side without any glitch.

ehpratah 48 Posting Whiz in Training

dont put your if statement in a straight line if you have a comment on it.

if($diff=='2'){ 
//send email 
}else
{ 
//do nothing 
} 

?>
ehpratah 48 Posting Whiz in Training

what error?

ehpratah 48 Posting Whiz in Training

Your First script will work. you just need to make a cronjob for it to send the email automatically.

$currentdate=date_create("2014-06-15");
$duedate=date_create("2014-06-13");
$diff=date_diff($currentdate,$duedate);
echo $diff->format("%a");

if($diff=='2'){

    //send email
}else{
    //do nothing
}
ehpratah 48 Posting Whiz in Training

No its not. the pc needs to be turned on for the task scheduler to work. the best option you have is yo use a cronjob on your webserver that will check your script on a given interval of time.

ehpratah 48 Posting Whiz in Training

Hi

First you must create a script that will check your DB if if the duedate is 2 days before. a simple select query will work.something like

SELECT * FROM table WHERE DATEDIFF(NOW(), duedate) < 2

if the statement return true add your send mail code.

for it to send the email automatically(without any user interactions/page load) you need something like task scheduler or much better a cronjob which will run your script on a specific interval of time.

ehpratah 48 Posting Whiz in Training

yes sure but its a large file so i'll just trim it down.

this is for the table trans_logs for the Date 2015-06-04

CREATE TABLE IF NOT EXISTS `trans_logs` (
  `translogid` int(6) NOT NULL AUTO_INCREMENT,
  `username` varchar(30) NOT NULL,
  `datetime` varchar(100) NOT NULL,
  `ref` varchar(15) NOT NULL,
  `status` varchar(15) NOT NULL,
  PRIMARY KEY (`translogid`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=26598 ;



INSERT INTO `trans_logs` (`translogid`, `username`, `datetime`, `ref`, `status`) VALUES
(26309, 'Ronel Rapadas', '2015-06-04 12:54', '150603029342', 'Ongoing'),
(26310, 'Ronel Rapadas', '2015-06-04 12:55', '150603029342', 'Served'),
(26311, 'KATRINA LEYESA', '2015-06-04 01:58', '150603027A5C', 'Ongoing'),
(26312, 'KATRINA LEYESA', '2015-06-04 02:02', '150603027A5C', 'Served'),
(26313, 'KATRINA LEYESA', '2015-06-04 02:04', '150603028476', 'Ongoing'),
(26314, 'KATRINA LEYESA', '2015-06-04 02:05', '150603028476', 'Served'),
(26315, 'KATRINA LEYESA', '2015-06-04 02:06', '15060302A2D8', 'Ongoing'),
(26316, 'KATRINA LEYESA', '2015-06-04 02:07', '15060302A2D8', 'Served'),
(26317, 'KATRINA LEYESA', '2015-06-04 02:08', '15060302C708', 'Ongoing'),
(26318, 'KATRINA LEYESA', '2015-06-04 02:09', '15060302C708', 'Served'),
(26319, 'KATRINA LEYESA', '2015-06-04 02:11', '15060302AA39', 'Ongoing'),
(26320, 'KATRINA LEYESA', '2015-06-04 02:11', '15060302AA39', 'Served'),
(26321, 'KATRINA LEYESA', '2015-06-04 02:14', '150603023479', 'Ongoing'),
(26322, 'KATRINA LEYESA', '2015-06-04 02:14', '150603023479', 'Served'),
(26323, 'KATRINA LEYESA', '2015-06-04 02:19', '15060302250E', 'Ongoing'),
(26324, 'KATRINA LEYESA', '2015-06-04 02:19', '15060302250E', 'Served'),
(26325, 'KATRINA LEYESA', '2015-06-04 02:29', '15060402CC37', 'Ongoing'),
(26326, 'KATRINA LEYESA', '2015-06-04 02:30', '15060402CC37', 'Served'),
(26327, 'KATRINA LEYESA', '2015-06-04 02:40', '1506040264F6', 'Ongoing'),
(26328, 'KATRINA LEYESA', '2015-06-04 02:42', '1506040264F6', 'Served'),
(26329, 'Ronel Rapadas', '2015-06-04 03:04', '1506040239FE', 'Ongoing'),
(26330, 'Ronel Rapadas', '2015-06-04 03:05', '1506040239FE', 'Served'),
(26331, 'Ronel Rapadas', '2015-06-04 03:06', '150604022566', 'Ongoing'),
(26332, 'Ronel Rapadas', '2015-06-04 03:06', '150604022566', 'Served'),
(26333, 'Mylinor Breis', '2015-06-04 05:36', '150603025529', 'Ongoing'),
(26334, 'Mylinor Breis', '2015-06-04 05:36', '150603025529', …
ehpratah 48 Posting Whiz in Training

tried it several time already on phpmyadmin with the same error message.

ehpratah 48 Posting Whiz in Training

Hi LPS! thanks for your for that but unfortunately its not working i am just getting this error message.

Error in Processing Request

Error code: 504

Error text: Gateway Time-out

i also tried using left outer join with no avail.

ehpratah 48 Posting Whiz in Training

Hi

Im having a hardtime making my query work the way it should be.i'm getting wrong output. basically what im trying to do is a simple user statistic that will show the user inputed data and user processed data base on the date range the user selected.

heres the screenshots for better visualization
1.jpg

and the query for that is.
first Get all the user from the user table

Select Name from user GROUP BY Name ORDER BY Name ASC

then i will loop inside the reservations table for the matching username base on the date range selected

select   
     SDate,
     FoName,
     COUNT( FoName ) AS 'opentrans' 
     From reservations 
     where SDate BETWEEN '" . $from . "'  AND '" . $to. "'
     AND FoName='$ngaran'
     GROUP BY FoName ORDER BY FoName ASC

after getting all the username available on that date range. i will loop inside table trans_logs to get all the proceesed/served transactions on that date range

Select username,status,
      SUM( IF(  status =  'Served', 1, 0 ) ) Served
      from trans_logs
      where datetime
      BETWEEN '" . $from . " 00:00'  AND '" . $to. " 23:59'
      and username='$ngaran' group by username order by username

I know that is not a great approach. but its the only closest thing in getting what i want. but i also tried using diffrent method the problem is that while im getting the correct result that i want i cant find a way to make the presentation of the …

ehpratah 48 Posting Whiz in Training

Is your session ID set? try echoing for the value first if your really getting it.your file should start with a session_start() function for your session variable to work try adding it at line 2

ehpratah 48 Posting Whiz in Training

Sorry for the late response been out for the holiday. so to cut the long story short, there are no possible way to decrypt any of the files without the KEY from the maniac. i already tried googling it but always come to a deadend. Yeah there is a backup but not really up to date.guess its better than to start from zero.

Thanks

P.S

If anybody found a way around it pls let me know.

ehpratah 48 Posting Whiz in Training

Hi i just wanna know if there are way to decrypt a files that is infected and decrypted by a virus / malware? all of the files from one of the workstation are encryted as in totaly you cannot open the files.there is a noted in there saying that i need to pay a certain amount of money for them to give the decryption key. i already tried using some decrypter tools that i found and also tried uploading it to decryptcryptolocker.com in hopes that it can still be decrypt , i already scan the computer using a bootable antivirus, tried using system restore , i also attempted to open the files on a previous version(but dont have this features). all of my files came with this extension document.XLS.hrputzk

By the way the virus came from an email with an attachement which my ever thinking colleague open in hopes to have an International Bank account

Help needed badly

thanks

ehpratah 48 Posting Whiz in Training
ehpratah 48 Posting Whiz in Training

@ Revjim

thank you so much for that Snippet it really do the trick. learned new thing today and i cant believe that it is possible to access other db's with out using union or some other techniques

thanks

Neil

ehpratah 48 Posting Whiz in Training

Hi everyone

i need some help down here. i am trying to connect multiple db and at the same time i want to sum the value of the column. what i have right now is this

SELECT SUM(total) as branch1sales FROM icm.sales 
UNION 
SELECT sum(total) as branch2sales FROM hism.sales

its computing correctly but the problem is the branch2 alias is being invoke. what am i doing wrong? see attached image for the output

Untitled.jpg

thanks

ehpratah 48 Posting Whiz in Training

hi line 9 is fine the query is working when i insert a value directly to the query. its seems that the js is not passing the data to the php file. but the thing is the showdriver function is just a copy paste of the showplate function.doest xml request can only be pass once? but then they are different function im total lost.

ehpratah 48 Posting Whiz in Training

Hi can anyone help me find what am i doing wrong. i have an xml request that check data on db and return the result. and base on that result it will clear or highlight a textbox. its working fine using the original function but when i add another xml request the function that i add don't work properly but the first function is working fine

my script

SHOWPLATE WORKING

function showplate(str)
{

    if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
        }
        else
        {// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function()
        {

            if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
            if (xmlhttp.responseText.trim()=="noplate")
                {

                   $("#platenumber").val('');

                    document.getElementById('submit').disabled = true;
                }
                else
                {

                    $("#platenumber").css({'border':'black 1px solid'});

                    document.getElementById('submit').disabled = false;
                }

            }
        }
      xmlhttp.open("GET","../fetch/checkplate.php?q="+str,true);
      xmlhttp.send();
};


THIS 1 NOT WORKING
function showdriver(dvr)
{

    if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
        }
        else
        {// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function()
        {

            if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
            if (xmlhttp.responseText.trim()=="nodriver")
                {

                   $("#driver").val('');

                    document.getElementById('submit').disabled = true;
                }
                else
                {

                    $("#driver").css({'border':'black 1px solid'});

                    document.getElementById('submit').disabled = false;
                }

            }
        }
      xmlhttp.open("GET","../fetch/checkdriver.php?d="+dvr,true);
      xmlhttp.send();


};

the checkdriver.php

<?php 
 require ("config.php");
$d= $GET["d"];
$d=trim(preg_replace('/\s+/',' ', $d));


    $driver="SELECT Name FROM guestname WHERE Name = '".$d."'";

    $sqld = $con->query($driver);
                if($sqld->num_rows > 0)
                {
                echo "yesdriver";
                }else{echo "nodriver";}

?>

the checkplate.php

<?php 
 require ("config.php");
$q= $_GET["q"];
$q=trim(preg_replace('/\s+/',' ', $q));


    $q="SELECT plateno FROM platenumber WHERE plateno = '".$q."'";

    $sql = $con->query($q);
                if($sql->num_rows > 0)
                {
                echo "yesplate";
                }else{echo "noplate";}

?>
ehpratah 48 Posting Whiz in Training

Thanks guys!

ehpratah 48 Posting Whiz in Training

Hi Thanks hericles and Pritaes both of you for the suggestion. UNION solved it all.

i came up with this

select Ra_num from DB1.processed_trans union all select Ra_num from DB2.processed_trans

now came the more pressing issue im trying to figure out.but because of your suggestion i think im on the right track already.

ehpratah 48 Posting Whiz in Training

to tell you the truth i dont know what to use. can i achieve what i want tru UNION? i'll try to look at union then.

ehpratah 48 Posting Whiz in Training

Hi

Im just trying to show all the Ra_num record from both database, there is no matching record that i can use for the ON. am i missing something? is there other way around it?

ehpratah 48 Posting Whiz in Training

Hi need some insight on how to show record from different database on the same server. i also tried using join but didnt get the correct output. im finding a way to make it work using just one query. my last resort will be using different query to select the data i need(hope i wouldn't go that way)

what i have so far is this. it show the record of both database but somehow it repeating the same record

SELECT DB2.processed_trans.Ra_num , DB1.processed_trans.Ra_num FROM DB2.processed_trans JOIN DB1.processed_trans ;

thanks,

neil

ehpratah 48 Posting Whiz in Training

Hi just a stupid question do you have a default timezone included or activated? if no include in it at the beginning your your code or activate it on your server.

date_default_timezone_set('Asia/Manila');
$date="10-10-2014";
$datetime1 = date_create(date('d - M - Y'));
$datetime2 = date_create($date);
$interval = date_diff($datetime1, $datetime2);
echo $diff = $interval->format('LISTED %R%a DAY(S) AGO');