Jump to content

impfut

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

impfut's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Works like a charm! Thank you very much chap!
  2. Hi, I'm fairly new to PHP and need a bit of assistance from a wiser person please. I am trying to build a simple template/tag system and have a problem retrieving the variables from a modified string. Please can someone show me the light? It's driving me crazy. What I want it to output: ... Hello Susan. Your account number is 123. What it currently outputs: .. Hello $memberName. Your account number is $memberAccount. <?php $memberName = "Susan"; $memberAccount = "123"; $content = "Hello [memberName]. Your account number is [memberAccount]."; function replaceTag($string) { $search = array('[', ']'); $replace = array('$', ''); return (string)str_replace($search, $replace, $string); } $statement = replaceTag($content); echo "$statement"; ?> Really struggling with this Cheers Dave
  3. Thank you to everyone for your comments. Based on the above I have modified my script. The DB table now has a column to say whether the person wants to receive the newsletter or not and there is also a column to say whether they have already been emailed. I am also now limiting the script to 100 emails at a time. For anyone who is interested, here is the code. I am still open to improvements if anyone can spot any weakness ;-) <?php include("../../opendb.php"); mysql_select_db($dbname1); $mailtable = $_POST['table']; $mailsubject = $_POST['subject']; $mailmessage = stripslashes($_POST['message']); $maxsend = 100; $sql="SELECT * FROM $mailtable WHERE send='0' AND receive='1' LIMIT $maxsend"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ $name = $rows['name']; $to = $rows['email']; $subject = "$mailsubject"; $header = "from: Me <me@domain.com>"; $message = "Dear $name \r\n"; $message.= " \r\n"; $message.= "$mailmessage \r\n"; $message.=" \r\n"; $message.="Warmest Regards \r\n"; $message.="Name \r\n"; $sentmail=mail($to,$subject,$message,$header); if($sentmail){ $query = "UPDATE $mailtable SET send='1' WHERE email='$to'"; $result2 = mysql_query($query); echo "Email sent to: $to</br>"; } else { $query2 = "UPDATE $mailtable SET send='0' WHERE email='$to'"; $result3 = mysql_query($query2); echo "Error sending to: $to</br>"; } } include("../../closedb.php"); ?>
  4. Nate, that is a fantastic reply!!! Thank you so much for taking the time to help me bud. I hope I can return the favor to others once I'm competent. I will give this a good crack tomorrow. Also, I'm sorry if it came across as me talking about the spam thing directly at you. It was just a general comment to all viewers who might have been concerned about helping a potential spammer. Thank you again chap, I am really, REALLY thankful ;-)
  5. Chronister, thank you for taking the time to write a detailed reply. I have good hosting with a company called Media Temple. I am however on a shared server environment. I'll get in touch with them and see what they say about the situation. Just for the record, I'm not a spammer, the people I'm emailing know my website. It is very unlikely any of them will report me or mark the email as junk so how would I get black listed? Would it be my hosting company? If I wanted to mail in batches, what would I need to do? Say for example I wanted to take 100 at a time, what would I need to change in my code? Thanks for any help guys.
  6. Oh, and I forgot to say.. Merry Christmas
  7. Hi all, this forum proved to be awesome for helping me with my previous query so I'm hopeful it can do so again. I'm a newbie to PHP and it's a lot to take in but I'm really enjoying it so far. It opens up so many possibilities compared to a html only site. Anyway... I have managed to put together a simple email script which is tested and working. The thing is, I'm currently using my test table which has 3 email addresses in it. The real table has over 2000 members. I've never emailed them in one go before but when I do, I want to make sure the script is going to work! The last thing I want is for it to crash or time out and some members get one email, some get two and some don't get anything. I have read that I may have a problem with using mail() for large lists. Should I modify my current script? If so, in what way? I'm really dumb at PHP at the moment so please be gentle. Any help would be much appreciated! Current Script <?php include("../../opendb.php"); mysql_select_db($dbname1); $mailtable = $_POST['table']; $mailsubject = $_POST['subject']; $mailmessage = stripslashes($_POST['message']); $sql="SELECT * FROM $table"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ $name = $rows['name']; $to = $rows['email']; $subject = "$mailsubject"; $header = "from: Me <me@domain.com>"; $message = "Dear $name \r\n"; $message.= " \r\n"; $message.= "$mailmessage \r\n"; $message.=" \r\n"; $message.="Warmest Regards \r\n"; $message.="Me \r\n"; $sentmail=mail($to,$subject,$message,$header); } if($sentmail){ header("location:http://www.domain.com/success.html"); } else { header("location:http://www.domain.com/failure.html"); } include("../../closedb.php"); ?>
  8. AWESOME!!! It's working now, you guys are great! I come from a branding/html/css/photoshop background so PHP is new to me but I'm really enjoying it. I'm still struggling with the fundamentals of how the language "thinks" but once I grasp this I'm sure I'll be fine. Classes, functions etc.. are all very scary at the moment lol. Here's our site if anyone is interested http://www.nodusawards.com official launch should be at the start of Jan. If you do have a look and spot any problems, please let me know. Thanks again!! Dave
  9. Hi guys, looks a cool forum full of people. I've just started getting into PHP. It's really cool (reminds me of building lego when I was a kid) BUT I'm having problems with simple things at the moment. I want to be able to select all records from my table based on whether the value in a column called "Total" is greater than X but less than Y. No idea how to do it though ??? Here's my code, can a guru help me please? <?php include("../opendb.php"); mysql_select_db($dbname2); $tbl_name = "applications"; $low = "49"; $high = "70"; $total = (> $low && < $high); $sql="SELECT * FROM $tbl_name WHERE total = '$total'"; $result=mysql_query($sql); // Start looping rows in mysql database. echo "<ul>\n"; while($rows=mysql_fetch_array($result)){ ?> <li><? echo $rows['date']; ?> - <a href="<? echo $rows['url']; ?>" title="<? echo $rows['title']; ?>" target="_blank"><? echo $rows['title']; ?></a></li> <? // close while loop } echo "</ul>"; // close connection mysql_close(); ?>
×
×
  • 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.