Jump to content

parallax

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

parallax's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks a lot for the help Barand! I just did a test and it worked, perfect. ;D
  2. Yeah that was first on my to-do-list, to backup the database. Also going to run it on a copy of the table first to see if everything went well I am wondering about one thing though. Since the part to be replaced contains html with quotes, how does sql render that in the syntax? For instance: REPLACE(description,"%size="2"%","%size="1"%") Looks kind of odd. Should I maybe use ''? ie. description, 'size="2"', or is it fine as is?
  3. Hi, I have a few questions related to the MySQL (my version is 4.1.20) function Replace. I have a couple of thousand entries in a table, 'descriptions', that are all built on the same html template. But they all have a few html errors which needs to be changed, in other words a small part of a string needs to be replaced in all these records (the string is simple and unique so that is not a problem). As such I figure the best way to go about this is the Replace function in SQL, not any PHP functions such as str_replace, would that be correct? I am not sure wether the standard Replace function such as: UPDATE yourtable SET yourfield = REPLACE(yourfield,"some_string","some_new_string") WHERE yourconditions. would do what I am after? Any advice?
  4. Do you know why the message of the mail gets outputted like this: line1\r\nline2\r\nline3\r\n\r\nline5\r\nline6 Instead of actual breaks?
  5. Yesss, it works now! Thank you again ;)
  6. Yep, it does in fact print out both my emails, with a comma between and at the end.
  7. Still no mails. This is what the code looks like at the moment: [code]    $subject = mysql_real_escape_string($_POST['Subject']);     $message = mysql_real_escape_string($_POST['Message']); $query = mysql_query('SELECT * FROM newsletter'); $mails = ''; while ($r = mysql_fetch_array($query)) {     $mails .= $r['Email'] . ','; } mail('$mails', '$subject', '$message'); echo "Mail was sent:<br>"; //just to check echo "$mails"; } [/code]
  8. Alright, one final question: Doesn't it matter if there is an extra comma at the end? Wouldn't it skip the subject in the mail-statement?  ???
  9. I see, thanks for the tip. Now I am one step closer to the solution. But how would I go about combining the items of an array, separating them with a ',' and saving them as a variable to use in the mail-statement?
  10. Hi, I'm pretty new to php, but today I have been trying to create a very simple newsletter-script. So far I have managed to create the subscription/unsubscription feature, which adds/removes the email to/from a database. I am now stuck on trying to code sending out the newsletter to the recipents. This is what I have got so far: [code]<?php require_once("db.php"); ?> <?php if ($_POST['submit'] == TRUE) {     $subject = mysql_real_escape_string($_POST['Subject']);     $message = mysql_real_escape_string($_POST['Message']); $query = "SELECT * FROM newsletter"; $result = mysql_query($query); while($row = mysql_fetch_array($result)){ $recipents = $row['Email']. "; "; } mail('$recipents', '$subject', '$message'); echo "Mail sent!"; } else {     ?> <h3>Send Newsletter</h3>     <form method="post" action="<?php echo $PHP_SELF ?>">     Subject: &nbsp;&nbsp;<input name="Subject" size="44" maxlength="255">     <br>     Message: <textarea name="Message" rows="20" cols="40"></textarea>     <br>     <input type="submit" name="submit" value="Send Newsletter">     </form>     <? } ?>[/code] Basically I am trying to create an array of the emails from the database, which I have done (if I print $recipents it shows the list of emails) - and then send out one message to all the recipents. When I click on the submit-button, no mail has been sent, but the line "Mail sent!" is still printed. I am not sure if this could be a simple syntax error or a problem with my array or whatever. But the mail function is working on the server (I'm using it in the sub/unsub. features too). Maybe I am just too tired ::), but can anyone see the problem?
×
×
  • 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.