Jump to content
Larry Ullman's Book Forums

Hope4You

Members
  • Posts

    14
  • Joined

  • Last visited

Hope4You's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I'm making a PHP newsletter sender, and I have multiple emails in a database. Is the following code the proper way to send multiple emails? So imagine that I have already done the MySQL call to retrieve all the emails, and I am now here: require_once "Mail.php"; require_once "Mail/mime.php"; $mail = new Mail_Mime(); $mime->setTXTBody('Text email'); $mime->setHTMLBody('HTML email'); $mime->setFrom('Sample Email Sender <sample@email.com>'); $mime->setSubject($subject); $body = $mime->get(); $headers = $mime->headers(); $smtp['host'] = 'smtp.emailserver.com'; $smtp['auth'] = true; $smtp['username'] = 'username@email.com'; $smtp['password'] = 'password'; $mail =& Mail::factory('smtp', $smtp); while($row = @mysqli_fetch_array($rq, MYSQLI_NUM)){$mail->send($row[0], $headers, $body);} unset($mime, $mail); You'll notice that what I did was set all the main email stuff outside of the while{} loop. Is this setup okay? Or do I need to move anything else into the while{} loop? Thanks again.
  2. I read in the blog that this site uses Amazon Cloudfront. I am also interested in using something similar. Q. 1: My site detects when a payment has finished, and I want only the people who paid to be able to download a file on a remote server (Such as Amazon). Is this possible? (I don't want to use a link that someone can give his friends to download the purchases too.) I understand that I cannot use PHP's fopen() functions, because this will end up using both Server A and server B's bandwidth resources! The whole point of me putting the files on a remote server is to reduce bandwidth usage on my main server. Q. 2: If this is not possible, the only other method I can think of is to keep the files on the same server with the payment validation, and put the files in my unreadable folder (outside of the public web root). Then, I would use readfile() to let the people who purchased access those files. Is this a good method? Thank you for helping. (if you need more information, let me know)
  3. My database character set is currently UTF-8. What would happen if I tried to INSERT a non-UTF8 character? Would it save properly? Does UTF-8 cover the characters that could be used in a name from, say, China or Norway? Thanks again.
  4. Thank you. After thinking a little more on the topic, I believe that the reason why I have no problems using POST with Ajax is because I add this line of code: ajax.setRequestHeader("Content-type","application/x-www-form-urlencoded");//to those who want to use this line of code: remember to replace the variable "ajax" with your variable name Which will then send the POST data just like a normal HTML form!
  5. Okay, thank you. So now I have another question: In the "PHP 5 Advanced 2nd edition" book on page 526, Larry says that "using POST in your Ajax won't work properly with the PHP script". 1. What's the actual problem with using POST to send data from Ajax to PHP script? So far my testing has worked - PHP received the POST data. 2. Should I only use GET with Ajax? Thank you! These forums have given me a lot of help.
  6. I have a further question: Would there be a concern if two rows had the same data within the INDEX length? Example: If a table contains the rows: Jake, Janet, Bob, Lowry, Jarry. I set the INDEX limit to 2. Then I queried: SELECT * FROM table WHERE name = 'Jake' Would this be a problem, since other rows also start with 'Ja'? Thanks again!
  7. Using Ajax, I want to use the POST method with https:// example: ajax.open("post","https://example.com/submit.php", true)); ajax.send("name=John"); What I want to know is: will the POST data (in this case, John) be encrypted as it is sent to submit.php? ---------------------------------------------- I would also like to know: should ajax.setRequestHeader("Content-type","application/x-www-form-urlencoded"); be placed between ajax.open() and ajax.send() if I use the POST method? Another site says to use it.
  8. Hello again. I read (pg. 470) that with Mail_Mime (PEAR) I can send mail with PHP via an external SMTP server (such as Google). I want to know: will Mail_Mime send the username and password for the external SMTP server securely (via SSL, etc)? Or would my information be send unencrypted? Thanks again!
  9. I would like to force download a .zip file to a user's computer using PHP. I was planning on using the readfile() function (along with the headers required), but then I stumbled across another method using fopen(), feof(), and fread() that appears to download files also... //necessary headers... if (($f = fopen($fullPath, 'rb')) === false) exit; while (!feof($f)) { echo fread($f, (1*(1024*1024))); flush(); @ob_flush(); } fclose($f); My question: To download a .zip file (that is approximately 85MB) to a user's computer using php, should I use readfile() or fopen()? Can you provide PHP code for me to use with the recommended function? Thank you very much.
  10. I have a question concerning indexing INNER JOIN rows: Example: Table1 has a column "countryKey" (INT), and a column "name" (TEXT). Table2 also has a column "countryKey" (INT), and a column "zipcode" (TEXT). An INNER JOIN query using these tables would look something like this: SELECT Table1.name, Table2.zipcode FROM Table1 INNER JOIN Table2 USING(countryKey). My question: should I index the countryKey column in Table1, Table2, or both?
  11. Thank you very much. I'm finally understanding the point of limiting indexes. For example, a table has a column with the TEXT type (moving away from TINYBLOB for now), and it contains rows: Jake, Janet, Bob, Lowry, Jorge So I should set the index limit to 3, since each row is different after the first 3 characters of each? I'm very grateful for your help!
  12. I want to index the TINYBLOB so that I can use it in a WHERE clause: "SELECT * FROM table WHERE email = AES_ENCRYPT('my@ema.il', 'code')" (email column is the TINYBLOB column) Shouldn't the whole TINYBLOB be indexed, so that the entire email is indexed? Either way, what number do you recommend setting the limit to?
  13. How do I create an index for TINYBLOB? The code: INDEX(tinyblobsection) returns an error saying that a length must be provided... My question is, what number should I set the length to, if I want the entire TINYBLOB column to be indexed? Note: Text inserted into the TINYBLOB column would be encrypted using AES_ENCRYPT, and before encryption the text could not be longer than 150 characters.
  14. Which book would you most recommend for me: 'PHP Advanced: Visual Quickpro Guide' and 'PHP For the Web: Visual Quickstart Guide'? I want to learn as much as I can about PHP, and note that I have already read the book 'PHP and MySQL for Dynamic Websites: Visual Quickpro Guide'. PS: 'PHP and MySQL for Dynamic Websites' is an awesome book; I learned so much!
×
×
  • Create New...