Re: [PHP] Creating new site
On Thu, 2008-07-31 at 09:57 +, Raido wrote: > I have investigated some frameworks.. Zend and Codeiginiter but I > haven't done any testing/exercises. They seem to make things much more > simple/faster yes...but I'm not sure how much time it will take to get > know one of them(or CakePHP). And I haven't got into reading > licences...I'm sure they have got licences that restricts something(or > not ?) To be honest, I kinda hate all kind of licences. There are many > pages info what I can and what I can't do...but I mostly like to do what > I have and want to do. Also, inventing the wheel once, might give good > experience or am I going slippery way ? I didn't find CodeIgniter difficult to learn - a few hours of reading and a few hours of playing. I was comfortable within one evening. The license for CodeIgniter is pretty simple. Since it's unlikely you'll ever need to mess with the framework itself - you can override any object - I don't see it's modification clause really coming into play. The meat of CodeIgniter's license (from http://codeigniter.com/user_guide/license.html): Permitted Use You are permitted to use, copy, modify, and distribute the Software and its documentation, with or without modification, for any purpose, provided that the following conditions are met: 1. A copy of this license agreement must be included with the distribution. 2. Redistributions of source code must retain the above copyright notice in all source code files. 3. Redistributions in binary form must reproduce the above copyright notice in the documentation and/or other materials provided with the distribution. 4. Any files that have been modified must carry notices stating the nature of the change and the names of those who changed them. 5. Products derived from the Software must include an acknowledgment that they are derived from CodeIgniter in their documentation and/or other materials provided with the distribution. 6. Products derived from the Software may not be called "CodeIgniter", nor may "CodeIgniter" appear in their name, without prior written permission from EllisLab, Inc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Get Remote-Image
Konrad Priemer wrote: Moin, kann mir mal wer auf die Sprünge helfen, ich bekomme es gerade nicht geregelt ein Image "on-the-fly" von einem Remote-Host per fsockopen auf meinen Server zu ziehen. Irgendwo hab ich da voll die Blockade ;) Mein "nichtfunktionierender" Versuch: ... Gutentag, Enschuldigung fur meine Deutsche schreibe. Aber Ich habe jetzt menige Jahren kein Deutsch geschrieben. ... $out = "GET ".." HTTP/1.0\r\nHost: ".$this->host."\r\nUser-Agent: GetWiki for WordPress\r\n\r\n"; $fp = fsockopen($this->host, $this->port, $errno, $errstr, 30); $File = fopen(,"wb"); fwrite( $File, $out ); Was Sie hier macht is nicht richtig. Sie schreiben $out nach $File, weil $out mußt zum $fp geschrieben werden. $fp Ist die Remote Host, und $out ist die Request. Die ervolg ist das $fp gibt Sie ein Response, und konnen mit fgets() oder fread() ausgelesen worden. Wieso, $tmp = fgets($fp); Und weiter Sie konnen $tmp ins $File schreiben. fclose($File); fclose($fp); Vielleicht ist es nicht gar richtig, aber Sie konnen das doch testen. Viel Spaß mit coding. Grüße Aschwin Wesselius -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Get Remote-Image
> Gutentag, I'm staring at the screen thinking "Huh...?". -- Richard Heyes http://www.phpguru.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP email
Hi, Can someone tell me what the address is to change my @php.net redirect? Thanks. -- Richard Heyes http://www.phpguru.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Back to Basics - Why Use Single Quotes?
Thanks for the nice explanation, Dan! On 7/30/08, Daniel Brown <[EMAIL PROTECTED]> wrote: > > On Wed, Jul 30, 2008 at 6:51 PM, Stephen <[EMAIL PROTECTED]> wrote: > > I have traditionally used double quotes going back to my PASCAL days. > > > > I see many PHP examples using single quotes, and I began to adopt that > > convention. > > > > Even updating existing code. > > > > And I broke some stuff that was doing variable expansion. So I am back to > > using double quotes. > > > > But I wonder, is there any reason to use single quotes? > >Single quotes means literal, whereas double quotes means translated. > >For example: > > > // This returns exactly the same data: > $foo_a = "bar"; > $foo_b = 'bar'; > > echo $foo_a; // bar > echo $foo_b; // bar > > > // This returns different data: > $foo = "bar"; // Single quotes can be used here just the same. > > echo "The answer is $foo"; // The answer is bar > echo 'The answer is $foo'; // The answer is $foo > > > /* And if you want to use special >characters like newlines, you >MUST use double quotes. */ > > echo "This echoes a newline.\n"; // This echoes a newline. [newline] > echo 'This echoes a literal \n'; // This echoes a literal \n > > ?> > >Basically, double quotes evaluate certain things and return the > evaluation, while single quotes return EXACTLY what's typed between > them. > > -- > > Better prices on dedicated servers: > Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. > Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. > Dedicated servers, VPS, and hosting from $2.50/mo. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Back to Basics - Why Use Single Quotes?
Single quotes do still recognise \' and \\ though, for getting a single quote and backslash. IIRC (which isn't likely) they're the only two. -- Richard Heyes http://www.phpguru.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using $_GET for POST
> > if ( ! (isset($_GET['x']) && $_GET['x'] == 20) ) > { > // Do something by returning an error > } > > Can this ever be correct when the form looks like: > > > > > > ? I sometimes do things similar to this. I normally use it when I am opening a new page via a javascript function and want to pass several values to use or check in the new page.
Re: [PHP] Back to Basics - Why Use Single Quotes?
On Wed, Jul 30, 2008 at 6:51 PM, Stephen <[EMAIL PROTECTED]> wrote: > I have traditionally used double quotes going back to my PASCAL days. > > I see many PHP examples using single quotes, and I began to adopt that > convention. > > Even updating existing code. > > And I broke some stuff that was doing variable expansion. So I am back to > using double quotes. > > But I wonder, is there any reason to use single quotes? > > Stephen Because sometimes it is nice to do this: $onclick = ' onclick="..."' Not having to escape my single tick makes it more readable. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Back to Basics - Why Use Single Quotes?
On Wed, Jul 30, 2008 at 7:03 PM, mike <[EMAIL PROTECTED]> wrote: > On 7/30/08, Stephen <[EMAIL PROTECTED]> wrote: > >> But I wonder, is there any reason to use single quotes? > > extremely minor performance gains, afaik. > > probably moreso when doing $foo["bar"] and $foo['bar'] > > but i believe it's negligible $foo = 'bar' and $foo = "bar" > > sara golemon did some performance tests with actual opcode results here: > http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > I read one of Ilia's presentation slides saying this was a myth. Strings probably aren't the bottleneck. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] upload file problem
I'm trying to upload the file. It's showing me successfully uploaded. But it's not able to move from temp directory to my defined directory my code: if (is_uploaded_file($_FILES['myfile']['tmp_name'])) { move_uploaded_file($_FILES['myfile']['tmp_name'], $myfilename); echo "File ". $_FILES['myfile']['name'] ." uploaded successfully.\n"; } else { echo "File uploading error"; } Thanks in advance. -Jignesh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] upload file problem
On Thu, Jul 31, 2008 at 10:18 AM, Jignesh Thummar <[EMAIL PROTECTED]> wrote: > I'm trying to upload the file. It's showing me successfully uploaded. > But it's not able to move from temp directory to my defined directory > > my code: > > if (is_uploaded_file($_FILES['myfile']['tmp_name'])) { > move_uploaded_file($_FILES['myfile']['tmp_name'], $myfilename); > echo "File ". $_FILES['myfile']['name'] ." uploaded successfully.\n"; > } else { > echo "File uploading error"; > } > > Thanks in advance. > > -Jignesh Is the directory you're moving to writable by your web server? If you don't know, try making a separate script that tries var_dump(is_writable('/path/to/uploads')); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] upload file problem
it's writable. On Thu, Jul 31, 2008 at 3:37 PM, Eric Butera <[EMAIL PROTECTED]> wrote: > On Thu, Jul 31, 2008 at 10:18 AM, Jignesh Thummar > <[EMAIL PROTECTED]> wrote: >> I'm trying to upload the file. It's showing me successfully uploaded. >> But it's not able to move from temp directory to my defined directory >> >> my code: >> >> if (is_uploaded_file($_FILES['myfile']['tmp_name'])) { >> move_uploaded_file($_FILES['myfile']['tmp_name'], $myfilename); >> echo "File ". $_FILES['myfile']['name'] ." uploaded successfully.\n"; >> } else { >> echo "File uploading error"; >> } >> >> Thanks in advance. >> >> -Jignesh > > Is the directory you're moving to writable by your web server? If you > don't know, try making a separate script that tries > var_dump(is_writable('/path/to/uploads')); > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating new site
Cake is licensed under the MIT license which is about as permissible as you can get. -Shawn Raido wrote: I have investigated some frameworks.. Zend and Codeiginiter but I haven't done any testing/exercises. They seem to make things much more simple/faster yes...but I'm not sure how much time it will take to get know one of them(or CakePHP). And I haven't got into reading licences...I'm sure they have got licences that restricts something(or not ?) To be honest, I kinda hate all kind of licences. There are many pages info what I can and what I can't do...but I mostly like to do what I have and want to do. Also, inventing the wheel once, might give good experience or am I going slippery way ? Shawn McKenzie wrote: Micah Gersten wrote: Depending on the size of the site, you might want to consider a PHP framework to start with. There's usually no point in reinventing the wheel. Someone mentioned CakePHP which utilizes MVC. I'm looking into porting my stuff to the Zend Framework which makes MVC optional, but has a lot of functionality make available. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com I too like CakePHP. I have coded in PHP for quite a while and understand OOP and OOP in PHP, however I don't really have any experience building sites or apps from scratch using OOP/MVC. Cake or a framework makes it much quicker and easier. For those that need total freedom to do things the way they want but need some pre-built functionality to make it quicker, Zend seems to be the choice. I consider Zend to be more of a class library like PEAR only more consistant. For me, I had no habits/best practices or preferred way when I started with OOP/MVC so Cake was great. It has a certain structure and uses certain conventions and code generation which makes it very quick and easy. The main drawback is the docs. -Shawn Raido wrote: Hi, There are many sites explaining how to build new site etc but I'd like to hear what You suggest. (about how to plan whole thing and how to write separate parts which can be put together later) I have build many small sites for myself(site to organise class assembly which is like yearly convention..it has user administration etc) but they all are anything else than OOP. But now, I need to help with creating one bigger site which should be OOP. That site should include user management(each user has it's own profile), each user can post job and other adds in different categories. (there will be many categories for example 'work,cars,training,apartments'.) And users profile should show ads posted by himself. Logic itself is simple: 1) unregistered user: a) I go to site, I see categories (work offers, apartment offers, training offers, etc) b) I click on category I'm interested in c) I see ad that I'm interested in d) I click on it c) I see detailed information about it(which company posted it etc) d) at bottom page I see form where I can contact with ad author 2) registered user a) I go to site b) I log in, my profile page opens c) there I can see ads posted by me..also I can see how many times ad is viewed etc d) i click on link 'Post new ad' e) there i choose category and probably Ajax helps to load specific fields(for example if I choose 'Cars' as category, then fields like 'year,transmission,color, etc' will appear. That is short summary what that site should do. It seems quite big for me so I'd be happy to hear any guidelines from people who have built big sites. Creating forms, posting data, user login etc, these things are not problem... problem is: how to build the whole thing aimed to OOP and use with Smarty to keep things organized. I'm not sure but I have idea about what things I should do first: 1) think and write down any function that needs to be done(for example different validations, functions for showing/posting form etc) 2) plan and create database? 3) create database class which handles database connection But what next? Or am I starting all wrong? Big thanks in advance, Raido -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] accessing variables within objects
On Jul 30, 2008, at 1:29 PM, Jim Lucas wrote: Marten Lehmann wrote: Hello, I'm using some php-classes which worked fine with php-5.0.4. Now I tried to upgrade to php-5.2.6, but the classes give a lot of errors. If I set error_reporting(E_ALL); I see messages like Notice: Undefined property: FastTemplate::$main in /whereever/ inc.template.php on line 293 Notice: Undefined property: current_session::$cust_id in /whereever/ inc.init.php on line 117 In inc.template.php there are a lot of calls like $this->$key. In inc.init.php there are calls like $session->cust_id. to fix these errors, you would need to modify the code so it does something like this. where it calls $this->$key you need to check and make sure that $key exists before you trying call for it. So something like this would work. if ( isset( $this->$key ) ) { $this->$key; } else { $this->$key = null; } You didn't show any context in which you are using the above code. So I don't know what will actually work in your situation. Show a little more code that includes the method in which $this->$key is called. You will want to look at using the Overloading feature of PHP5. Check out this page for overloading examples http://us2.php.net/manual/en/language.oop5.overloading.php Take note of the __get() and __set() methods. The __get method checks to see if the key exists before it tries working with it. Ok, I'm trying to understand the point to using these overloading methods. hi = 'Hi'; $obj->bye = 'Bye'; echo $obj->hi, ' ', $obj->bye; // Output: Hi Bye ?> You could have done that or you could do the following. setHi('Hello'); $obj->setBye('Bye Bye!'); echo $obj->hi(), ' ', $obj->bye(); // Output: Hello Bye Bye! ?> The 2nd way seems more *OOP* than the first - weird to explain. I guess what I'm wanting to know is why would you use overloading (in PHP)? The only reason I can think of is to avoid having to create/ use accessors. Please help me understand! But please be nice! =D Thanks, ~Philip What has changed in php-5.2.x so that these calls don't work any more? What is the new, required form to use objects in a similar manner (unfortunately I have no ressources to code these classes from scratch)? Thanks. Kind regards Marten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Get Remote-Image
Richard Heyes wrote: Gutentag, I'm staring at the screen thinking "Huh...?". He didn't even apologize for his English! -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Get Remote-Image
Daniel Brown wrote: On Wed, Jul 30, 2008 at 9:50 PM, Konrad Priemer <[EMAIL PROTECTED]> wrote: kann mir mal wer auf die Sprünge helfen, ich bekomme es gerade nicht geregelt ein Image "on-the-fly" von einem Remote-Host per fsockopen auf meinen Server zu ziehen. Irgendwo hab ich da voll die Blockade ;) Die copy() Funktion kann mit URL arbeiten. http://php.net/copy No, http://us2.php.net/manual/de/function.copy.php -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating new site
> Cake is licensed under the MIT license which is about as permissible as you > can get. Any Open Source code is permissable as long you don't tell anyone... :-) -- Richard Heyes http://www.phpguru.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] strange string evaluation
Hello, with PHP 5.0.x this two lines of code returned "{TEST}": $var = "TEST"; print "\{$var}"; But with PHP 5.2.x, the same code returns "\{TEST}" If I remove the backslash: $var = "TEST"; print "{$var}"; then just "TEST" is return (without any brackets). What is the recommended way for PHP 5.2.x to work with that? It looks a bid odd if I have to write print "{". $var. "}"; instead. Regards Marten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strange string evaluation
On Thu, 2008-07-31 at 17:54 +0200, Marten Lehmann wrote: > Hello, > > with PHP 5.0.x this two lines of code returned "{TEST}": > > $var = "TEST"; > print "\{$var}"; > > But with PHP 5.2.x, the same code returns "\{TEST}" > > If I remove the backslash: > > $var = "TEST"; > print "{$var}"; > > then just "TEST" is return (without any brackets). > > What is the recommended way for PHP 5.2.x to work with that? It looks a > bid odd if I have to write > > print "{". $var. "}"; Yeah, that is weird. I'd write: echo '{'.$var.'}'; Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Get Remote-Image
On Thu, Jul 31, 2008 at 11:14 AM, Shawn McKenzie <[EMAIL PROTECTED]> wrote: > > No, > > http://us2.php.net/manual/de/function.copy.php What do you mean, "no," McKenzie? ;-P If you use the short method, it redirects properly. Putting him through us2 and specifying translation is going to be a lot slower. -- Better prices on dedicated servers: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php CLI Parser not working
Did you check what Jim suggested, as well, about short_open_tags? If your scripts use PHP tags like this: Yes, that was the problem - it was Off in: /etc/php5/cli/php.ini we had checked the one in: ./etc/php5/apache2/php.ini and it was On there so we thought something else was wrong. Thanks to you both for your help. - Joel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dynamic Select Lists - 1st Selection Effects 2nd!
Ave, What I have is two Select (Drop-Down) lists (State & County) and I'm populating them from a mySQL table. What I want is when the user selects the State from the State List, the County List should only pull out counties associated with that State. Now I know that you can create such an effect using Javascript or AJAX and have nothing to do with PHP/mySQL - and I was able to accomplish that - but only for lists where you could define data manually. I'm not able to accomplish this at all with Lists that are pulling out option data from a mySQL table. I'm also giving the User the opportunity to add as many State/County combinations as possible in a box. 'tis my code: State: $row_D_STATE['STATE']?> 0) { mysql_data_seek($D_STATE, 0); $row_D_STATE = mysql_fetch_assoc($D_STATE); } ?> County: All $row_D_COUNTY['COUNTY']?> 0) { mysql_data_seek($D_COUNTY, 0); $row_D_COUNTY = mysql_fetch_assoc($D_COUNTY); } ?> onClick="document.AD_INVENTORY_FORM.d_state_county.value +=document.AD_INVENTORY_FORM.d_state.value +'/'+document.AD_INVENTORY_FORM.d_county.value+'\n';"> COLS="26" ROWS="3"> I'm not able to understand exactly how to manipulate the SQL Query or otherwise force the 2nd Select List to only show records that match the selected State. Any pointers? --- Rahul Sitaram Johari Founder, Internet Architects Group, Inc. [Email] [EMAIL PROTECTED] [Web] http://www.rahulsjohari.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] upload file problem
Maybe check the return value of the function: http://us3.php.net/manual/en/function.move-uploaded-file.php Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Jignesh Thummar wrote: > I'm trying to upload the file. It's showing me successfully uploaded. > But it's not able to move from temp directory to my defined directory > > my code: > > if (is_uploaded_file($_FILES['myfile']['tmp_name'])) { >move_uploaded_file($_FILES['myfile']['tmp_name'], $myfilename); >echo "File ". $_FILES['myfile']['name'] ." uploaded successfully.\n"; > } else { > echo "File uploading error"; > } > > Thanks in advance. > > -Jignesh > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] accessing variables within objects
Here's the PHP doc page. Let us know if you have more questions: http://us3.php.net/manual/en/language.oop5.overloading.php Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Philip Thompson wrote: > On Jul 30, 2008, at 1:29 PM, Jim Lucas wrote: > >> Marten Lehmann wrote: >>> Hello, >>> I'm using some php-classes which worked fine with php-5.0.4. Now I >>> tried to upgrade to php-5.2.6, but the classes give a lot of errors. >>> If I set >>> error_reporting(E_ALL); >>> I see messages like >>> Notice: Undefined property: FastTemplate::$main in >>> /whereever/inc.template.php on line 293 >>> Notice: Undefined property: current_session::$cust_id in >>> /whereever/inc.init.php on line 117 >>> In inc.template.php there are a lot of calls like $this->$key. In >>> inc.init.php there are calls like $session->cust_id. >> >> to fix these errors, you would need to modify the code so it does >> something like this. >> >> where it calls $this->$key you need to check and make sure that $key >> exists before you trying call for it. >> >> So something like this would work. >> >> if ( isset( $this->$key ) ) { >> $this->$key; >> } else { >> $this->$key = null; >> } >> >> You didn't show any context in which you are using the above code. So >> I don't know what will actually work in your situation. Show a >> little more code that includes the method in which $this->$key is >> called. >> >> You will want to look at using the Overloading feature of PHP5. >> Check out this page for overloading examples >> >> http://us2.php.net/manual/en/language.oop5.overloading.php >> >> Take note of the __get() and __set() methods. The __get method >> checks to see if the key exists before it tries working with it. > > Ok, I'm trying to understand the point to using these overloading > methods. > > $obj = new ClassThatUsesOverloading (); > $obj->hi = 'Hi'; > $obj->bye = 'Bye'; > > echo $obj->hi, ' ', $obj->bye; > // Output: Hi Bye > ?> > > You could have done that or you could do the following. > > $obj = new ClassThatDoesntUseOverloading (); > $obj->setHi('Hello'); > $obj->setBye('Bye Bye!'); > > echo $obj->hi(), ' ', $obj->bye(); > // Output: Hello Bye Bye! > ?> > > The 2nd way seems more *OOP* than the first - weird to explain. I > guess what I'm wanting to know is why would you use overloading > (in PHP)? The only reason I can think of is to avoid having to > create/use accessors. Please help me understand! But please be nice! =D > > Thanks, > ~Philip > > >>> What has changed in php-5.2.x so that these calls don't work any >>> more? What is the new, required form to use objects in a similar >>> manner (unfortunately I have no ressources to code these classes >>> from scratch)? Thanks. >>> Kind regards >>> Marten > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] upload file problem
On Thu, Jul 31, 2008 at 10:18 AM, Jignesh Thummar <[EMAIL PROTECTED]> wrote: > I'm trying to upload the file. It's showing me successfully uploaded. > But it's not able to move from temp directory to my defined directory > > my code: > > if (is_uploaded_file($_FILES['myfile']['tmp_name'])) { > move_uploaded_file($_FILES['myfile']['tmp_name'], $myfilename); > echo "File ". $_FILES['myfile']['name'] ." uploaded successfully.\n"; > } else { > echo "File uploading error"; > } If it is passing the if(is_uploaded_file()) condition, echo out $myfilename and make sure it's valid to use as a path/filename. -- Better prices on dedicated servers: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd!
> -Original Message- > From: Rahul S. Johari [mailto:[EMAIL PROTECTED] > Sent: Thursday, July 31, 2008 11:40 AM > To: php-general@lists.php.net > Subject: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd! > > Ave, > > What I have is two Select (Drop-Down) lists (State & County) and I'm > populating them from a mySQL table. What I want is when the user > selects the State from the State List, the County List should only > pull out counties associated with that State. > > Now I know that you can create such an effect using Javascript or AJAX > and have nothing to do with PHP/mySQL - and I was able to accomplish > that - but only for lists where you could define data manually. I'm > not able to accomplish this at all with Lists that are pulling out > option data from a mySQL table. > > I'm also giving the User the opportunity to add as many State/County > combinations as possible in a box. > 'tis my code: > > > > State: > > > $row_D_STATE['STATE']?> >} while ($row_D_STATE = > mysql_fetch_assoc($D_STATE)); > $rows = mysql_num_rows($D_STATE); > if($rows > 0) { > mysql_data_seek($D_STATE, 0); > $row_D_STATE = > mysql_fetch_assoc($D_STATE); > } > ?> > > > > > County: > > > All > > $row_D_COUNTY['COUNTY']?> >} while ($row_D_COUNTY = > mysql_fetch_assoc($D_COUNTY)); > $rows = mysql_num_rows($D_COUNTY); > if($rows > 0) { > mysql_data_seek($D_COUNTY, 0); > $row_D_COUNTY = > mysql_fetch_assoc($D_COUNTY); > } > ?> > VALUE="[+] Add" > onClick="document.AD_INVENTORY_FORM.d_state_county.value > +=document.AD_INVENTORY_FORM.d_state.value > +'/'+document.AD_INVENTORY_FORM.d_county.value+'\n';"> > > > >NAME="d_state_county" > COLS="26" ROWS="3"> > > > > I'm not able to understand exactly how to manipulate the SQL Query or > otherwise force the 2nd Select List to only show records that match > the selected State. > > Any pointers? The page referenced by an AJAX XmlHttpRequest() doesn't have to be static. You can even use the query string to supply the AJAX call with parameters (or perhaps post a form instead). This way, you can pass the chosen state to the AJAX-requested page and use PHP on the other end to construct the appropriate counties selection list. AJAX could then push this result into a DIV that had, up until now, contained an empty selection list with no available options. Summary: Page has two DIVs: one for state list, one for county list (which is empty). User clicks first DIV's selection box, onChange JS method fires AJAX call to getCounties.php?state=XX (where XX is the chosen state). PHP on the other end builds a selection list for the given state and returns it to the AJAX call. The AJAX result is then assigned to the second div, which now contains the list of counties for the given state. HTH, Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] accessing variables within objects
On Jul 31, 2008, at 11:48 AM, Micah Gersten wrote: Here's the PHP doc page. Let us know if you have more questions: http://us3.php.net/manual/en/language.oop5.overloading.php Yeah, I got the link the first time and read the page. But I was looking for a little bit more explanation... Thanks anyway, ~Philip Philip Thompson wrote: On Jul 30, 2008, at 1:29 PM, Jim Lucas wrote: Marten Lehmann wrote: Hello, I'm using some php-classes which worked fine with php-5.0.4. Now I tried to upgrade to php-5.2.6, but the classes give a lot of errors. If I set error_reporting(E_ALL); I see messages like Notice: Undefined property: FastTemplate::$main in /whereever/inc.template.php on line 293 Notice: Undefined property: current_session::$cust_id in /whereever/inc.init.php on line 117 In inc.template.php there are a lot of calls like $this->$key. In inc.init.php there are calls like $session->cust_id. to fix these errors, you would need to modify the code so it does something like this. where it calls $this->$key you need to check and make sure that $key exists before you trying call for it. So something like this would work. if ( isset( $this->$key ) ) { $this->$key; } else { $this->$key = null; } You didn't show any context in which you are using the above code. So I don't know what will actually work in your situation. Show a little more code that includes the method in which $this->$key is called. You will want to look at using the Overloading feature of PHP5. Check out this page for overloading examples http://us2.php.net/manual/en/language.oop5.overloading.php Take note of the __get() and __set() methods. The __get method checks to see if the key exists before it tries working with it. Ok, I'm trying to understand the point to using these overloading methods. hi = 'Hi'; $obj->bye = 'Bye'; echo $obj->hi, ' ', $obj->bye; // Output: Hi Bye ?> You could have done that or you could do the following. setHi('Hello'); $obj->setBye('Bye Bye!'); echo $obj->hi(), ' ', $obj->bye(); // Output: Hello Bye Bye! ?> The 2nd way seems more *OOP* than the first - weird to explain. I guess what I'm wanting to know is why would you use overloading (in PHP)? The only reason I can think of is to avoid having to create/use accessors. Please help me understand! But please be nice! =D Thanks, ~Philip What has changed in php-5.2.x so that these calls don't work any more? What is the new, required form to use objects in a similar manner (unfortunately I have no ressources to code these classes from scratch)? Thanks. Kind regards Marten "Personally, most of my web applications do not have to factor 13.7 billion years of space drift in to the calculations, so PHP's rand function has been great for me..." ~S. Johnson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] upload file problem
Jignesh Thummar wrote: I'm trying to upload the file. It's showing me successfully uploaded. But it's not able to move from temp directory to my defined directory my code: if (is_uploaded_file($_FILES['myfile']['tmp_name'])) { move_uploaded_file($_FILES['myfile']['tmp_name'], $myfilename); echo "File ". $_FILES['myfile']['name'] ." uploaded successfully.\n"; } else { echo "File uploading error"; } What does $myfilename resolve to? It should include the complete path from server root (not DOCUMENT_ROOT). Try: echo "File uploading error: ${myfilename}"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Get Remote-Image
Daniel Brown wrote: On Thu, Jul 31, 2008 at 11:14 AM, Shawn McKenzie <[EMAIL PROTECTED]> wrote: No, http://us2.php.net/manual/de/function.copy.php What do you mean, "no," McKenzie? ;-P If you use the short method, it redirects properly. Putting him through us2 and specifying translation is going to be a lot slower. Sorry Brown... maybe http://php.net/de/copy Since there weren't any English words in his post I figured going directly to the Deutsch translation was best -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd!
On Jul 31, 2008, at 12:55 PM, Boyd, Todd M. wrote: -Original Message- From: Rahul S. Johari [mailto:[EMAIL PROTECTED] Sent: Thursday, July 31, 2008 11:40 AM To: php-general@lists.php.net Subject: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd! Ave, What I have is two Select (Drop-Down) lists (State & County) and I'm populating them from a mySQL table. What I want is when the user selects the State from the State List, the County List should only pull out counties associated with that State. Now I know that you can create such an effect using Javascript or AJAX and have nothing to do with PHP/mySQL - and I was able to accomplish that - but only for lists where you could define data manually. I'm not able to accomplish this at all with Lists that are pulling out option data from a mySQL table. I'm also giving the User the opportunity to add as many State/County combinations as possible in a box. 'tis my code: State: NAME="d_state"> mysql_num_rows($D_STATE); if($rows > 0) { mysql_data_seek($D_STATE, 0); $row_D_STATE = mysql_fetch_assoc($D_STATE); } ?> County: SELECTED>All mysql_num_rows($D_COUNTY); if($rows > 0) { mysql_data_seek($D_COUNTY, 0); $row_D_COUNTY = mysql_fetch_assoc($D_COUNTY); } ?> TYPE="button" VALUE="[+] Add" onClick="document.AD_INVENTORY_FORM.d_state_county.value +=document.AD_INVENTORY_FORM.d_state.value +'/'+document.AD_INVENTORY_FORM.d_county.value+'\n';"> COLSPAN="2"> NAME="d_state_county" COLS="26" ROWS="3"> I'm not able to understand exactly how to manipulate the SQL Query or otherwise force the 2nd Select List to only show records that match the selected State. Any pointers? The page referenced by an AJAX XmlHttpRequest() doesn't have to be static. You can even use the query string to supply the AJAX call with parameters (or perhaps post a form instead). This way, you can pass the chosen state to the AJAX-requested page and use PHP on the other end to construct the appropriate counties selection list. AJAX could then push this result into a DIV that had, up until now, contained an empty selection list with no available options. Summary: Page has two DIVs: one for state list, one for county list (which is empty). User clicks first DIV's selection box, onChange JS method fires AJAX call to getCounties.php?state=XX (where XX is the chosen state). PHP on the other end builds a selection list for the given state and returns it to the AJAX call. The AJAX result is then assigned to the second div, which now contains the list of counties for the given state. HTH, Todd Boyd Web Programmer In theory your solution sounds extremely feasible & perhaps the appropriate procedure. My problem is that I'm not an expert at all in AJAX (Or javascript for that matter). The manually-fed examples I worked with were freely available sources for such a functional Select List, and I tried manipulating them to fit in my php/mySQL code but to no avail. I'll try & work this out, but I doubt I'll be able to. Thanks. --- Rahul Sitaram Johari Founder, Internet Architects Group, Inc. [Email] [EMAIL PROTECTED] [Web] http://www.rahulsjohari.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] limiting the amount of emails sent at a time in a batch send
Richard Kurth wrote: I want to limit these script two send 100 email and then pause for a few seconds and then send another 100 emails and repeat this tell it has sent all the emails that are dated for today. This script is runs by cron so it is running in the background. How would I do this and is it the best way to do it. I am using swift mailer to send the mail. I think I would use limit 100 in the query but how would I tell it to get the next 100. There's no need to limit the DB query, nor to track what's been sent by updating the DB. Grab all of the addresses at once and let SwiftMailer deal with the throttling: require('Swift/lib/Swift.php'); require('Swift/lib/Swift/Connection/SMTP.php'); /* this handles the throttling */ require('Swift/lib/Swift/Plugin/AntiFlood.php'); /* this holds all of your addresses */ $recipients = new Swift_RecipientList(); /* Grab the addresses from the DB (this is using MDB2) */ $result = ... while ($row = $result->fetchRow()) { $recipients->addTo($row['address'], $row['name']); } @$result->free(); try { $swift = new Swift(new Swift_Connection_SMTP('localhost'), 'your_domain'); set_time_limit(0); $swift->log->enable(); /* 100 mails per batch with a 60 second pause between batches */ $swift->attachPlugin(new Swift_Plugin_AntiFlood(100, 60), 'anti-flood'); flush(); $message = new Swift_Message('your subject'); $message->setCharset('utf-8'); $message->setReplyTo(...); $message->setReturnPath(...); $message->headers->set('Errors-To', ...); $message->attach(new Swift_Message_Part($plain_content)); $message->attach(new Swift_Message_Part($html_content, 'text/html')); $num_sent = $swift->batchSend($message, $recipients, new Swift_Address(..., '...')); $swift->disconnect(); ... This is a rough example taken from my own script. This would need to be modified if you're not sending the same message to all recipients, of course. It's not clear to me from your example. b -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Get Remote-Image
On Thu, Jul 31, 2008 at 1:21 PM, Shawn McKenzie <[EMAIL PROTECTED]> wrote: > > Sorry Brown... maybe http://php.net/de/copy > > Since there weren't any English words in his post I figured going directly > to the Deutsch translation was best Yeah, I understand but what I mean is that, the language in which you usually browse php.net will be the default language when you use the short URL. For example, go to http://php.net/copy and change the language to German (or any other language) and then close the window. Then go to http://php.net/eregi. Unless you specifically define which language to use, the site will use either a past preference or the language sent in the headers by the browser. Either way, though, it was thoughtful of you to point out the translated page. I told Richard Heyes he was wrong about you. ;-P -- Better prices on dedicated servers: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strange string evaluation
Marten Lehmann wrote: Hello, with PHP 5.0.x this two lines of code returned "{TEST}": $var = "TEST"; print "\{$var}"; But with PHP 5.2.x, the same code returns "\{TEST}" If I remove the backslash: $var = "TEST"; print "{$var}"; then just "TEST" is return (without any brackets). What is the recommended way for PHP 5.2.x to work with that? It looks a bid odd if I have to write print "{". $var. "}"; instead. $var = 'TEST'; print "{{$var}}"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP email
On Thu, Jul 31, 2008 at 7:46 AM, Richard Heyes <[EMAIL PROTECTED]> wrote: > Hi, > > Can someone tell me what the address is to change my @php.net redirect? > Thanks. It's on the Master system. I'll send you the direct link to edit your profile in a Google chat. -- Better prices on dedicated servers: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Windows date("Y/m/d H:i:s") performance
PHP 5.2.6 with Xdebug 2.0.3 here... Aha! Turning off Xdebug "fixes" it... Weird. Or maybe "normal" for Xdebug? I'll take this up with Derick and co on Xdebug list next, if anybody wants to follow... On Wed, July 30, 2008 11:36 am, Andrew Ballard wrote: > On Wed, Jul 30, 2008 at 12:19 PM, Richard Lynch <[EMAIL PROTECTED]> wrote: >> I suppose to be complete, I should point out that in Linux a call to >> date finishes in 1.2271404266357E-5 seconds on average. >> >> For those unfamiliar with scientific notation, that would be: >> 0.12271404266357 seconds, or rougly 1/10,000th of the time Doze >> takes. >> > > Interesting. Just for comparison, I ran it directly with the binaries > (disabling the debugger) for PHP 4.4.4 and 5.2.0 on my machine. > > 4.4.4 - in the order of 4.5E-6 - 5.0E-6 > > 5.2.0 - right around 1.0E-4 > > Andrew > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Some people ask for gifts here. I just want you to buy an Indie CD for yourself: http://cdbaby.com/search/from/lynch -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd!
> -Original Message- > From: Rahul S. Johari [mailto:[EMAIL PROTECTED] > Sent: Thursday, July 31, 2008 12:27 PM > To: Boyd, Todd M. > Cc: php-general@lists.php.net > Subject: Re: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd! > > > On Jul 31, 2008, at 12:55 PM, Boyd, Todd M. wrote: > > >> -Original Message- > >> From: Rahul S. Johari [mailto:[EMAIL PROTECTED] > >> Sent: Thursday, July 31, 2008 11:40 AM > >> To: php-general@lists.php.net > >> Subject: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd! > >> > >> Ave, > >> > >> What I have is two Select (Drop-Down) lists (State & County) and I'm > >> populating them from a mySQL table. What I want is when the user > >> selects the State from the State List, the County List should only > >> pull out counties associated with that State. > >> > >> Now I know that you can create such an effect using Javascript or > >> AJAX > >> and have nothing to do with PHP/mySQL - and I was able to accomplish > >> that - but only for lists where you could define data manually. I'm > >> not able to accomplish this at all with Lists that are pulling out > >> option data from a mySQL table. > >> > >> I'm also giving the User the opportunity to add as many State/County > >> combinations as possible in a box. ---8<--- snip > >> I'm not able to understand exactly how to manipulate the SQL Query > or > >> otherwise force the 2nd Select List to only show records that match > >> the selected State. > >> > >> Any pointers? > > > > The page referenced by an AJAX XmlHttpRequest() doesn't have to be > > static. You can even use the query string to supply the AJAX call > with > > parameters (or perhaps post a form instead). This way, you can pass > > the > > chosen state to the AJAX-requested page and use PHP on the other end > > to > > construct the appropriate counties selection list. AJAX could then > > push > > this result into a DIV that had, up until now, contained an empty > > selection list with no available options. > > > > Summary: Page has two DIVs: one for state list, one for county list > > (which is empty). User clicks first DIV's selection box, onChange JS > > method fires AJAX call to getCounties.php?state=XX (where XX is the > > chosen state). PHP on the other end builds a selection list for the > > given state and returns it to the AJAX call. The AJAX result is then > > assigned to the second div, which now contains the list of counties > > for > > the given state. > > > In theory your solution sounds extremely feasible & perhaps the > appropriate procedure. My problem is that I'm not an expert at all in > AJAX (Or javascript for that matter). The manually-fed examples I > worked with were freely available sources for such a functional Select > List, and I tried manipulating them to fit in my php/mySQL code but to > no avail. > > I'll try & work this out, but I doubt I'll be able to. > > Thanks. Rahul, Aww, come now... don't be so negative! :) Most widely-adopted programming practices are widely-adopted for a reason: they are not inherently difficult to use. This does, of course, get obfuscated by various extensions and poor programming techniques end-users employ, but I digress. http://www.w3schools.com/ajax/ should get you started, but here's a simple implementation: selection.html: --- Alabama Alaska function ajaxCounties() { var xmlHttp; var stateList = document.getElementById("stateList"); try { // Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { // Older IE try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { // AJAX unsupported alert("Your browser does not support AJAX!"); return false; } } } // ajax actions xmlHttp.onReadyStateChange = function() { // data returned from server if(xmlHttp.readyState == 4) { // fill div with server-generated
Re: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd!
On Thu, Jul 31, 2008 at 12:40 PM, Rahul S. Johari <[EMAIL PROTECTED]> wrote: > Ave, > > What I have is two Select (Drop-Down) lists (State & County) and I'm > populating them from a mySQL table. What I want is when the user selects the > State from the State List, the County List should only pull out counties > associated with that State. [snip] This is a usability issue rather than a code issue, but wouldn't you want that to be the other way around? (ie, select the country from a list and it populates the state list with states/provinces/territories/adminstrative disticts/etc. that belong to that country?) I know the order is "backward" from how one typically writes an address on paper, but otherwise your state list will be HUGE and often your country list would only have one value after the user selects a state. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd!
On Thu, Jul 31, 2008 at 2:31 PM, Boyd, Todd M. <[EMAIL PROTECTED]> wrote: >> -Original Message- >> From: Rahul S. Johari [mailto:[EMAIL PROTECTED] >> Sent: Thursday, July 31, 2008 12:27 PM >> To: Boyd, Todd M. >> Cc: php-general@lists.php.net >> Subject: Re: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd! >> >> >> On Jul 31, 2008, at 12:55 PM, Boyd, Todd M. wrote: >> >> >> -Original Message- >> >> From: Rahul S. Johari [mailto:[EMAIL PROTECTED] >> >> Sent: Thursday, July 31, 2008 11:40 AM >> >> To: php-general@lists.php.net >> >> Subject: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd! >> >> >> >> Ave, >> >> >> >> What I have is two Select (Drop-Down) lists (State & County) and > I'm >> >> populating them from a mySQL table. What I want is when the user >> >> selects the State from the State List, the County List should only >> >> pull out counties associated with that State. >> >> >> >> Now I know that you can create such an effect using Javascript or >> >> AJAX >> >> and have nothing to do with PHP/mySQL - and I was able to > accomplish >> >> that - but only for lists where you could define data manually. I'm >> >> not able to accomplish this at all with Lists that are pulling out >> >> option data from a mySQL table. >> >> >> >> I'm also giving the User the opportunity to add as many > State/County >> >> combinations as possible in a box. > > ---8<--- snip > >> >> I'm not able to understand exactly how to manipulate the SQL Query >> or >> >> otherwise force the 2nd Select List to only show records that match >> >> the selected State. >> >> >> >> Any pointers? >> > >> > The page referenced by an AJAX XmlHttpRequest() doesn't have to be >> > static. You can even use the query string to supply the AJAX call >> with >> > parameters (or perhaps post a form instead). This way, you can pass >> > the >> > chosen state to the AJAX-requested page and use PHP on the other end >> > to >> > construct the appropriate counties selection list. AJAX could then >> > push >> > this result into a DIV that had, up until now, contained an empty >> > selection list with no available options. >> > >> > Summary: Page has two DIVs: one for state list, one for county list >> > (which is empty). User clicks first DIV's selection box, onChange JS >> > method fires AJAX call to getCounties.php?state=XX (where XX is the >> > chosen state). PHP on the other end builds a selection list for the >> > given state and returns it to the AJAX call. The AJAX result is then >> > assigned to the second div, which now contains the list of counties >> > for >> > the given state. >> > >> In theory your solution sounds extremely feasible & perhaps the >> appropriate procedure. My problem is that I'm not an expert at all in >> AJAX (Or javascript for that matter). The manually-fed examples I >> worked with were freely available sources for such a functional Select >> List, and I tried manipulating them to fit in my php/mySQL code but to >> no avail. >> >> I'll try & work this out, but I doubt I'll be able to. >> >> Thanks. > > Rahul, > > Aww, come now... don't be so negative! :) Most widely-adopted > programming practices are widely-adopted for a reason: they are not > inherently difficult to use. This does, of course, get obfuscated by > various extensions and poor programming techniques end-users employ, but > I digress. > > http://www.w3schools.com/ajax/ should get you started, but here's a > simple implementation: > > selection.html: > --- > > >Alabama >Alaska > > > > > > > > > > > function ajaxCounties() > { >var xmlHttp; >var stateList = document.getElementById("stateList"); > >try { > // Firefox, Opera 8.0+, Safari > xmlHttp = new XMLHttpRequest(); >} catch (e) { >// Internet Explorer >try { >xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); >} catch (e) { >// Older IE >try { >xmlHttp = new > ActiveXObject("Microsoft.XMLHTTP"); >} catch (e) { >// AJAX unsupported >alert("Your browser does not support > AJAX!"); >return false; >} >} >} > >// ajax actions >xmlHttp.onReadyStateChange = function() >{ >// data returned from server >if(xmlHttp.readyState == 4) { >// fill div with server-generated
Re: [PHP] accessing variables within objects
Sorry about that, I forgot you got that link already. Here's an answer for you: I use overloading to dynamically call a function in another object if the current object does not have it. It helps because PHP does not support multiple inheritance. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Philip Thompson wrote: > On Jul 31, 2008, at 11:48 AM, Micah Gersten wrote: > >> Here's the PHP doc page. >> Let us know if you have more questions: >> http://us3.php.net/manual/en/language.oop5.overloading.php > > Yeah, I got the link the first time and read the page. But I was > looking for a little bit more explanation... > > Thanks anyway, > > ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] accessing variables within objects
Philip Thompson wrote: On Jul 30, 2008, at 1:29 PM, Jim Lucas wrote: Marten Lehmann wrote: Hello, I'm using some php-classes which worked fine with php-5.0.4. Now I tried to upgrade to php-5.2.6, but the classes give a lot of errors. If I set error_reporting(E_ALL); I see messages like Notice: Undefined property: FastTemplate::$main in /whereever/inc.template.php on line 293 Notice: Undefined property: current_session::$cust_id in /whereever/inc.init.php on line 117 In inc.template.php there are a lot of calls like $this->$key. In inc.init.php there are calls like $session->cust_id. to fix these errors, you would need to modify the code so it does something like this. where it calls $this->$key you need to check and make sure that $key exists before you trying call for it. So something like this would work. if ( isset( $this->$key ) ) { $this->$key; } else { $this->$key = null; } You didn't show any context in which you are using the above code. So I don't know what will actually work in your situation. Show a little more code that includes the method in which $this->$key is called. You will want to look at using the Overloading feature of PHP5. Check out this page for overloading examples http://us2.php.net/manual/en/language.oop5.overloading.php Take note of the __get() and __set() methods. The __get method checks to see if the key exists before it tries working with it. Ok, I'm trying to understand the point to using these overloading methods. hi = 'Hi'; $obj->bye = 'Bye'; echo $obj->hi, ' ', $obj->bye; // Output: Hi Bye ?> I was only suggesting the overloading because it would be the simplest thing to implement in an existing class without massively re-write parts of your application. You could simply add the __get() method and then have it check to see if the value or $key existed before it tries using it. And if it doesn't exist, then return null or something else. This would get rid of a lot of your NOTICEs from PHP. I would add a method something like the following to your class and it should fix the problems with trying to access properties that do not exist. function __get($key) { // Check for the existence of the key in object if ( isset( $this->$key ) { // If found, return value return $this->$key; } // Default: return null return null; } You could have done that or you could do the following. setHi('Hello'); $obj->setBye('Bye Bye!'); echo $obj->hi(), ' ', $obj->bye(); // Output: Hello Bye Bye! ?> This example is flawed by the fact that you are call hi and bye as a method instead of referencing the property. The 2nd way seems more *OOP* than the first - weird to explain. I guess what I'm wanting to know is why would you use overloading (in PHP)? The only reason I can think of is to avoid having to create/use accessors. Please help me understand! But please be nice! =D Thanks, ~Philip What has changed in php-5.2.x so that these calls don't work any more? What is the new, required form to use objects in a similar manner (unfortunately I have no ressources to code these classes from scratch)? Thanks. Kind regards Marten -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd!
Maybe you should try this library. It comes with examples and is fairly easy to implement. http://xajaxproject.org/ Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Rahul S. Johari wrote: > > In theory your solution sounds extremely feasible & perhaps the > appropriate procedure. My problem is that I'm not an expert at all in > AJAX (Or javascript for that matter). The manually-fed examples I > worked with were freely available sources for such a functional Select > List, and I tried manipulating them to fit in my php/mySQL code but to > no avail. > > I'll try & work this out, but I doubt I'll be able to. > > Thanks. > > --- > Rahul Sitaram Johari > Founder, Internet Architects Group, Inc. > > [Email][EMAIL PROTECTED] > [Web]http://www.rahulsjohari.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd!
What I usually do is default to the most common country and show the associated states. You can change the states if they change the country. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Andrew Ballard wrote: > On Thu, Jul 31, 2008 at 12:40 PM, Rahul S. Johari > <[EMAIL PROTECTED]> wrote: > >> Ave, >> >> What I have is two Select (Drop-Down) lists (State & County) and I'm >> populating them from a mySQL table. What I want is when the user selects the >> State from the State List, the County List should only pull out counties >> associated with that State. >> > [snip] > > This is a usability issue rather than a code issue, but wouldn't you > want that to be the other way around? (ie, select the country from a > list and it populates the state list with > states/provinces/territories/adminstrative disticts/etc. that belong > to that country?) I know the order is "backward" from how one > typically writes an address on paper, but otherwise your state list > will be HUGE and often your country list would only have one value > after the user selects a state. > > Andrew > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd!
> -Original Message- > From: Micah Gersten [mailto:[EMAIL PROTECTED] > Sent: Thursday, July 31, 2008 1:59 PM > To: PHP General list > Subject: Re: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd! > > What I usually do is default to the most common country and show the > associated states. > You can change the states if they change the country. > > Thank you, > Micah Gersten > onShore Networks > Internal Developer > http://www.onshore.com > > > > Andrew Ballard wrote: > > On Thu, Jul 31, 2008 at 12:40 PM, Rahul S. Johari > > <[EMAIL PROTECTED]> wrote: > > > >> Ave, > >> > >> What I have is two Select (Drop-Down) lists (State & County) and I'm > >> populating them from a mySQL table. What I want is when the user > selects the > >> State from the State List, the County List should only pull out > counties > >> associated with that State. > >> > > [snip] > > > > This is a usability issue rather than a code issue, but wouldn't you > > want that to be the other way around? (ie, select the country from a > > list and it populates the state list with > > states/provinces/territories/adminstrative disticts/etc. that belong > > to that country?) I know the order is "backward" from how one > > typically writes an address on paper, but otherwise your state list > > will be HUGE and often your country list would only have one value > > after the user selects a state. *cough* ...pretty sure he wrote "county", guys. ;) Todd Boyd Web Programmer
Re: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd! -- SOLVED!!
Did IT Haha ... just as you were probably writing in & sending this mail. I pretty much used your theory and actually did look around under http://www.w3schools.com/ajax/ to get the relevant AJAX information. Works like a charm. Pretty much using an onChange=grabCountiesfromAnotherPHPpage(); function. Code is similar to your example below - slightly different. An included 'ajax.js' takes care of the AJAX code, and an additional 'counties.php' writes counties based on a "SELECT COUNTY from myTable WHERE STATE = $_GET['STATE']" SQL Query in an independent SELECT LIST. AJAX takes care of the rest by pulling in this SELECT LIST on to the original page. Thanks a ton - this actually turned out to be easier then I thought!! :) On Jul 31, 2008, at 2:31 PM, Boyd, Todd M. wrote: Rahul, Aww, come now... don't be so negative! :) Most widely-adopted programming practices are widely-adopted for a reason: they are not inherently difficult to use. This does, of course, get obfuscated by various extensions and poor programming techniques end-users employ, but I digress. http://www.w3schools.com/ajax/ should get you started, but here's a simple implementation: selection.html: --- Alabama Alaska function ajaxCounties() { var xmlHttp; var stateList = document.getElementById("stateList"); try { // Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { // Older IE try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { // AJAX unsupported alert("Your browser does not support AJAX!"); return false; } } } // ajax actions xmlHttp.onReadyStateChange = function() { // data returned from server if(xmlHttp.readyState == 4) { // fill div with server-generated
Re: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd!
You're right. Same principles apply though. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Boyd, Todd M. wrote: > *cough* > > ...pretty sure he wrote "county", guys. ;) > > > Todd Boyd > Web Programmer > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd! -- SOLVED!!
> -Original Message- > From: Rahul S. Johari [mailto:[EMAIL PROTECTED] > Sent: Thursday, July 31, 2008 2:06 PM > To: Boyd, Todd M. > Cc: php-general@lists.php.net > Subject: Re: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd! -- > SOLVED!! > > > Did IT Haha ... just as you were probably writing in & sending > this mail. > I pretty much used your theory and actually did look around under > http://www.w3schools.com/ajax/ > to get the relevant AJAX information. Works like a charm. > > Pretty much using an onChange=grabCountiesfromAnotherPHPpage(); > function. Code is similar to your example below - slightly different. > An included 'ajax.js' takes care of the AJAX code, and an additional > 'counties.php' writes counties based on a "SELECT COUNTY from myTable > WHERE STATE = $_GET['STATE']" SQL Query in an independent SELECT LIST. > AJAX takes care of the rest by pulling in this SELECT LIST on to the > original page. > > Thanks a ton - this actually turned out to be easier then I thought!! > > :) Rahul, Glad to hear it! Hopefully, this will keep you from abandoning new and exciting programming horizons that you don't immediately feel capable of grasping. After all, if you're going to be an "Internet Architect," AJAX is something you'll need to be (at least comfortably) familiar with. :) Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd!
> -Original Message- > From: Micah Gersten [mailto:[EMAIL PROTECTED] > Sent: Thursday, July 31, 2008 2:08 PM > To: Boyd, Todd M. > Cc: PHP General list > Subject: Re: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd! > > You're right. Same principles apply though. > > Thank you, > Micah Gersten > onShore Networks > Internal Developer > http://www.onshore.com > > > > Boyd, Todd M. wrote: > > *cough* > > > > ...pretty sure he wrote "county", guys. ;) I guess. Just sayin'... the logic was not backwards, as selecting a Country to match a State would pretty much always yield only one result. :) Missouri => USA Ontario => Canada Etc. Nevertheless, an interesting discussion on methods. Todd Boyd Web Programmer
Re: [PHP] limiting the amount of emails sent at a time in a batch send
On Thu, Jul 31, 2008 at 1:27 PM, brian <[EMAIL PROTECTED]> wrote: > Richard Kurth wrote: >> >> I want to limit these script two send 100 email and then pause for a few >> seconds and then send another 100 emails and repeat this tell it has sent >> all the emails that are dated for today. This script is runs by cron so it >> is running in the background. >> >> How would I do this and is it the best way to do it. I am using swift >> mailer to send the mail. >> >> I think I would use limit 100 in the query but how would I tell it to get >> the next 100. > > There's no need to limit the DB query, nor to track what's been sent by > updating the DB. Grab all of the addresses at once and let SwiftMailer deal > with the throttling: > > require('Swift/lib/Swift.php'); > require('Swift/lib/Swift/Connection/SMTP.php'); > > /* this handles the throttling > */ > require('Swift/lib/Swift/Plugin/AntiFlood.php'); > > > /* this holds all of your addresses > */ > $recipients = new Swift_RecipientList(); > > > /* Grab the addresses from the DB (this is using MDB2) > */ > $result = ... > > while ($row = $result->fetchRow()) > { >$recipients->addTo($row['address'], $row['name']); > } > @$result->free(); > > try > { >$swift = new Swift(new Swift_Connection_SMTP('localhost'), > 'your_domain'); > >set_time_limit(0); >$swift->log->enable(); > >/* 100 mails per batch with a 60 second pause between batches > */ >$swift->attachPlugin(new Swift_Plugin_AntiFlood(100, 60), > 'anti-flood'); > >flush(); > >$message = new Swift_Message('your subject'); > >$message->setCharset('utf-8'); >$message->setReplyTo(...); >$message->setReturnPath(...); >$message->headers->set('Errors-To', ...); > >$message->attach(new Swift_Message_Part($plain_content)); >$message->attach(new Swift_Message_Part($html_content, 'text/html')); > >$num_sent = $swift->batchSend($message, $recipients, new > Swift_Address(..., '...')); > >$swift->disconnect(); > > ... > > > This is a rough example taken from my own script. This would need to be > modified if you're not sending the same message to all recipients, of > course. It's not clear to me from your example. > > b > Nice! I'll have to look into this library some time. How do you control it to prevent sending the same message though? I can't imagine this is called from a web page, because I'm guessing it would take a few minutes to finish. If it's called from a cron job, don't you still have to somehow flag the message as having been delivered so that the next process doesn't come along and send the same thing all over again? Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd!
On Thu, Jul 31, 2008 at 3:04 PM, Boyd, Todd M. <[EMAIL PROTECTED]> wrote: >> -Original Message- >> From: Micah Gersten [mailto:[EMAIL PROTECTED] >> Sent: Thursday, July 31, 2008 1:59 PM >> To: PHP General list >> Subject: Re: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd! >> >> What I usually do is default to the most common country and show the >> associated states. >> You can change the states if they change the country. >> >> Thank you, >> Micah Gersten >> onShore Networks >> Internal Developer >> http://www.onshore.com >> >> >> >> Andrew Ballard wrote: >> > On Thu, Jul 31, 2008 at 12:40 PM, Rahul S. Johari >> > <[EMAIL PROTECTED]> wrote: >> > >> >> Ave, >> >> >> >> What I have is two Select (Drop-Down) lists (State & County) and I'm >> >> populating them from a mySQL table. What I want is when the user >> selects the >> >> State from the State List, the County List should only pull out >> counties >> >> associated with that State. >> >> >> > [snip] >> > >> > This is a usability issue rather than a code issue, but wouldn't you >> > want that to be the other way around? (ie, select the country from a >> > list and it populates the state list with >> > states/provinces/territories/adminstrative disticts/etc. that belong >> > to that country?) I know the order is "backward" from how one >> > typically writes an address on paper, but otherwise your state list >> > will be HUGE and often your country list would only have one value >> > after the user selects a state. > > *cough* > > ...pretty sure he wrote "county", guys. ;) > > > Todd Boyd > Web Programmer > Oops. Sure did. My mistake. I'm so used to dealing with country lists my eyes glossed right over the word 'county'. :-) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd! -- SOLVED!!
On Jul 31, 2008, at 3:10 PM, Boyd, Todd M. wrote: -Original Message- From: Rahul S. Johari [mailto:[EMAIL PROTECTED] Sent: Thursday, July 31, 2008 2:06 PM To: Boyd, Todd M. Cc: php-general@lists.php.net Subject: Re: [PHP] Dynamic Select Lists - 1st Selection Effects 2nd! -- SOLVED!! Did IT Haha ... just as you were probably writing in & sending this mail. I pretty much used your theory and actually did look around under http://www.w3schools.com/ajax/ to get the relevant AJAX information. Works like a charm. Pretty much using an onChange=grabCountiesfromAnotherPHPpage(); function. Code is similar to your example below - slightly different. An included 'ajax.js' takes care of the AJAX code, and an additional 'counties.php' writes counties based on a "SELECT COUNTY from myTable WHERE STATE = $_GET['STATE']" SQL Query in an independent SELECT LIST. AJAX takes care of the rest by pulling in this SELECT LIST on to the original page. Thanks a ton - this actually turned out to be easier then I thought!! :) Rahul, Glad to hear it! Hopefully, this will keep you from abandoning new and exciting programming horizons that you don't immediately feel capable of grasping. After all, if you're going to be an "Internet Architect," AJAX is something you'll need to be (at least comfortably) familiar with. :) Todd Boyd Web Programmer Indeed! This problem actually opened up my horizon to the whole AJAX foundation. I think what I was most impressed was the ease with which I was able to accomplish this Dynamic state for my select lists, and how effective the script actually is. I actually had two separate SELECT LIST combinations on the page which both needed the same Dynamic functionality. Achieved it by fine-tuning my script a bit. Really liking AJAX right now and ready to dip in my feet deeper. Thanks Todd, appreciate your support! --- Rahul Sitaram Johari Founder, Internet Architects Group, Inc. [Email] [EMAIL PROTECTED] [Web] http://www.rahulsjohari.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] limiting the amount of emails sent at a time in a batch send
Andrew Ballard wrote: On Thu, Jul 31, 2008 at 1:27 PM, brian <[EMAIL PROTECTED]> wrote: Richard Kurth wrote: I want to limit these script two send 100 email and then pause for a few seconds and then send another 100 emails and repeat this tell it has sent all the emails that are dated for today. This script is runs by cron so it is running in the background. How would I do this and is it the best way to do it. I am using swift mailer to send the mail. I think I would use limit 100 in the query but how would I tell it to get the next 100. There's no need to limit the DB query, nor to track what's been sent by updating the DB. Grab all of the addresses at once and let SwiftMailer deal with the throttling: require('Swift/lib/Swift.php'); require('Swift/lib/Swift/Connection/SMTP.php'); /* this handles the throttling */ require('Swift/lib/Swift/Plugin/AntiFlood.php'); /* this holds all of your addresses */ $recipients = new Swift_RecipientList(); /* Grab the addresses from the DB (this is using MDB2) */ $result = ... while ($row = $result->fetchRow()) { $recipients->addTo($row['address'], $row['name']); } @$result->free(); try { $swift = new Swift(new Swift_Connection_SMTP('localhost'), 'your_domain'); set_time_limit(0); $swift->log->enable(); /* 100 mails per batch with a 60 second pause between batches */ $swift->attachPlugin(new Swift_Plugin_AntiFlood(100, 60), 'anti-flood'); flush(); $message = new Swift_Message('your subject'); $message->setCharset('utf-8'); $message->setReplyTo(...); $message->setReturnPath(...); $message->headers->set('Errors-To', ...); $message->attach(new Swift_Message_Part($plain_content)); $message->attach(new Swift_Message_Part($html_content, 'text/html')); $num_sent = $swift->batchSend($message, $recipients, new Swift_Address(..., '...')); $swift->disconnect(); ... This is a rough example taken from my own script. This would need to be modified if you're not sending the same message to all recipients, of course. It's not clear to me from your example. b Nice! I'll have to look into this library some time. How do you control it to prevent sending the same message though? I'm not sure about that. Mine is for a newsletter (not personalised) so Swift just needs a list of addresses. I can't remember if AntiFlood can be used for many unique mails. I suspect that it doesn't. I can't imagine this is called from a web page, because I'm guessing it would take a few minutes to finish. cron. But, if you wanted it fired from an admin page (I can't imagine a good situation where something like this would be public) you could add ignore_user_abort() and then jazz up the page with some async JS. If it's called from a cron job, don't you still have to somehow flag the message as having been delivered so that the next process doesn't come along and send the same thing all over again? Yeah, I just twigged to the fact that your messages are stored in the database. This is some kind of messaging system? As opposed to a newsletter-type thing, I mean. As above, I don't know that AntiFlood is what you want. That's meant for multiple-recipient mails. There's also a Throttler plugin, though, again, it's meant for batches. You might also look at the IMAP functions. Instead of storing the messages in the DB, you can let the MTA deal with pushing them out and cut Swift (and the cro0n job) out of the loop. b -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Site work fine with appserv, but fail over debian :S
hi. Im implementing a website, making the develop and testing using appserv. All work perfectly. But when i upload the site to my linux webserver some pages cant be displayed. The page dont display any error, but dont show information. The problem is only when i load the info from a table of my database. The same site and database in appserv work perfectly. What can be the difference between my linux server, and the appserv applications? Thanks in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] limiting the amount of emails sent at a time in a batch send
On Thu, Jul 31, 2008 at 4:24 PM, brian <[EMAIL PROTECTED]> wrote: > Andrew Ballard wrote: >> >> On Thu, Jul 31, 2008 at 1:27 PM, brian <[EMAIL PROTECTED]> wrote: >>> >>> Richard Kurth wrote: I want to limit these script two send 100 email and then pause for a few seconds and then send another 100 emails and repeat this tell it has sent all the emails that are dated for today. This script is runs by cron so it is running in the background. How would I do this and is it the best way to do it. I am using swift mailer to send the mail. I think I would use limit 100 in the query but how would I tell it to get the next 100. >>> >>> There's no need to limit the DB query, nor to track what's been sent by >>> updating the DB. Grab all of the addresses at once and let SwiftMailer >>> deal >>> with the throttling: >>> >>> require('Swift/lib/Swift.php'); >>> require('Swift/lib/Swift/Connection/SMTP.php'); >>> >>> /* this handles the throttling >>> */ >>> require('Swift/lib/Swift/Plugin/AntiFlood.php'); >>> >>> >>> /* this holds all of your addresses >>> */ >>> $recipients = new Swift_RecipientList(); >>> >>> >>> /* Grab the addresses from the DB (this is using MDB2) >>> */ >>> $result = ... >>> >>> while ($row = $result->fetchRow()) >>> { >>> $recipients->addTo($row['address'], $row['name']); >>> } >>> @$result->free(); >>> >>> try >>> { >>> $swift = new Swift(new Swift_Connection_SMTP('localhost'), >>> 'your_domain'); >>> >>> set_time_limit(0); >>> $swift->log->enable(); >>> >>> /* 100 mails per batch with a 60 second pause between batches >>>*/ >>> $swift->attachPlugin(new Swift_Plugin_AntiFlood(100, 60), >>> 'anti-flood'); >>> >>> flush(); >>> >>> $message = new Swift_Message('your subject'); >>> >>> $message->setCharset('utf-8'); >>> $message->setReplyTo(...); >>> $message->setReturnPath(...); >>> $message->headers->set('Errors-To', ...); >>> >>> $message->attach(new Swift_Message_Part($plain_content)); >>> $message->attach(new Swift_Message_Part($html_content, >>> 'text/html')); >>> >>> $num_sent = $swift->batchSend($message, $recipients, new >>> Swift_Address(..., '...')); >>> >>> $swift->disconnect(); >>> >>> ... >>> >>> >>> This is a rough example taken from my own script. This would need to be >>> modified if you're not sending the same message to all recipients, of >>> course. It's not clear to me from your example. >>> >>> b >>> >> >> Nice! I'll have to look into this library some time. How do you >> control it to prevent sending the same message though? > > I'm not sure about that. Mine is for a newsletter (not personalised) so > Swift just needs a list of addresses. I can't remember if AntiFlood can be > used for many unique mails. I suspect that it doesn't. > >> I can't imagine >> this is called from a web page, because I'm guessing it would take a >> few minutes to finish. > > cron. But, if you wanted it fired from an admin page (I can't imagine a good > situation where something like this would be public) you could add > ignore_user_abort() and then jazz up the page with some async JS. > > If it's called from a cron job, don't you still >> >> have to somehow flag the message as having been delivered so that the >> next process doesn't come along and send the same thing all over >> again? > > Yeah, I just twigged to the fact that your messages are stored in the > database. This is some kind of messaging system? As opposed to a > newsletter-type thing, I mean. As above, I don't know that AntiFlood is > what you want. That's meant for multiple-recipient mails. > > There's also a Throttler plugin, though, again, it's meant for batches. > > You might also look at the IMAP functions. Instead of storing the messages > in the DB, you can let the MTA deal with pushing them out and cut Swift (and > the cro0n job) out of the loop. > > b > The case I have in mind is for a newsletter, and in this instance they are all the same. In this instance, I am limited by the host to 2500 messages/hour. (Originally it was 900). At this point, 2500 is more than enough for this group, but I'd still like to play kindly with the server resources since this is a shared host. I just set up a generic message queue and dump mail there rather than sending it real time. For now, all the messages in a given batch are the same, but I was leaving flexibility in case I hit a situation where that changed. It looks like this would work pretty well when I'm up for a rewrite. :) I understand the general idea: 1. read message body from storage (file, database, etc.) 2. get result set containing addresses from database 3. build recipient list from result set 4. send everything to sendBatch() It seems to me that step 5 still has to either (a) delete the message body from storage or else (b) flag it as sent so that the next process spawned via cron sees that there is
Re: [PHP] limiting the amount of emails sent at a time in a batch send
Andrew Ballard wrote: On Thu, Jul 31, 2008 at 4:24 PM, brian <[EMAIL PROTECTED]> wrote: Andrew Ballard wrote: On Thu, Jul 31, 2008 at 1:27 PM, brian <[EMAIL PROTECTED]> wrote: Richard Kurth wrote: I want to limit these script two send 100 email and then pause for a few seconds and then send another 100 emails and repeat this tell it has sent all the emails that are dated for today. This script is runs by cron so it is running in the background. How would I do this and is it the best way to do it. I am using swift mailer to send the mail. I think I would use limit 100 in the query but how would I tell it to get the next 100. There's no need to limit the DB query, nor to track what's been sent by updating the DB. Grab all of the addresses at once and let SwiftMailer deal with the throttling: require('Swift/lib/Swift.php'); require('Swift/lib/Swift/Connection/SMTP.php'); /* this handles the throttling */ require('Swift/lib/Swift/Plugin/AntiFlood.php'); /* this holds all of your addresses */ $recipients = new Swift_RecipientList(); /* Grab the addresses from the DB (this is using MDB2) */ $result = ... while ($row = $result->fetchRow()) { $recipients->addTo($row['address'], $row['name']); } @$result->free(); try { $swift = new Swift(new Swift_Connection_SMTP('localhost'), 'your_domain'); set_time_limit(0); $swift->log->enable(); /* 100 mails per batch with a 60 second pause between batches */ $swift->attachPlugin(new Swift_Plugin_AntiFlood(100, 60), 'anti-flood'); flush(); $message = new Swift_Message('your subject'); $message->setCharset('utf-8'); $message->setReplyTo(...); $message->setReturnPath(...); $message->headers->set('Errors-To', ...); $message->attach(new Swift_Message_Part($plain_content)); $message->attach(new Swift_Message_Part($html_content, 'text/html')); $num_sent = $swift->batchSend($message, $recipients, new Swift_Address(..., '...')); $swift->disconnect(); ... This is a rough example taken from my own script. This would need to be modified if you're not sending the same message to all recipients, of course. It's not clear to me from your example. b Nice! I'll have to look into this library some time. How do you control it to prevent sending the same message though? I'm not sure about that. Mine is for a newsletter (not personalised) so Swift just needs a list of addresses. I can't remember if AntiFlood can be used for many unique mails. I suspect that it doesn't. I can't imagine this is called from a web page, because I'm guessing it would take a few minutes to finish. cron. But, if you wanted it fired from an admin page (I can't imagine a good situation where something like this would be public) you could add ignore_user_abort() and then jazz up the page with some async JS. If it's called from a cron job, don't you still have to somehow flag the message as having been delivered so that the next process doesn't come along and send the same thing all over again? Yeah, I just twigged to the fact that your messages are stored in the database. This is some kind of messaging system? As opposed to a newsletter-type thing, I mean. As above, I don't know that AntiFlood is what you want. That's meant for multiple-recipient mails. There's also a Throttler plugin, though, again, it's meant for batches. You might also look at the IMAP functions. Instead of storing the messages in the DB, you can let the MTA deal with pushing them out and cut Swift (and the cro0n job) out of the loop. b The case I have in mind is for a newsletter, and in this instance they are all the same. In this instance, I am limited by the host to 2500 messages/hour. (Originally it was 900). At this point, 2500 is more than enough for this group, but I'd still like to play kindly with the server resources since this is a shared host. I just set up a generic message queue and dump mail there rather than sending it real time. For now, all the messages in a given batch are the same, but I was leaving flexibility in case I hit a situation where that changed. It looks like this would work pretty well when I'm up for a rewrite. :) I understand the general idea: 1. read message body from storage (file, database, etc.) 2. get result set containing addresses from database 3. build recipient list from result set 4. send everything to sendBatch() It seems to me that step 5 still has to either (a) delete the message body from storage or else (b) flag it as sent so that the next process spawned via cron sees that there is no work to do and dies rather than repeating the whole process again. Andrew Thanks to everybody. I have figured this out. I am using swift but I am limiting the send by a 100 and setting the table with the date sent. Then the crontab runes again and grabs another 100 that have not had th
Re: [PHP] accessing variables within objects
On Jul 31, 2008, at 1:49 PM, Jim Lucas wrote: Philip Thompson wrote: On Jul 30, 2008, at 1:29 PM, Jim Lucas wrote: Marten Lehmann wrote: Hello, I'm using some php-classes which worked fine with php-5.0.4. Now I tried to upgrade to php-5.2.6, but the classes give a lot of errors. If I set error_reporting(E_ALL); I see messages like Notice: Undefined property: FastTemplate::$main in /whereever/ inc.template.php on line 293 Notice: Undefined property: current_session::$cust_id in / whereever/inc.init.php on line 117 In inc.template.php there are a lot of calls like $this->$key. In inc.init.php there are calls like $session->cust_id. to fix these errors, you would need to modify the code so it does something like this. where it calls $this->$key you need to check and make sure that $key exists before you trying call for it. So something like this would work. if ( isset( $this->$key ) ) { $this->$key; } else { $this->$key = null; } You didn't show any context in which you are using the above code. So I don't know what will actually work in your situation. Show a little more code that includes the method in which $this->$key is called. You will want to look at using the Overloading feature of PHP5. Check out this page for overloading examples http://us2.php.net/manual/en/language.oop5.overloading.php Take note of the __get() and __set() methods. The __get method checks to see if the key exists before it tries working with it. Ok, I'm trying to understand the point to using these overloading methods. hi = 'Hi'; $obj->bye = 'Bye'; echo $obj->hi, ' ', $obj->bye; // Output: Hi Bye ?> I was only suggesting the overloading because it would be the simplest thing to implement in an existing class without massively re-write parts of your application. You could simply add the __get() method and then have it check to see if the value or $key existed before it tries using it. And if it doesn't exist, then return null or something else. This would get rid of a lot of your NOTICEs from PHP. I would add a method something like the following to your class and it should fix the problems with trying to access properties that do not exist. function __get($key) { // Check for the existence of the key in object if ( isset( $this->$key ) { // If found, return value return $this->$key; } // Default: return null return null; } You could have done that or you could do the following. setHi('Hello'); $obj->setBye('Bye Bye!'); echo $obj->hi(), ' ', $obj->bye(); // Output: Hello Bye Bye! ?> This example is flawed by the fact that you are call hi and bye as a method instead of referencing the property. Wait a second. Isn't that the point of encapsulation and abstraction? You don't have direct access to properties - only the class does (well, if it's private). ~Phil The 2nd way seems more *OOP* than the first - weird to explain. I guess what I'm wanting to know is why would you use overloading (in PHP)? The only reason I can think of is to avoid having to create/use accessors. Please help me understand! But please be nice! =D Thanks, ~Philip What has changed in php-5.2.x so that these calls don't work any more? What is the new, required form to use objects in a similar manner (unfortunately I have no ressources to code these classes from scratch)? Thanks. Kind regards Marten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] limiting the amount of emails sent at a time in a batch send
brian wrote: > Richard Kurth wrote: >> I want to limit these script two send 100 email and then pause for a >> few seconds and then send another 100 emails and repeat this tell it >> has sent all the emails that are dated for today. This script is runs >> by cron so it is running in the background. >> >> How would I do this and is it the best way to do it. I am using swift >> mailer to send the mail. >> >> I think I would use limit 100 in the query but how would I tell it to >> get the next 100. > > There's no need to limit the DB query, nor to track what's been sent by > updating the DB. Grab all of the addresses at once and let SwiftMailer > deal with the throttling: Of course there is. 1) What if the server gets rebooted in the middle of the send or the database goes down in the middle? You send to everyone again. 2) What if the host has a limit on how long a script can run for? You send to everyone again and again and again each time the script tries to start. 3) What if safe-mode is enabled on the server? You have a limited send time and possibly end up with the same outcome as #2. 4) What if you are sending to 100,000 email addresses? You run out of memory because you have so much data loaded. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] upload file problem
Thanks.. It's fixed... - Jignesh On Thu, Jul 31, 2008 at 6:05 PM, brian <[EMAIL PROTECTED]> wrote: > Jignesh Thummar wrote: >> >> I'm trying to upload the file. It's showing me successfully uploaded. >> But it's not able to move from temp directory to my defined directory >> >> my code: >> >> if (is_uploaded_file($_FILES['myfile']['tmp_name'])) { >> move_uploaded_file($_FILES['myfile']['tmp_name'], $myfilename); >> echo "File ". $_FILES['myfile']['name'] ." uploaded successfully.\n"; >> } else { >> echo "File uploading error"; >> } >> > > What does $myfilename resolve to? It should include the complete path from > server root (not DOCUMENT_ROOT). > > Try: > > echo "File uploading error: ${myfilename}"; > > -- > 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