tryingtolearn
Members-
Posts
293 -
Joined
-
Last visited
-
Days Won
1
Everything posted by tryingtolearn
-
So is the PEAR package the answer to this? anyone???
-
Hi all I wrote a system that will allow sending an email to a list of users (Currently 2935 users) It takes the names of everyone in the list unless they opted out and sends the mail then is supposed to notify who it sent to. Here is the problem, It works fine when I tested it with 7 users All 7 emails were sent and the page displayed the 7 email address it sent it to. but when I ran it with the full database the page sat there for a while (Because of so many emails - I get that part) but eventually came up with a page cannot be displayed page No errors or anything and according to the tracking All 2935 emails were delivered. The 2nd email template sent - well I hit refresh when the page cannot be displayed came up and it sent the mail twice. I have read to use the PEAR Mail for large lists but Im honest - I have no idea how to even use that when I go to their page??? And I tried an example of adding sleep that I saw somewhere but that didnt do anything I never even got the message saying it was taking a break So I am not sure I did that right. So is there anything I can do to this existing code to solve the page cannot be displayed if (isset($_POST['submitted'])) { // Check if the form has been submitted. // Validate. if (!empty($_POST['mail'])) { $m = escape_data($_POST['mail']); } else { echo '<p><font color="red">You forgot to select a template!</font></p>'; $m = FALSE; } if ($m) { // If everything's OK. $query1 = "SELECT emess_mess, emess_title FROM maillist WHERE emess_id='$m'"; $result1 = @mysql_query ($query1); // Run the query. while ($row1 = mysql_fetch_array($result1, MYSQL_ASSOC)) { $em = $row1['emess_title']; $query = "SELECT * FROM mailer WHERE mail_receive='Yes'"; $result = @mysql_query ($query); // Run the query. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $to = $row['mail_email']; $sent = date("D M j Y - g:i a"); $message = "Sent - $sent <br /> \n"; $message .= "If you cannot view this email, visit <a href=\"http://www.website.com\">website by clicking here</a></p> \n"; $message .= $row1['emess_mess']; $subject = $em; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: '.$to.'' . "\r\n"; $headers .= "From: website\r\nReply-To: [email protected]"; // Mail it $query3 = "INSERT INTO sent (title, sent_to) VALUES ('$em', '$to')"; $result3 = @mysql_query ($query3); // Run the query. $mail_sent = @mail($to, $subject, $message, $headers); //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" echo $mail_sent ? "Mail sent to $to <br />" : "Mail failed to $to <br />"; }//end message while }//end to while include ('./includes/footer.html'); // Include the HTML footer. exit(); } else { // If it did not run OK. echo '<p><font color="red">We could not send the mail</font></p>'; } }//end if submitted Here is the sleep code I tried set_time_limit(0); // Lets send 100 emails at a time, with a 3 minute break $wth = 100; // how many emails to send at a time $sent = 0; // emails sent $select = mysql_query("") or die(mysql_error()); while($x = mysql_fetch_array($select)) { $sent+1; // add one to the sent count if( $sent == $wth ) { sleep( 300 ); echo "Taking a break for 3 minutes.."; $sent = 0; // reset the sent count to 0 } mail(); // put your mail function here
-
I am having to modify a registration form to include the users address for shipping details. I am wondering Is there a standard for this to allow most international type addresses? Like US would be Address 1 Address 2 City State Zip Code But other countries are set up different Is there some format that most of you follow for a situation like this? Thanks
-
I have a form and when a user gets to a point in the form to upload images I would like for them to be able to select how many image upload fields are displayed by selecting a number from a dropdown box (So if they select 1 - 1 upload field appears - if they select 5 - 5 fields appear etc...) But I do not want the page to have to reload - Is that possible?
-
mail function questions for large amouont of emails
tryingtolearn replied to tryingtolearn's topic in PHP Coding Help
Thanks for the link. I checked w/ the host That wont work. The free one doesnt even import a csv file - you have to copy and paste the addresses The paid one is $30.00 a month. Back to the drawing board. -
mail function questions for large amouont of emails
tryingtolearn replied to tryingtolearn's topic in PHP Coding Help
Thanks for the quick response. cooldude832 I will check w/ the hosting if they offer that. When they offer something like that - are you saying it is configurable (sp?) so I could have people unsubscribe etc... Blade280891 Do you run the risk that cooldude was talking about Being labled a spammer w/ phpmailer -
I have been reading the mail() function and am a bit worried about this note What is considered a larger volumes? I have a list of about 10,000 customers in a file that I need to periodically send mail to. To me, that sounds like a large volume Is that something that the PEAR::MAIL would be better for? If so, is there anything I have to check for in order to use it? Or anything that gives a step by step on setting it up? Like what do I download The whole package? Does it all get uploaded?? Thanks for any input
-
</br> is not a valid tag If you re trying to get a line break it is <br />
-
MFHJoe Thanks again, Played around with what you posted and got it working just like I needed. I appreciate you taking the time to help me.
-
MFHJoe That is really great! I will work with that a bit Thank you very much Project Fear I got a Unknown modifier '/' error for this line while(preg_match("/http:\/\/www.url.com\/\?([a-zA-Z0-9]+)/",$source,$tmp_matches)){
-
Im thinking I might be going about this wrong all together I dont know, basically I need to open $_POST['input'] (Which will be a url from a form) search the source code of that (Which is why I was using file_get_contents) and perfom an action each time it finds http://www.url.com/?l65j But everything after the ? is different for each one
-
That worked but the results arent what I was looking for That took each line of the source code of the page and added it to the array ex The value at 0 is <html> The value at 1 is <head> etc.... So I guess I should add $source is going to be something like this <html> <head> <title>Untitled</title> </head> <body> "250","134","image1.gif",""," Joe - hosted ","http://www.url.com/?l65j", "250","134","image2.gif",""," Sally - hosted ","http://www.url.com/?Ut59", "250","134","image3.gif",""," Mary - Not hosted ","http://www.url.com/?MN7F", "250","134","image4.gif",""," Joe - hosted ","http://www.url.com/?WrT3", </body> </html> And I need to extract and perfom an action on each url within I guess that bit of onfo would have helped - sorry
-
I was trying that also but I get an invalid argument supplied for foreach() This is what the form action looks ;ike if(isset($_POST['input'])) { $source = file_get_contents($_POST['input']); $output = htmlspecialchars($source); explode("\n",$output); foreach($output as $key => $value){ echo"The value at $key is $value<br />"; } }
-
Im using file_get_contents to get a string from a form input The result is like this "250","134","image1.gif",""," Joe - hosted ","http://www.url.com/?l65j", "250","134","image2.gif",""," Sally - hosted ","http://www.url.com/?Ut59", "250","134","image3.gif",""," Mary - Not hosted ","http://www.url.com/?MN7F", "250","134","image4.gif",""," Joe - hosted ","http://www.url.com/?WrT3", Is it possible to break down the string for each url and perform an action on each one? I tried various things with strstr and substr but it only returns the first url. So I thought I needed to get each one in an array but I cant seem to get that to work Any ideas??
-
rename() using consecutive numbers
tryingtolearn replied to tryingtolearn's topic in PHP Coding Help
Nevermind, I figured it out $ct = "1"; if ($handle = opendir('./friends')) { while (false !== ($lv = readdir($handle))) { if ($lv != "." && $lv != "..") { $limit = count(glob('./friends/*.*')); $up =$ct++; $root = getcwd(); copy("./friends/$lv", "$root/friends_no/$up.jpg"); } } closedir($handle); } -
Hi All I am trying to use rename() to take all the images in one directory that have a timestamp and filename and rename them to a new directory but change the names to 1.jpg, 2.jpg, 3.jpg etc... But by using this, it only renames the last one. if ($handle = opendir('./friends')) { while (false !== ($lv = readdir($handle))) { if ($lv != "." && $lv != "..") { $root = getcwd(); $limit = count(glob('./friends/*.*')); //just * to count subdirs for ($i = 1; $i <= $limit; $i++) { copy("./friends/$lv", "$root/friends_no/$i.jpg"); } } } closedir($handle); } Anybody have an idea on what I am doing wrong?
-
Thanks for the fast reply phpzone Unfortunetly that didnt work I changed the code to look like this require_once ('../mysql_connect.php'); // Connect to the database. $filename = $path.$date.$HTTP_POST_FILES['userfile']['name']; $handle = fopen("$filename", "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $import="INSERT into leads (prfname2,prlname2,prcaddr12,prcaddr22,prccity2,prcstate2,prcpostco2,prevntdate,prcreated,prhomepho2,premail2,add1,add2,add3,add4) values('mysql_real_escape_string($data[0])','mysql_real_escape_string($data[1])','mysql_real_escape_string($data[2])','mysql_real_escape_string($data[3])','mysql_real_escape_string($data[4])','mysql_real_escape_string($data[5])','mysql_real_escape_string($data[6])','mysql_real_escape_string($data[7])','mysql_real_escape_string($data[8])','mysql_real_escape_string($data[9])','mysql_real_escape_string($data[10])','Y','2','3','4')"; mysql_query($import) or die(mysql_error()); //print_r($data); } fclose($handle); But I still get this error
-
Hi again all, I am trying to upload a csv file and insert the data into a DB But when I encounter an apostrophe in the data it stops Is there a way around this? Code Im using require_once ('../mysql_connect.php'); // Connect to the database. $filename = $path.$date.$HTTP_POST_FILES['userfile']['name']; $handle = fopen("$filename", "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $import="INSERT into leads (prfname2,prlname2,prcaddr12,prcaddr22,prccity2,prcstate2,prcpostco2,prevntdate,prcreated,prhomepho2,premail2,add1,add2,add3,add4) values('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]','$data[7]','$data[8]','$data[9]','$data[10]','Y','2','3','4')"; mysql_query($import) or die(mysql_error()); } fclose($handle); For example - everything goes good and then say an address field in the csv file is 555 ALEXANDER'S OAK It stops right there w/ an error. Any help is appreciated.
-
Is there any special procedures for doing this? I found a script on a forum (But it is dated 2003) not sure if that matters But here is the problem Everything uploads fine and then I go to download and that works as well The problem is that when I try to uncompress (Or is it decompress) the downloaded file It wont, The compressed file extraction wizard says its empty But it isnt - If I email the compressed file to myself it works fine So Im wondering if there is something in the script that is causing the problem <?php error_reporting(E_ALL); $file_path = '/home/public_html/files/'; if (empty($_REQUEST['file']) || !preg_match("/^[a-zA-Z_0-9]+.+[a-zA-Z0-9]+$/", $_REQUEST['file'])) { die('Not a valid URL.'); } header("Content-type: application/octet-stream\n"); header("Content-disposition: attachment; filename=\"" . $_REQUEST['file'] . "\"\n"); header("Content-transfer-encoding: binary\n"); header("Content-length: " . filesize($file_path . $_REQUEST['file']) . "\n"); $fp = fopen($file_path . $_REQUEST['file'], "r"); fpassthru($fp); die(); ?>
-
change onclick buttons to onchange from a select
tryingtolearn replied to tryingtolearn's topic in Javascript Help
Worked perfect Thank you very much. -
I am trying to be able to change the font-size and font of text in a div Right now I am using individual buttons for each like this (This works but...) <script type="text/javascript"> function fs(n) { document.getElementById('C').style.fontSize = n } function fn(n) { document.getElementById('C').style.fontFamily = n } </script> <div style="font-family: arial, helvetica, sans-serif; color: #336699;" id="C">Text</div> <input type="button" onClick="fs('12px')" value="12px"> <input type="button" onClick="fs('14px')" value="14px"> <input type="button" onClick="fs('18px')" value="18px"> <input type="button" onClick="fs('24px')" value="24px"> <input type="button" onClick="fs('36px')" value="36px"> <input type="button" onClick="fs('48px')" value="48px"> <input type="button" onClick="fs('60px')" value="60px"> <input type="button" onClick="fs('72px')" value="72px"> <input type="button" onClick="fn('arial')" value="arial"> <input type="button" onClick="fn('tahoma')" value="tahoma"> <input type="button" onClick="fn('times new roman')" value="times new roman"> But Id rather use two dropdown boxes like <select name="fontSize""> <option value="12px">12px</option> <option value="14px">14px</option> <option value="22px">22px</option> <option value="36px">36px</option> <option value="72px">72px</option> </select> <select name="font""> <option value="arial">arial</option> <option value="tahoma">tahoma</option> </select> But I cant seem to figure that out Any ideas on the direction I need to be going in? Thanks