-
Posts
541 -
Joined
-
Last visited
About ecabrera
- Birthday 11/28/1994
Profile Information
-
Gender
Male
-
Location
New Jersey USA
ecabrera's Achievements
-
The problem was that the editor had misspelled words. It works now
-
ok so i'm using this tutorial from here Everything works fine but the insert to database function. It's the insert_data() function. I tried testing it but it inserts 0 in the test database so i think its not passing the correct values. <?php class PayPal_IPN{ function infotuts_ipn($im_debut_ipn) { define('SSL_P_URL', 'https://www.paypal.com/cgi-bin/webscr'); define('SSL_SAND_URL', 'https://www.sandbox.paypal.com/cgi-bin/webscr'); $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); if (!preg_match('/paypal\.com$/', $hostname)) { $ipn_status = 'Validation post isn\'t from PayPal'; if ($im_debut_ipn == true) { // mail test } return false; } // parse the paypal URL $paypal_url = ($_REQUEST['test_ipn'] == 1) ? SSL_SAND_URL : SSL_P_URL; $url_parsed = parse_url($paypal_url); $post_string = ''; foreach ($_REQUEST as $field => $value) { $post_string .= $field . '=' . urlencode(stripslashes($value)) . '&'; } $post_string.="cmd=_notify-validate"; // append ipn command // get the correct paypal url to post request to $paypal_mode_status = $im_debut_ipn; //get_option('im_sabdbox_mode'); if ($paypal_mode_status == true) $fp = fsockopen('ssl://www.sandbox.paypal.com', "443", $err_num, $err_str, 60); else $fp = fsockopen('ssl://www.paypal.com', "443", $err_num, $err_str, 60); $ipn_response = ''; if (!$fp) { // could not open the connection. If loggin is on, the error message // will be in the log. $ipn_status = "fsockopen error no. $err_num: $err_str"; if ($im_debut_ipn == true) { echo 'fsockopen fail'; } return false; } else { // Post the data back to paypal fputs($fp, "POST $url_parsed[path] HTTP/1.1\r\n"); fputs($fp, "Host: $url_parsed[host]\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: " . strlen($post_string) . "\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $post_string . "\r\n\r\n"); // loop through the response from the server and append to variable while (!feof($fp)) { $ipn_response .= fgets($fp, 1024); } fclose($fp); // close connection } // Invalid IPN transaction. Check the $ipn_status and log for details. if (!preg_match("/VERIFIED/s", $ipn_response)) { $ipn_status = 'IPN Validation Failed'; if ($im_debut_ipn == true) { echo 'Validation fail'; print_r($_REQUEST); } return false; } else { $ipn_status = "IPN VERIFIED"; if ($im_debut_ipn == true) { echo 'SUCCESS'; } return true; } } function ipn_response($request){ mail("enrique7979@yahoo.com","My subject",print_r($request,true)); $im_debut_ipn=true; if ($this->infotuts_ipn($im_debut_ipn)) { // if paypal sends a response code back let's handle it if ($im_debut_ipn == true) { $sub = 'PayPal IPN Debug Email Main'; $msg = print_r($request, true); $aname = 'infotuts'; //mail send } // process the membership since paypal gave us a valid + $this->insert_data($request); } } function issetCheck($post,$key){ if(isset($post[$key])){ $return=$post[$key]; } else{ $return=''; } return $return; } function insert_data($request){ require_once('dbconnect.php'); $post=$request; $item_name=$this->issetCheck($post,'item_name'); $amount=$this->issetCheck($post,'mc_gross'); $currency=$this->issetCheck($post,'mc_currency'); $payer_email=$this->issetCheck($post,'payer_email'); $first_name=$this->issetCheck($post,'first_name'); $last_name=$this->issetCheck($post,'last_name'); $country=$this->issetCheck($post,'residence_country'); $txn_id=$this->issetCheck($post,'txn_id'); $txn_type=$this->issetCheck($post,'txn_type'); $payment_status=$this->issetCheck($post,'payment_status'); $payment_type=$this->issetCheck($post,'payment_type'); $payer_id=$this->issetCheck($post,'payer_id'); $create_date=date('Y-m-d H:i:s'); $payment_date=date('Y-m-d H:i:s'); mysqli_query($con,"INSERT INTO `test`(`email`, `name`) VALUES ('$payer_email','$item_name')"); mysqli_query($con,"INSERT INTO `infotuts_transection_tbl` (`item_name`,`payer_email`,`first_name`,`last_name`,`amount`,`currency`,`country`,`txn_id`,`txn_type`,`payer_id`,`payment_status`,`payment_type`,`create_date`,`payment_date`) VALUES ('$item_name','$payer_email','$first_name','$last_name','$amount','$currency','$country','$txn_id','$txn_type','$payer_id','$payment_status','$payment_type','$create_date','$payment_date')"); } } $obj = New PayPal_IPN(); $obj->ipn_response($_REQUEST); ?>
-
solution : $dbbody = $rows['body']; $arr = explode("\n", $dbbody);
-
OK so I want to be about to turn each line into a variable for example. I am retrieving emails sent to my email that look like this in the body content Name Address Town State Zip Car I want to be able to make each line into a variable instead of doing this. $query = mysqli_query($db,"SELECT * FROM email_leads WHERE email = '$company_email'"); while($rows = mysqli_fetch_assoc($query)){ $dbbody = nl2br($rows['body']); echo "<hr>$dbbody"; Any Ideas
-
i get this SELECT * FROM `cars` WHERE manufacturer IN ('Audi','BMW') AND tier IN ('') i don't get it. Isn't it the same as the one before?
-
What im i doing wrong ? $sql = "SELECT * FROM `cars` WHERE manufacturer IN ('". implode("','", $checklist) . "') AND tier IN ('". implode("','", $tier) . "')";
-
I am trying to do this $sql = "SELECT * FROM `cars` WHERE `manufacturer` IN (".implode(",",$_POST['check_list']).")"; $query = mysqli_query($db,$sql); //get the rows while($rows = mysqli_fetch_assoc($query)){ $mid = $rows['id']; $dbm = $rows['manufacturer']; $tier = $rows['tier']; $name = $rows['name']; $email = $rows['email']; echo ""; echo "<br><br>Tier: $tier <br>Manufacturer: $dbm<br>Contact Name: $name <br> Email: $email "; } but it's not working.
-
I want to be able to search various manufacturers by selecting checkboxes, how would I do this? What if they choose 7 to search how would i get it to work with the sql string right now i have to enter it manually like this LIKE '%BMW' but I want it to come from the loop: if(!empty($_POST['check_list'])) { // Loop to store and display values of individual checked checkbox. foreach($_POST['check_list'] as $selected) { echo $selected."</br>"; } } $sql = "SELECT * FROM `Cars` WHERE `manufacturer` LIKE '%BMW' OR `manufacturer` LIKE '%Audi' ORDER BY `tier` ASC";
-
I want to get my price to the nearest quarter for example if its 563 it will go to 550. I don't know what the next step should be. All my prices are whole numbers not decimals. $sql = "SELECT AVG(pay) from `data` WHERE `o_state`='$o_state' and `d_state`='$d_state' and `first` LIKE '$firstdate%'"; $run = mysqli_query($db,$sql); $rows = mysqli_fetch_assoc($run); echo $mean = $rows['AVG(pay)']; $mean = round($mean, 0);
-
i have fixed it i tried ($t/60%60);
-
ok so here is my code $t = round($seconds); echo sprintf('%02d:%02d:%02d', ($t/3600),($t/60%60), $t%60); the $t is the h m s in seconds i want to just get the minutes so than i can do something like this if($t <= 1500){ $t = 900; } if($t <= 2100){ $t = 1800; } if($t <= 3300){ $t = 2700; } if($t <= 3600){ $t = $t + 216000; } so the result can be something like this 3 hr 15mins 3hr 30min 3hr 45min 4 is this something i can do?
-
ok im stuck at how to calculate the pay. for example how would i calculate 14 hours and 42mins * Pay Salary i tried this 14.42 * 15 = 216.3 but im pretty sure thats off by a few cents or dollars. Any idea how to go about it
-
i fixed it by adding $seconds = 0; before the for loop $seconds = 0; for($day=0; $day<7; $day++) { ... $seconds += $parsed['hour'] * 3600 + $parsed['minute'] * 60 + $parsed['second']; } echo $seconds;
-
This is how my code looks like. $query = "SELECT date, start, end, day_total, TIMESTAMPDIFF(SECOND, start, end) as day_t FROM `timesheet` WHERE `date` >= CAST('$start' AS DATE) AND `date` <= DATE_ADD(CAST('$start' AS DATE), INTERVAL 6 DAY) AND e_user='$username'"; $result = mysqli_query($db, $query); //Dump results into an array $records = array(); while($row = mysqli_fetch_assoc($result)) { $records[$row['date']] = $row; } //Create a loop from first to last date //for each day, check if there is a matching records //in the records array. If so, use that data //Else, there was no data for that date for($day=0; $day<7; $day++) { $timeStamp = strtotime("{$start} +{$day} day"); $dateStamp = date("Y-m-d", $timeStamp); $DOW = date("D", $timeStamp); $dateStr = date("m/d/Y", $timeStamp); //Set default values $startTime = ''; $endTime = ''; $totalHours = ''; if(isset($records[$dateStamp])) { $startTime = $records[$dateStamp]['start']; $endTime = $records[$dateStamp]['end']; $totalTimeer = $records[$dateStamp]['day_t']; } // $totalTime = $records[$dateStamp]['day_total']; $totalTime = $records[$dateStamp]['day_total']; $h = str_replace("h ",":","$totalTime"); $m = str_replace("m ",":","$h"); $all = str_replace("s","","$m"); $parsed = date_parse($all); $seconds = $parsed['hour'] * 3600 + $parsed['minute'] * 60 + $parsed['second']; echo $seconds; //Output results echo "<tr>\n"; echo "<td class='tg-031e'>{$DOW} {$dateStr}</td>\n"; echo "<td class='tg-031e'>{$startTime}</td>\n"; echo "<td class='tg-031e'>{$endTime}</td>\n"; echo "<td class='tg-031e'>{$totalTime}</td>\n"; echo "<td class='tg-031e'></td>\n"; echo "<td class='tg-031e'></td>"; echo "</tr>\n"; } ?>
-
Im trying to add seconds like this $h = str_replace("h ",":","$totalTime"); $m = str_replace("m ",":","$h"); $all = str_replace("s","","$m"); $parsed = date_parse($all); $seconds = $parsed['hour'] * 3600 + $parsed['minute'] * 60 + $parsed['second']; echo $seconds; the results come out like this 12766 0 4460 0 9219 0 0 which i think is good because there are seven results 12766 , 0 , 4460 , 0 , 9219 , 0 , 0 i want to add them but keep in mind that they are in sign of an array. I've been trying this $seconds * 7; or $seconds + seconds + seconds + seconds + seconds + seconds +seconds but i get this 89362 0 31220 0 64533 0 0 is there a way to add them all up and get just on value of seconds? like 3294242