[PHP] Variable Scope problem passing function parameters
I'm new to PHP 5 and classes, but I've done a lot of ActionScript. I'm trying to use PHPMailer inside my own class (a service for AMFPHP). I'm having problems getting the data that'spassed into my class's send() method to the instance of the PHPMailer. Basically, I have this: class EmailAMF { public function send ($from, $to, $subject, $body) { require('class.phpmailer.php'); $phpMail = new PHPMailer(); $phpMail-From = $from; $phpMail-AddAddress($this-to); $phpMail-Subject = $subject; $phpMail-Body = $body; return $phpMail-Send(); } } As far as I can tell, it sends an essentially blank email to nobody (but returns true. If I replace any of my function variables with strings, like this: $phpMail-AddAddress('m...@example.com'); the email actually gets that data. What am I missing? Thanks, Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable Scope problem passing function parameters
metastable wrote: Jim McIntyre wrote: $phpMail = new PHPMailer(); $phpMail-From = $from; $phpMail-AddAddress($this-to); $phpMail-Subject = $subject; $phpMail-Body = $body; return $phpMail-Send(); $this - to it has no meaning in the scope of your class. Apparently, neither do the other variable names. If I replace that with a string containing my email address, it sends an email... but everything else in the email is blank - no body, no subject, etc. How do I reference the arguments passed to the function when setting properties or calling methods of the instance of PHPMailer? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SOLVED Re: [PHP] Variable Scope problem passing function parameters
Jim McIntyre wrote: metastable wrote: Jim McIntyre wrote: $phpMail = new PHPMailer(); $phpMail-From = $from; $phpMail-AddAddress($this-to); $phpMail-Subject = $subject; $phpMail-Body = $body; return $phpMail-Send(); Never mind - I found the problem. It was a lowly typo. Ugh. -Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What font/size do you use for programming?
I'm running a Mac (so I know mine is a bit different size wise) but I'm currently using Veranda at 14 point for coding. Just out of curiosity, what font and size do you ppls use for your programming? I prefer Monaco to Verdana - easier to distinguish 0 and O, etc. The font that came with Eudora, Mishawaka (or something like that) is also good, as is something called ProFont http://www.tobias-jung.de/seekingprofont/. -Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Keeping POST values when paging
At 1:32 PM -0400 7/8/08, tedd wrote: Actually, you don't need to use sessions, post, nor get to pass variables between scripts. Here's an example: http://www.webbytedd.com/bb/tedd/index.php Of course, the smart ones on this list will figure it out pretty quickly. So, this code in the HTML page, at the stage just before the data is sent to the script of my choice, isn't using POST to pass the variable? form method=post action=index.php [snip] input type='hidden' name='var2' value='hereWeGo' [snip] /form -Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random Unique ID
IIRC, the OP wanted to generate a unique key precisely to keep from revealing the record ID to the end user... what about taking the auto_increment value (easy to generate, assured to be unique) adding its MD5 hash to another column in the table, then using that as the published ID? The only disadvantage I see is that the MD5 hash isn't very human-friendly, so using it for an account or member number, or something like that the user might have to write down or read to a customer service rep on the phone, might be difficult. -Jim On Fri, March 23, 2007 9:35 pm, Richard Lynch wrote: Use auto_increment. It's not random, but you should never show it to the end user anyway, so who cares? Another option is to use http://php.net/uniqid and you can create a UNIQUE INDEX on the column and simply check mysql_errno() to see if it's 1023 (or is it 2023?) when you insert to see if you had a collision. On Wed, March 21, 2007 12:18 pm, [EMAIL PROTECTED] wrote: Hello, I want to add a random unique ID to a Mysql table. Collisions are unlikely but possible so to handle those cases I'd like to regenerate the random ID until there is no collision and only then add my row. Any suggestions for a newbie as to the right way to go about doing this? Best, Craig -- - Virtual Phonecards - Instant Pin by Email - - Large Selection - Great Rates- - http://speedypin.com/?aff=743co_branded=1 - -- ** ** * Craig Spencer * * [EMAIL PROTECTED]* ** ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] creating mailto: URL including 8-bit characters
Hi, I'm trying to create a mailto: link in a page that will fill in the Subject and Bopy of a new email message with Spanish-language text. The text lives in strings in an array of localized text. Accented characters in the text are encoded as HTML entities. So, for example, the subject and body text might look like this in the raw data: $subject = 'Articulo acerca de Spyware'; $body = 'Creo que te seraacute; de intereacute;s este artiacute;ulo...'; I can't figure out how to URL encode the characters so they work properly when the email link is created. I tried: $encSubject = rawurlencode(html_entity_decode($subject)); $encBody = rawurlencode(html_entity_decode($body)); echo 'a href=mailto:?subject=' . $encSubject . body= . $encBody . (etc.) but that didn't work. The accented characters show up as empty squares in the email. I also tried adding various charset parameters to html_entity_decode, but that didn't work either: $encSubject = rawurlencode(html_entity_decode($subject), ISO-8859-1); What does appear to work is simply not encoding the text at all, but that leaves a bunch of spaces and ampersand characters in the URL, and that's not supposed to be done. I'd appreciate the list's help figuring out how to do this. Many thanks! -Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Better way to count bits set in an integer?
Hi, Is there a better/more efficient way to determine how many bits are set in an integer than this? substr_count(base_convert($myValue, 10, 2), '1'); I'm using PHP 4. Thanks, Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Looping from A to Z
Good afternoon. I'm having trouble getting PHP to loop from A through Z. Here is what I tried, coming from a C background: for ($l = A; $l = Z; $l++) echo $l; // Returns A, B, C, ..., X, Y, Z, AA, AB, AC, AD, AE, ... YX, YY, YZ. (26 * 26 results!) Interestingly, if I make it a less than operation instead of less than or equal to, it works correctly (except for the Z): for ($l = A; $l Z; $l++) echo $l; // Returns A, B, C, ..., W, X, Y (25 results) Anyone know why PHP would do that? Richard From the PHP docs: PHP follows Perl's convention when dealing with arithmetic operations on character variables and not C's. For example, in Perl 'Z'+1 turns into 'AA', while in C 'Z'+1 turns into '[' ( ord('Z') == 90, ord('[') == 91 ). Note that character variables can be incremented but not decremented. -Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A quick Regex query
At 4:57 PM -0500 2/16/06, phplists wrote: Hi, I am using the following: [0-9]{4} [A-Za-zÅØ]{2,20} to extract data like: 1000 Øslo How can I alter the above to limit to ONLY 4 digits, or in other words exclude: 11000 Beograd Please note that what I am extracting from is NOT at the begining of a line, so I can't use the ^ first. How about: ^[^\d\r]*([0-9]{4} [A-Za-zÅØ]{2,20}) The backreferenced pattern $1 contains the extracted string. Also, you may notice a couple of 'special' characters in my expression 'Å + Ø' By putting them in they seem to work fine, but is this the best way of doing it? I'm sorry, I don't know the answer to that. -Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Workaround ISP's redirect of 404 Not Found PHP pages?
Hi, I searched archived messages for this, but didn't find an answer. If this should go to the installation list, please advise (and forgive!). I'm working on a site hosted at 1and1. I want to use a PHP-enabled custom 404 page, but something in their configuration is preventing it from working. My .htaccess file includes the directive: ErrorDocument 404 /not_found.php It works for everything but .php files. If I try to browse a .php file that doesn't exist, the server returns 1and1's default 404 page, not my custom page. After a few rounds of support requests and misinformation, their tech support folks told me this: PHP is running as a CGI on the shared hosting servers, which is why your .htaccess isn't working for it. You will have to create the error rule within a php.ini file. Firstly, I can't find anything in their configuration that would suggest what they're doing to acccomplish the redirect. For reference, the phpinfo page (sorry, had to sanitize a few things) can be viewed here: http://www2.jdgcommunications.com/phpexample/phpinfo.html And secondly, how could I incorporate an error rule in a local php.ini file? I know how to change settings for error display, reporting and logging, but I haven't been able to find any configuration directives even remotely related to what I'm trying to do. Thanks, Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Workaround ISP's redirect of 404 Not Found PHP pages?
At 3:32 PM + 1/26/06, James Benson wrote: PHP is running as a CGI on the shared hosting servers, which is why your .htaccess isn't working for it. You will have to create the error rule within a php.ini file. That is so much bull, how then can it work for NON .php files? I know for a fact that CGI does not prevent you using .htaccess or the ErrorDocument directive in apache because Im using one myself right now in CGI mode and it works just fine, does your webhost use a custom error page that advertises its own services or provides a link to their website by any chance? Well, laboring under the assumption that everything they tell me is bull, I looked the other way and found a solution. Thanks also to Barry for this: At 3:42 PM +0100 1/26/06, Barry wrote: Best thing is probably to use a rewrite rule. So if the error.html should be desplayed the rewrite rule opens the .php file. In .htaccess, I replaced ErrorDocument 404 /not_found.php with RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) /not_found.php and it seems to be working. Many, many thanks to you both. I should have started here - it would have saved me about two weeks. No lie. Peace, Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php