Jump to content

hashstar

Members
  • Posts

    35
  • Joined

  • Last visited

Everything posted by hashstar

  1. Hi there, I have a problem with my site www.lifetimewoodtreatment.co.uk For some reason the products are not being added to the cart. I've looked at all the files and dont know where the problem is How do i know where the problem might lie? Any help is much appreciated.
  2. Hi, I would like to add a coupon code option to my shopping cart. How should i go about this? Here is the code that i use for my cart: <?php session_start(); require_once('MCAPI.class.php'); $api = new MCAPI('39b576be70ddb86cf0fa83ff80fca85c-us5'); $list_id = "5f2d41d5db"; $api->listSubscribe($list_id, $_POST['email'], ''); include('include/includes.php'); $cart = Cart::CreateInstance(); if(isset($_GET)){ foreach($_GET as $k=>$v){ $smarty->assign($k,$v); } } if(isset($_GET['remove'])){ $cart->RemoveItems($_GET['remove'],1); } if(isset($_GET['removeAll'])){ $cart->RemoveItems($_GET['removeAll'],$_GET['counts']); } if(isset($_GET['emptyCart'])){ if($_GET['emptyCart']){ $cart->EmptyCart(); header("Location: cart.html"); exit(0); }} if(isset($_GET['add'])){ $itemId = $_GET['add']; $size = $_GET['size']; if (isset($_GET['qty'])) { $qty = $_GET['qty']; } else { $qty = 1; } $cart->addItems($itemId.'-'.$size, array($size,$itemId), $qty); } $cart = Cart::CreateInstance(); $cartBox = $cart->GetCart(); //print_r($cartBox); $total = 0; $subTotal = array(); $db = new DB(); $prods = $db->select("SELECT friendly,name,id FROM products"); $smarty->assign('prods',$prods); if(is_array($cartBox)){ foreach($cartBox as $key=>$item){ $id = $cartBox[$key]['data']->_itemData[1]; $products = $db->select("SELECT detail,image,friendly,name FROM products WHERE id='$id'"); $detailjson = json_decode($products[0]['detail']); foreach($detailjson as $detail){ list($k, $v) = split_by_colon($detail); if($k == $cartBox[$key]['data']->_itemData[0]){ $price = $v;} } $cartBox[$key]['data']->_itemData[3] = $products[0]['image']; $cartBox[$key]['data']->_itemData[6] = $products[0]['name']; $cartBox[$key]['data']->_itemData[2] = $products[0]['friendly']; $cartBox[$key]['data']->_itemData[5] = $price; $sub = (int)$item['count'] * $price; $cartBox[$key]['data']->_itemData[4] = $sub; $total += $sub; } } else { $cartBox = array(); } $count = $cart->GetItemsCount(); $shipping = (int)0; if($total>0&&$total<5){ $shipping = 2.99; }elseif($total>5&&$total<10){ $shipping = 3.99; }elseif($total>10&&$total<15){ $shipping = 4.99; }elseif($total>15&&$total<20){ $shipping = 5.99; }elseif($total>20&&$total<25){ $shipping = 6.99; }elseif($total>25&&$total<30){ $shipping = 7.99; }elseif($total>30&&$total<40){ $shipping = 8.99; }elseif($total>40&&$total<50){ $shipping = 9.99; }elseif($total>50&&$total<55){ $shipping = 10.99; }elseif($total>55&&$total<60){ $shipping = 11.99; }elseif($total>60&&$total<65){ $shipping = 12.99; }elseif($total>65&&$total<70){ $shipping = 13.99; }elseif($total>70&&$total<75){ $shipping = 14.99; }elseif($total>75&&$total<90){ $shipping = 15.99; }elseif($total>90&&$total<100){ $shipping = 16.49; }elseif($total>100&&$total<110){ $shipping = 16.99; }elseif($total>110&&$total<120){ $shipping = 17.99; }elseif($total>120&&$total<130){ $shipping = 18.99; }elseif($total>130&&$total<140){ $shipping = 19.99; }elseif($total>140&&$total<150){ $shipping = 20.99; }elseif($total>150&&$total<160){ $shipping = 21.99; }elseif($total>160&&$total<170){ $shipping = 22.99; }elseif($total>170&&$total<180){ $shipping = 23.99; }elseif($total>180){ $shipping = 24.99; } /* 0 - 4.99 = 2.99 5 - 9.99 = 3.99 10 - 14.99 = 4.99 15 - 19.99 = 5.99 20 - 29.99 = 6.99 30 - 39.99 = 7.99 40 - 49.99 = 8.99 50 - 69.99 = 9.99 70 - 99.99 = 10.99 100+ = 12.99 */ if(isset($_GET['eushipping'])||(isset($_POST['rec_country'])&&$_POST['rec_country']!='uk')){ if($_POST['rec_country']=='au' || $_GET['country']=='au'){ //Set shipping for Austria $shipping = ceil($total/60.00)*30.00; }elseif($_POST['rec_country']=='be' || $_GET['country']=='be'){ //Set shipping for Belgium $shipping = ceil($total/60.00)*20.00; }elseif($_POST['rec_country']=='bu' || $_GET['country']=='bu'){ //Set shipping for Bulgaria $shipping = ceil($total/60.00)*50.00; }elseif($_POST['rec_country']=='cy' || $_GET['country']=='cy'){ //Set shipping for Cyprus $shipping = ceil($total/60.00)*108.00; }elseif($_POST['rec_country']=='cz' || $_GET['country']=='cz'){ //Set shipping for Czech Republic $shipping = ceil($total/60.00)*33.00; }elseif($_POST['rec_country']=='de' || $_GET['country']=='de'){ //Set shipping for Denmark $shipping = ceil($total/60.00)*30.00; }elseif($_POST['rec_country']=='es' || $_GET['country']=='es'){ //Set shipping for Estonia $shipping = ceil($total/60.00)*45.00; }elseif($_POST['rec_country']=='fi' || $_GET['country']=='fi'){ //Set shipping for Finalnd $shipping = ceil($total/60.00)*30.00; }elseif($_POST['rec_country']=='fr' || $_GET['country']=='fr'){ //Set shipping for France $shipping = ceil($total/60.00)*28.00; }elseif($_POST['rec_country']=='ge' || $_GET['country']=='ge'){ //Set shipping for Germany $shipping = ceil($total/60.00)*25.00; }elseif($_POST['rec_country']=='gr' || $_GET['country']=='gr'){ //Set shipping for Greece $shipping = ceil($total/60.00)*50.00; }elseif($_POST['rec_country']=='hu' || $_GET['country']=='hu'){ //Set shipping for Hungary $shipping = ceil($total/60.00)*25.00; }elseif($_POST['rec_country']=='ir' || $_GET['country']=='ir'){ //Set shipping for Ireland $shipping = ceil($total/60.00)*25.00; }elseif($_POST['rec_country']=='it' || $_GET['country']=='it'){ //Set shipping for Italy $shipping = ceil($total/60.00)*30.00; }elseif($_POST['rec_country']=='la' || $_GET['country']=='la'){ //Set shipping for Latvia $shipping = ceil($total/60.00)*42.00; }elseif($_POST['rec_country']=='li' || $_GET['country']=='li'){ //Set shipping for Lithuania $shipping = ceil($total/60.00)*35.00; }elseif($_POST['rec_country']=='lu' || $_GET['country']=='lu'){ //Set shipping for Luxembourg $shipping = ceil($total/60.00)*20.00; }elseif($_POST['rec_country']=='ma' || $_GET['country']=='ma'){ //Set shipping for Malta $shipping = ceil($total/60.00)*108.00; }elseif($_POST['rec_country']=='ne' || $_GET['country']=='ne'){ //Set shipping for Netherlands $shipping = ceil($total/60.00)*25.00; }elseif($_POST['rec_country']=='no' || $_GET['country']=='no'){ //Set shipping for Norway $shipping = ceil($total/60.00)*37.00; }elseif($_POST['rec_country']=='pol' || $_GET['country']=='pol'){ //Set shipping for Poland $shipping = ceil($total/60.00)*35.00; }elseif($_POST['rec_country']=='por' || $_GET['country']=='por'){ //Set shipping for Portugal $shipping = ceil($total/60.00)*30.00; }elseif($_POST['rec_country']=='ro' || $_GET['country']=='ro'){ //Set shipping for Romania $shipping = ceil($total/60.00)*48.00; }elseif($_POST['rec_country']=='slv' || $_GET['country']=='slv'){ //Set shipping for Slovakia $shipping = ceil($total/60.00)*32.00; }elseif($_POST['rec_country']=='slk' || $_GET['country']=='slk'){ //Set shipping for Slovenia $shipping = ceil($total/60.00)*29.00; }elseif($_POST['rec_country']=='sp' || $_GET['country']=='sp'){ //Set shipping for Spain $shipping = ceil($total/60.00)*36.00; }elseif($_POST['rec_country']=='swe' || $_GET['country']=='swe'){ //Set shipping for Sweden $shipping = ceil($total/60.00)*32.00; }elseif($_POST['rec_country']=='swi' || $_GET['country']=='swi'){ //Set shipping for Switzerland $shipping = ceil($total/60.00)*55.00; }elseif($_POST['rec_country']=='ukh' || $_GET['country']=='ukh'){ //Set shipping for UK - Highlnads and Islands $shipping = ceil($total/60.00)*18.00; }elseif($_POST['rec_country']=='ukn' || $_GET['country']=='ukn'){ //Set shipping for UK - Northern Island $shipping = ceil($total/60.00)*18.00; }elseif($_POST['rec_country']=='jng' || $_GET['country']=='jng'){ //Set shipping for Jersey and Guernsey $shipping = ceil($total/60.00)*34.00; } } /* */ if(isset($_GET['count'])){ echo (int)$count; exit; } if(isset($_GET['order'])){ if($_GET['order']){ }} if(isset($_GET['ajax'])){ $noAjax = $_GET['ajax']; }else{ $noAjax = false; } $smarty->assign('noAjax',$noAjax); if(isset($_GET['t'])){ $t=$_GET['t'].'.tpl'; } else { $t = 'cart.tpl'; } if(isset($_POST['cmd'])) { $_SESSION['paypal'] = $_POST; //print_r($_POST); } if(isset($_POST['rec_houseA1'])){ $filename = time().'-'.rand(1,499); $paypal = $_SESSION['paypal']; unset($paypal['checkout_x']); unset($paypal['checkout_y']); $_SESSION['addresses'] = $_POST; $File = 'sales/'.$filename.'.php'; $Handle = fopen($File, 'x'); fwrite($Handle,'<? '); fwrite($Handle,'$cart = array('); foreach($cartBox as $k=>$v){ fwrite($Handle,'"'.$k.'"=>array('); foreach($v as $key=>$value){ if(is_object($value)){ fwrite($Handle,'"'.$key.'"=>(object)array('); foreach($value as $keys=>$values){ if(is_array($values)){ fwrite($Handle,'"'.$keys.'"=>array('); foreach($values as $keyd=>$valued){ fwrite($Handle, '"'.$keyd.'"=>"'.$valued.'",'); } fwrite($Handle,'""=>""),'); }else{ fwrite($Handle, '"'.$keys.'"=>"'.$values.'",'); } } fwrite($Handle,'""=>""),'); }else{fwrite($Handle, '"'.$key.'"=>"'.$value.'",');} } fwrite($Handle,'""=>""),'); } //$total += $_POST['shipping']; fwrite($Handle,'"total"=>"'.$total.'");'); fwrite($Handle,' '); fwrite($Handle,'$detail = array('); foreach($_POST as $k=>$v){ if(is_array($v)){ fwrite($Handle,'array('); foreach($v as $key=>$value){ if(is_array($value)){ fwrite($Handle,'array('); foreach($value as $keys=>$values){ fwrite($Handle, '"'.$keys.'"=>"'.$values.'",'); } fwrite($Handle,')'); }else{fwrite($Handle, '"'.$key.'"=>"'.$value.'",');} } fwrite($Handle,')'); }else{ fwrite($Handle, '"'.$k.'"=>"'.$v.'",'); } } fwrite($Handle,'""=>"");'); fwrite($Handle,' '); fwrite($Handle,'$paypal = array('); foreach($paypal as $k=>$v){ if(is_array($v)){ fwrite($Handle,'array('); foreach($v as $key=>$value){ if(is_array($value)){ fwrite($Handle,'array('); foreach($value as $keys=>$values){ fwrite($Handle, '"'.$keys.'"=>"'.$values.'",'); } fwrite($Handle,')'); }else{fwrite($Handle, '"'.$key.'"=>"'.$value.'",');} } fwrite($Handle,')'); }else{ fwrite($Handle, '"'.$k.'"=>"'.$v.'",'); } } fwrite($Handle,'""=>"");'); fwrite($Handle,' '); fwrite($Handle,'$shipping = "'.$shipping.'"; '); fwrite($Handle,'$subtotal = "'.$total.'"; '); $totals = $total+$shipping; fwrite($Handle,'$totals = "'.$totals.'";'); fclose($Handle); $smarty->assign('filename',$filename); $smarty->assign('shipping',$shipping); $smarty->assign('paypal',$paypal); //print_r($paypal); $smarty->display('paypal.tpl'); }else{ $smarty->assign('total',$total+$shipping); $smarty->assign('itemsInBox',$count); $smarty->assign('cartBox',$cartBox); $smarty->assign('shipping',$shipping); $style = $db->select("SELECT * FROM styles WHERE `name`='default'"); $smarty->assign('style',$style); $smarty->display($t); } ?> <?php // form processing code, test if a form submitted to this page if(strtolower($_SERVER['REQUEST_METHOD']) == 'post'){ // was a form, process the form data $errors = array(); // use an array to hold validation errors // filter/validate the expected data $email = trim($_POST['email']); // trim any starting/ending white-space if($email == ''){ $errors[] = "Email cannot be empty."; } else { // test if value has the correct format if(function_exists('filter_var')){ // php5.2 or better if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors[] = "Email address format is not valid."; } } else { // alternate code to validate email format would go here (php < 5.2) ... } } // other validation tests as needed by your application ... // if no validation errors, use the form data here... if(empty($errors)){ $con = mysql_connect("organicgrowshopcouk.fatcowmysql.com","worm","*aldoushuxley2012*"); if (!$con){ die('Could not connect: ' . mysql_error()); } mysql_select_db("ogs_mailinglist1", $con); $sql=sprintf("INSERT INTO mailinglist (email) VALUES ('%s')", mysql_real_escape_string($email)); if (!mysql_query($sql,$con)){ die('Error: ' . mysql_error()); } mysql_close($con); } } else { // not a form submission, handle that state here... // what you do here depends on if this page only handles the form submission or if the form itself is on this same page... } // display any errors if(!empty($errors)){ echo "Please correct the following errors:<br />"; foreach($errors as $error){ echo "$error<br />"; } } // if the form is on this same page, you would display/redisplay it here, otherwise output a link back to the form page or store any errors and submitted data in session variables and redirect back to the form page . ?> Any help is much appreciated!
  3. Hello people, Can anyone out there help me figure out how to get my php mailing list to send an email to everyone in my database? I am using php mailer and have tried using the 'MAILQUEUE_THROTTLE' function. but it does not seem to work ! Is there any other way around this, i just can't understand why it won't work!! when i try to send emails from my database manually i can only send 4 at a time....
  4. This cron stuff seems complicated. Is there a simple easy way of doing this with just php? Thanks, Hash
  5. Hi there, I have a mailing list script that i am using to send out an email to everyone on my database. The problem i am having is that my host will only let me send the email to 4 addresses at once and there is a limit of 500 per hour. How can i make it so the script just sends out 4 emails at a time an no more than 500 an hour? this is the code i am using: <?php require('connect.php'); // Grab our config settings require_once($_SERVER['DOCUMENT_ROOT'].'/config.php'); // Grab the FreakMailer class require_once($_SERVER['DOCUMENT_ROOT'].'/include/MailClass.inc'); /* Note: set_time_limit() does not work with safe_mode enabled */ $result_message = ''; if (isset($_POST['submit'])) { $errors = array(); if (empty($_POST['email_addresses'])) { $errors['emails'] = 'No emails selected.'; } // here you can/should loop through and verify email addresses to avoid spamming; put a restriction to # of emails allowed to be sent, etc. // santizing/controlling your email functions is greatly overlooked and can cause your site to be dropped by your hosting provider if your site is being used to send gobs of spam if (empty($errors)) { $result_message = 'There was a problem sending this mail!'; // instantiate the class $mailer = new FreakMailer(); // Build foreach ($_POST['email_addresses'] as $email_address) { $mailer->AddBCC($email_address); } // Set the subject $mailer->Subject = 'New Products from The Organic Grow Shop'; $mailer->isHTML(true); if ($mailer->Send()) { $result_message = 'Mail sent!'; } $mailer->ClearAddresses(); $mailer->ClearAttachments(); } } $sql = "SELECT * FROM mailinglist"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result) > 0) { echo (!empty($result_message) ? $result_message .'<br/><br/>' : ''); echo " <h1>Mailing List</h1> Send to<br/><br/> <form action='send.php' method='POST'> "; while ($getrow = mysql_fetch_assoc($result)) { echo "<input type='checkbox' name='email_addresses[]' value='". $getrow['email'] ."' unchecked='unchecked'/>". $getrow['email'] ."<br>"; } echo "<input type='submit' name='submit' value='Send »'/></form>"; } else { echo 'Add some email addresses.'; } } else { trigger_error(mysql_error()); } ?>
  6. Hi there, I am using php mailer and this piece of code: <?php require('connect.php'); // Grab our config settings require_once($_SERVER['DOCUMENT_ROOT'].'/config.php'); // Grab the FreakMailer class require_once($_SERVER['DOCUMENT_ROOT'].'/include/MailClass.inc'); $result_message = ''; if (isset($_POST['submit'])) { $errors = array(); if (empty($_POST['email_addresses'])) { $errors['emails'] = 'No emails selected.'; } // here you can/should loop through and verify email addresses to avoid spamming; put a restriction to # of emails allowed to be sent, etc. // santizing/controlling your email functions is greatly overlooked and can cause your site to be dropped by your hosting provider if your site is being used to send gobs of spam if (empty($errors)) { $result_message = 'There was a problem sending this mail!'; // instantiate the class $mailer = new FreakMailer(); // Build foreach ($_POST['email_addresses'] as $email_address) { $mailer->AddBCC($email_address); } // Set the subject $mailer->Subject = 'New Products from The Organic Grow Shop'; $mailer->isHTML(true); if ($mailer->Send()) { $result_message = 'Mail sent!'; } $mailer->ClearAddresses(); $mailer->ClearAttachments(); } } $sql = "SELECT * FROM mailinglist"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result) > 0) { echo (!empty($result_message) ? $result_message .'<br/><br/>' : ''); echo " <h1>Mailing List</h1> Send to<br/><br/> <form action='send.php' method='POST'> "; while ($getrow = mysql_fetch_assoc($result)) { echo "<input type='checkbox' name='email_addresses[]' value='". $getrow['email'] ."' unchecked='unchecked'/>". $getrow['email'] ."<br>"; } echo "<input type='submit' name='submit' value='Send »'/></form>"; } else { echo 'Add some email addresses.'; } } else { trigger_error(mysql_error()); } ?> I can send emails to multiple address ok, have tested sending to 5 addresses at once and this worked fine, but when i try and send the email to everyone in my database it doesn't work. I think what might be happening is that there are emails in my database that aren't correct and this is stopping it from sending out the rest of the emails when it gets to that point. Does that sound plausible? What else could it be? is there a way to weed out any incorrect emails from my database? Any help is much appreciated!!!
  7. THANK YOU!!! It worked! You are awesome!
  8. That's great, thanks! Just one problem with it though is this part: $emails = implode(',', $_POST['email_addresses']); It says: Invalid address: info@organicgrowshop.co.uk,mj12@hushmail.comThere was a problem sending this mail! How do i get it so that comma is a line break? Cheers, Hashstar
  9. Yep you're correct. It is for multiple email addresses.
  10. Hi mrMarcus What am i looking for in the class to ensure accuracy? not sure what bit of this i need to change and what to change it to?: $emails = implode(';', $_GET['mail']); $mailer->AddAddress = $emails Cheers
  11. Hi scootstah, I am trying to send out a an email to a mailing list. This is the php page that i get the data from mysql database: <?php require('connect.php'); echo "<h1>Mailing List</h1>Send to<p>"; //setup variables $mailcount = 0; $get = mysql_query("SELECT * FROM mailinglist"); echo"<form action='send.php' method='GET'>"; while ($getrow = mysql_fetch_assoc($get)) { echo "<input type='checkbox' name='mail_".$mailcount++."' value='".$getrow['email']."' CHECKED>".$getrow['email']."<br>"; } echo "<input type='submit' name'submit' value='send'> </form>"; ?> I had tried it another way which worked just as well <?php // Grab our config settings require_once($_SERVER['DOCUMENT_ROOT'].'/config.php'); // Grab the FreakMailer class require_once($_SERVER['DOCUMENT_ROOT'].'/include/MailClass.inc'); // instantiate the class $mailer = new FreakMailer(); // Set the subject $mailer->Subject = 'This is a test'; // Body $mailer->Body = 'This is a test of my mail system!'; // Get the user's Email $con = mysql_connect("organicgrowshopcouk.fatcowmysql.com","worm","*aldoushuxley2012*"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ogs_mailinglist1", $con); $result = mysql_query("SELECT * FROM mailinglist"); while($row = mysql_fetch_array($result)) { echo $row['email'] . " " ; echo "<br />"; } if(!$mailer->Send()) { echo 'There was a problem sending this mail!'; } else { echo 'Mail sent!'; } $mailer->ClearAddresses(); $mailer->ClearAttachments(); ?> i don't know how to get the the email address into $mailer->AddAddress tho...
  12. I am trying to send out an email to a mailing list with php mailer. The problem i am having is how to use the email addresses that are in the database. I can access the database and get the data, i can pass the data in a form but i can't figure out how to get it into $mailer->AddAddress this is the code i am trying at the minute <?php require('connect.php'); // Grab our config settings require_once($_SERVER['DOCUMENT_ROOT'].'/config.php'); // Grab the FreakMailer class require_once($_SERVER['DOCUMENT_ROOT'].'/include/MailClass.inc'); // instantiate the class $mailer = new FreakMailer(); // Set the subject $mailer->Subject = 'This is a test'; // Body $mailer->Body = 'This is a test of my mail system!'; //loop through for($x=0;$x<count($_GET);$x++) { if ($_GET["mail_$x"]) { } } if(!$mailer->Send()) { echo 'There was a problem sending this mail!'; } else { echo 'Mail sent!'; } $mailer->ClearAddresses(); $mailer->ClearAttachments(); ?> this is the part that contains the email address : for($x=0;$x<count($_GET);$x++) { if ($_GET["mail_$x"]) Where do i go from here? I know i really need to understand more of the basics, but I've started this now and it's really bugging me that i can't get it to work! Please help me :-\ Hashstar
  13. Can someone explain to me how this is done?
  14. NLT: yep i am using this on a server with SMTP Thorpe: Ah ok, this is the code from my MailClass file i am using if it's any help? <?php require_once($_SERVER['DOCUMENT_ROOT'].'/include/phpmailer.class.php'); class FreakMailer extends PHPMailer { var $priority = 3; var $to_name; var $to_email; var $From = null; var $FromName = null; var $Sender = null; function FreakMailer() { global $site; // Comes from config.php $site array if($site['smtp_mode'] == 'enabled') { $this->Host = $site['smtp_host']; $this->Port = $site['smtp_port']; if($site['smtp_username'] != '') { $this->SMTPAuth = true; $this->Username = $site['smtp_username']; $this->Password = $site['smtp_password']; } $this->Mailer = "smtp"; } if(!$this->From) { $this->From = $site['from_email']; } if(!$this->FromName) { $this-> FromName = $site['from_name']; } if(!$this->Sender) { $this->Sender = $site['from_email']; } $this->Priority = $this->priority; } } ?>
  15. Hi NLT, i added: echo $row['email'] and it prints the email on the screen so i know i am deftly getting the data from the database. But it won't send the email...
  16. Oh ok, i don't know if i am getting a result i thought that this part would send the email if(!$mailer->Send()) but i am not getting an email so assumed that it was a problem with getting the email from the database... p.s sorry about posting database info, will be more careful in future
  17. Hi there, I am trying to use some php code to get a users email address from mysql database, can someone please check my code and see where i am going wrong? <?php $con = mysql_connect("*","*","*"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ogs_mailinglist1", $con); $result = mysql_query("SELECT * FROM mailinglist"); while($row = mysql_fetch_array($result)) { echo $row['email'] . " " ; echo "<br />"; } // Grab our config settings require_once($_SERVER['DOCUMENT_ROOT'].'/config.php'); // Grab the FreakMailer class require_once($_SERVER['DOCUMENT_ROOT'].'/include/MailClass.inc'); // instantiate the class $mailer = new FreakMailer(); // Set the subject $mailer->Subject = 'This is a test'; // Body $mailer->Body = 'This is a test of my mail system!'; // Get the user's Email $sql = mysql_query("SELECT email FROM users WHERE 1"); while($row = mysql_fetch_object($result)) mysql_close($con); if(!$mailer->Send()) { echo 'There was a problem sending this mail!'; } else { echo 'Mail sent!'; } $mailer->ClearAddresses(); $mailer->ClearAttachments(); ?> I think the problem is with this part: // Get the user's Email $sql = mysql_query("SELECT email FROM users WHERE 1"); while($row = mysql_fetch_object($result)) but i don't know how to correct it Thanks, Hash
  18. Hi again, I changed my code as you suggested but am still getting some blank data sent to the database. I'm sure that this data is coming from blank forms being filled in.
  19. How do you mean, check if there is anything in there?
  20. Hi there, I am using this code to send the users email address to the database. That works fine, but i keep getting blank info added to the database. Does anyone know how i can stop this? <?php $con = mysql_connect("*","*","*"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ogs_mailinglist1", $con); $sql="INSERT INTO mailinglist (email) VALUES ('$_POST[rec_email]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); ?> Thanks,
  21. Ah that solved it!! Thanks for the help guys!!!
  22. Hi thanks for the quick replies! Sorry will use cod tags in future . downah: i do not have an auto increment field in my table. I only have 1 field in the table right now.
  23. Hi there, I am trying to add a bit of php to capture an email address and add it to mysql database. This part works fine but i get this message: Error: Duplicate entry '' for key 'PRIMARY' How do i get rid of this error? Thanks! <?php session_start(); include('include/includes.php'); $cart = Cart::CreateInstance(); if(isset($_GET)){ foreach($_GET as $k=>$v){ $smarty->assign($k,$v); } } if(isset($_GET['remove'])){ $cart->RemoveItems($_GET['remove'],1); } if(isset($_GET['removeAll'])){ $cart->RemoveItems($_GET['removeAll'],$_GET['counts']); } if(isset($_GET['emptyCart'])){ if($_GET['emptyCart']){ $cart->EmptyCart(); header("Location: cart.html"); exit(0); }} if(isset($_GET['add'])){ $itemId = $_GET['add']; $size = $_GET['size']; if (isset($_GET['qty'])) { $qty = $_GET['qty']; } else { $qty = 1; } $cart->addItems($itemId.'-'.$size, array($size,$itemId), $qty); } $cart = Cart::CreateInstance(); $cartBox = $cart->GetCart(); //print_r($cartBox); $total = 0; $subTotal = array(); $db = new DB(); $prods = $db->select("SELECT friendly,name,id FROM products"); $smarty->assign('prods',$prods); if(is_array($cartBox)){ foreach($cartBox as $key=>$item){ $id = $cartBox[$key]['data']->_itemData[1]; $products = $db->select("SELECT detail,image,friendly,name FROM products WHERE id='$id'"); $detailjson = json_decode($products[0]['detail']); foreach($detailjson as $detail){ list($k, $v) = split_by_colon($detail); if($k == $cartBox[$key]['data']->_itemData[0]){ $price = $v;} } $cartBox[$key]['data']->_itemData[3] = $products[0]['image']; $cartBox[$key]['data']->_itemData[6] = $products[0]['name']; $cartBox[$key]['data']->_itemData[2] = $products[0]['friendly']; $cartBox[$key]['data']->_itemData[5] = $price; $sub = (int)$item['count'] * $price; $cartBox[$key]['data']->_itemData[4] = $sub; $total += $sub; } } else { $cartBox = array(); } $count = $cart->GetItemsCount(); $shipping = (int)0; if($total>0&&$total<5){ $shipping = 2.99; }elseif($total>5&&$total<10){ $shipping = 3.99; }elseif($total>10&&$total<15){ $shipping = 4.99; }elseif($total>15&&$total<20){ $shipping = 5.99; }elseif($total>20&&$total<30){ $shipping = 6.99; }elseif($total>30&&$total<40){ $shipping = 7.99; }elseif($total>40&&$total<50){ $shipping = 8.99; }elseif($total>50&&$total<60){ $shipping = 9.99; }elseif($total>60&&$total<70){ $shipping = 10.99; }elseif($total>70&&$total<80){ $shipping = 11.99; }elseif($total>80&&$total<90){ $shipping = 12.99; }elseif($total>90&&$total<100){ $shipping = 15.99; }elseif($total>100&&$total<110){ $shipping = 16.99; }elseif($total>110&&$total<120){ $shipping = 17.99; }elseif($total>120&&$total<130){ $shipping = 18.99; }elseif($total>130&&$total<140){ $shipping = 19.99; }elseif($total>140&&$total<150){ $shipping = 20.99; }elseif($total>150&&$total<160){ $shipping = 21.99; }elseif($total>160&&$total<170){ $shipping = 22.99; }elseif($total>170&&$total<180){ $shipping = 23.99; }elseif($total>180){ $shipping = 24.99; } /* 0 - 4.99 = 2.99 5 - 9.99 = 3.99 10 - 14.99 = 4.99 15 - 19.99 = 5.99 20 - 29.99 = 6.99 30 - 39.99 = 7.99 40 - 49.99 = 8.99 50 - 69.99 = 9.99 70 - 99.99 = 10.99 100+ = 12.99 */ if(isset($_GET['eushipping'])||(isset($_POST['rec_country'])&&$_POST['rec_country']!='uk')){ if($_POST['rec_country']=='au' || $_GET['country']=='au'){ //Set shipping for Austria $shipping = ceil($total/60.00)*30.00; }elseif($_POST['rec_country']=='be' || $_GET['country']=='be'){ //Set shipping for Belgium $shipping = ceil($total/60.00)*20.00; }elseif($_POST['rec_country']=='bu' || $_GET['country']=='bu'){ //Set shipping for Bulgaria $shipping = ceil($total/60.00)*50.00; }elseif($_POST['rec_country']=='cy' || $_GET['country']=='cy'){ //Set shipping for Cyprus $shipping = ceil($total/60.00)*108.00; }elseif($_POST['rec_country']=='cz' || $_GET['country']=='cz'){ //Set shipping for Czech Republic $shipping = ceil($total/60.00)*33.00; }elseif($_POST['rec_country']=='de' || $_GET['country']=='de'){ //Set shipping for Denmark $shipping = ceil($total/60.00)*30.00; }elseif($_POST['rec_country']=='es' || $_GET['country']=='es'){ //Set shipping for Estonia $shipping = ceil($total/60.00)*45.00; }elseif($_POST['rec_country']=='fi' || $_GET['country']=='fi'){ //Set shipping for Finalnd $shipping = ceil($total/60.00)*30.00; }elseif($_POST['rec_country']=='fr' || $_GET['country']=='fr'){ //Set shipping for France $shipping = ceil($total/60.00)*28.00; }elseif($_POST['rec_country']=='ge' || $_GET['country']=='ge'){ //Set shipping for Germany $shipping = ceil($total/60.00)*25.00; }elseif($_POST['rec_country']=='gr' || $_GET['country']=='gr'){ //Set shipping for Greece $shipping = ceil($total/60.00)*50.00; }elseif($_POST['rec_country']=='hu' || $_GET['country']=='hu'){ //Set shipping for Hungary $shipping = ceil($total/60.00)*25.00; }elseif($_POST['rec_country']=='ir' || $_GET['country']=='ir'){ //Set shipping for Ireland $shipping = ceil($total/60.00)*25.00; }elseif($_POST['rec_country']=='it' || $_GET['country']=='it'){ //Set shipping for Italy $shipping = ceil($total/60.00)*30.00; }elseif($_POST['rec_country']=='la' || $_GET['country']=='la'){ //Set shipping for Latvia $shipping = ceil($total/60.00)*42.00; }elseif($_POST['rec_country']=='li' || $_GET['country']=='li'){ //Set shipping for Lithuania $shipping = ceil($total/60.00)*35.00; }elseif($_POST['rec_country']=='lu' || $_GET['country']=='lu'){ //Set shipping for Luxembourg $shipping = ceil($total/60.00)*20.00; }elseif($_POST['rec_country']=='ma' || $_GET['country']=='ma'){ //Set shipping for Malta $shipping = ceil($total/60.00)*108.00; }elseif($_POST['rec_country']=='ne' || $_GET['country']=='ne'){ //Set shipping for Netherlands $shipping = ceil($total/60.00)*25.00; }elseif($_POST['rec_country']=='no' || $_GET['country']=='no'){ //Set shipping for Norway $shipping = ceil($total/60.00)*37.00; }elseif($_POST['rec_country']=='pol' || $_GET['country']=='pol'){ //Set shipping for Poland $shipping = ceil($total/60.00)*35.00; }elseif($_POST['rec_country']=='por' || $_GET['country']=='por'){ //Set shipping for Portugal $shipping = ceil($total/60.00)*30.00; }elseif($_POST['rec_country']=='ro' || $_GET['country']=='ro'){ //Set shipping for Romania $shipping = ceil($total/60.00)*48.00; }elseif($_POST['rec_country']=='slv' || $_GET['country']=='slv'){ //Set shipping for Slovakia $shipping = ceil($total/60.00)*32.00; }elseif($_POST['rec_country']=='slk' || $_GET['country']=='slk'){ //Set shipping for Slovenia $shipping = ceil($total/60.00)*29.00; }elseif($_POST['rec_country']=='sp' || $_GET['country']=='sp'){ //Set shipping for Spain $shipping = ceil($total/60.00)*36.00; }elseif($_POST['rec_country']=='swe' || $_GET['country']=='swe'){ //Set shipping for Sweden $shipping = ceil($total/60.00)*32.00; }elseif($_POST['rec_country']=='swi' || $_GET['country']=='swi'){ //Set shipping for Switzerland $shipping = ceil($total/60.00)*55.00; }elseif($_POST['rec_country']=='ukh' || $_GET['country']=='ukh'){ //Set shipping for UK - Highlnads and Islands $shipping = ceil($total/60.00)*18.00; }elseif($_POST['rec_country']=='ukn' || $_GET['country']=='ukn'){ //Set shipping for UK - Northern Island $shipping = ceil($total/60.00)*18.00; }elseif($_POST['rec_country']=='jng' || $_GET['country']=='jng'){ //Set shipping for Jersey and Guernsey $shipping = ceil($total/60.00)*34.00; } } /* */ if(isset($_GET['count'])){ echo (int)$count; exit; } if(isset($_GET['order'])){ if($_GET['order']){ }} if(isset($_GET['ajax'])){ $noAjax = $_GET['ajax']; }else{ $noAjax = false; } $smarty->assign('noAjax',$noAjax); if(isset($_GET['t'])){ $t=$_GET['t'].'.tpl'; } else { $t = 'cart.tpl'; } if(isset($_POST['cmd'])) { $_SESSION['paypal'] = $_POST; //print_r($_POST); } if(isset($_POST['rec_houseA1'])){ $filename = time().'-'.rand(1,499); $paypal = $_SESSION['paypal']; unset($paypal['checkout_x']); unset($paypal['checkout_y']); $_SESSION['addresses'] = $_POST; $File = 'sales/'.$filename.'.php'; $Handle = fopen($File, 'x'); fwrite($Handle,'<? '); fwrite($Handle,'$cart = array('); foreach($cartBox as $k=>$v){ fwrite($Handle,'"'.$k.'"=>array('); foreach($v as $key=>$value){ if(is_object($value)){ fwrite($Handle,'"'.$key.'"=>(object)array('); foreach($value as $keys=>$values){ if(is_array($values)){ fwrite($Handle,'"'.$keys.'"=>array('); foreach($values as $keyd=>$valued){ fwrite($Handle, '"'.$keyd.'"=>"'.$valued.'",'); } fwrite($Handle,'""=>""),'); }else{ fwrite($Handle, '"'.$keys.'"=>"'.$values.'",'); } } fwrite($Handle,'""=>""),'); }else{fwrite($Handle, '"'.$key.'"=>"'.$value.'",');} } fwrite($Handle,'""=>""),'); } //$total += $_POST['shipping']; fwrite($Handle,'"total"=>"'.$total.'");'); fwrite($Handle,' '); fwrite($Handle,'$detail = array('); foreach($_POST as $k=>$v){ if(is_array($v)){ fwrite($Handle,'array('); foreach($v as $key=>$value){ if(is_array($value)){ fwrite($Handle,'array('); foreach($value as $keys=>$values){ fwrite($Handle, '"'.$keys.'"=>"'.$values.'",'); } fwrite($Handle,')'); }else{fwrite($Handle, '"'.$key.'"=>"'.$value.'",');} } fwrite($Handle,')'); }else{ fwrite($Handle, '"'.$k.'"=>"'.$v.'",'); } } fwrite($Handle,'""=>"");'); fwrite($Handle,' '); fwrite($Handle,'$paypal = array('); foreach($paypal as $k=>$v){ if(is_array($v)){ fwrite($Handle,'array('); foreach($v as $key=>$value){ if(is_array($value)){ fwrite($Handle,'array('); foreach($value as $keys=>$values){ fwrite($Handle, '"'.$keys.'"=>"'.$values.'",'); } fwrite($Handle,')'); }else{fwrite($Handle, '"'.$key.'"=>"'.$value.'",');} } fwrite($Handle,')'); }else{ fwrite($Handle, '"'.$k.'"=>"'.$v.'",'); } } fwrite($Handle,'""=>"");'); fwrite($Handle,' '); fwrite($Handle,'$shipping = "'.$shipping.'"; '); fwrite($Handle,'$subtotal = "'.$total.'"; '); $totals = $total+$shipping; fwrite($Handle,'$totals = "'.$totals.'";'); fclose($Handle); $smarty->assign('filename',$filename); $smarty->assign('shipping',$shipping); $smarty->assign('paypal',$paypal); //print_r($paypal); $smarty->display('paypal.tpl'); }else{ $smarty->assign('total',$total+$shipping); $smarty->assign('itemsInBox',$count); $smarty->assign('cartBox',$cartBox); $smarty->assign('shipping',$shipping); $style = $db->select("SELECT * FROM styles WHERE `name`='default'"); $smarty->assign('style',$style); $smarty->display($t); } ?> <?php $con = mysql_connect("organicgrowshopcouk.fatcowmysql.com","worm","*******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ogs_mailinglist1", $con); $sql="INSERT INTO mailinglist (email) VALUES ('$_POST[rec_email]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); ?>
  24. Hi there, i am trying to send a html using phpMailer and am following this tutorial: http://www.askapache.com/php/phpfreaks-eric-rosebrocks-phpmailer-tutorial.html I have managed to send an email just fine but when i try to add html to it it doesn't work! I get this message: Mail sent! Fatal error: Call to undefined method FreakMailer::Body() in /hermes/waloraweb018/b1267/moo.organicgrowshopcouk/testemail.php on line 44 This is the code I'm using: <?php // Grab our config settings require_once($_SERVER['DOCUMENT_ROOT'].'/config.php'); // Grab the FreakMailer class require_once($_SERVER['DOCUMENT_ROOT'].'/include/MailClass.inc'); // instantiate the class $mailer = new FreakMailer(); // Set the subject $mailer->Subject = 'This is a test'; // Body $mailer->Body = 'This is a test of my mail system!'; // Add an address to send to. $mailer->AddAddress('info@organicgrowshop.co.uk', 'Matt Johnson'); if(!$mailer->Send()) { echo 'There was a problem sending this mail!'; } else { echo 'Mail sent!'; } $mailer->ClearAddresses(); $mailer->ClearAttachments(); $htmlBody = '<html> <head> <title>My HTML Email</title> </head> <body> <br /> <h2>PHP Freaks Rules!</h2> <p>We invite you to visit <a href="http://www.phpfreaks.com" title="PHP Freaks">PHP Freaks.com</a> for a loving community of PHP Developers who enjoy helping each other learn the language!</p> <p>Sincerely,<br /> PHP Freaks Staff</p>'; $mailer->Body($htmlBody); $mailer->isHTML(true); // Send the E-Mail ?> How do i define method Body() ? Do i need to change something in the phpmailer.class.php file? Sorry if i sound like a complete n00b.
  25. Hi, Thanks for getting back to me! I had found that much but and have tried that but it doesn't work.... also doesn't explain why the js and css that i have in the template file is working??? Cheers, Hash
×
×
  • 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.