Re: [PHP] Automatic Execution of Function
On Sunday, November 07, 2004, at 09:38PM, Kevin Javia <[EMAIL PROTECTED]> wrote: >Hi, > >I need to make a function that will execute "automatically" at some regular >intervals. > >Is it possible? If yes, can any give me some hint how can I make such thing? > >Thanks. >Kevin. > I presume you're talking about executing a script on periodic basis, not on a periodic basis within a webpage. If so, and you're on a unix-like OS, try cron. -ryan - http://homepage.mac.com/ryansking/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] You know you're a geek when...
On Sunday, November 07, 2004, at 10:38PM, raditha dissanayake <[EMAIL PROTECTED]> wrote: >Murray @ PlanetThoughtful wrote: > >>.You upgrade MySQL from 4.0.x to 4.1.x and you get excited because now you >>can include subselects in your pages. >> >> >You know you're a geek when you know which list deals with which top >and when you know that subselects in mysql is not much faster than the >nested loop you have been using. You know you're a geek when you know there's more to software development than speed. -ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] inline_C installation
On Nov 11, 2004, at 12:50 PM, Rayan Lahoud wrote: Does anybody knows how to install a pear package. i have the inline_C package that i want to install and use. And can i have some sample functions using this package? I believe the inline_c package is actually a pecl package [pecl.php.net], however it is still installed with the pear installer (I hope that makes sense). Ok, first try typing pear -v on the command line. If this doesn't work (it returns "command not found"), try http://pear.php.net/manual/en/installation.php. If that succedes, you have a pear package manager installed. Now type: pear install inline_c this should install the package for you. You'll probably have to add the module to your php.ini script and restart apache. -ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unable to use vars in foreach
On Sunday, November 14, 2004, at 08:24PM, Jonathan Villa <[EMAIL PROTECTED]> wrote: > >$modules = simplexml_load_file(MODULES); > Are you certain that MODULES has been defined()? And what do you get when you print_r($modules)? -ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unable to use vars in foreach
On Sunday, November 14, 2004, at 08:36PM, Jonathan Villa <[EMAIL PROTECTED]> wrote: >> >> On Sunday, November 14, 2004, at 08:24PM, Jonathan Villa <[EMAIL PROTECTED]> >> wrote: >>> >>>$modules = simplexml_load_file(MODULES); >>> >> >> Are you certain that MODULES has been defined()? And what do you get when >> you print_r($modules)? >> >> -ryan >> > >Yes MODULES is defined. It's defined in an include file. In my loop, >when I echo the $mod->postName the values print just fine. My issue is in >the conditional. AHA! Here's what I think's going on (sorry I don't have time to investigate it myself) $mod->postName is a simplexml object. Due to some php5 magic, when used it a situation that calls for a string (like echo $xmlobj), it echos the proper value. However, when using it as an array subscript does not appear to qualify as this situation. To solve this try either: $post[(string)$xmlobj] OR $post[strval($xmlobj)] I hope this is clear and helpful. -ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unable to use vars in foreach [updated question]
On Sunday, November 14, 2004, at 08:44PM, Jonathan Villa <[EMAIL PROTECTED]> wrote: >So, searching php.net (I swear I did before...) > >I found this at http://us2.php.net/language.types.array > >" You cannot use arrays or objects as keys. Doing so will result in a >warning: Illegal offset type." > >Neverthought that my var was an object, just thought maybe a string. My >new question is, how can I convert this object to a string? Or get the >val of it See my post from about 1 minute ago. -ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] explode and PATH_SEPARATOR
On Nov 15, 2004, at 10:17 AM, Francisco M. Marzoa Alonso wrote: Taking this code: define (PATH_SEPARATOR, "/"); $String="Root/One/Two/Three/Last"; $arr = explode ( PATH_SEPARATOR, $String ); var_dump ( $arr ); $arr = explode ( "/", $String ); var_dump ( $arr ); ?> PATH_SEPARATOR is is a predefined constant, so you'll need to use something else, but you still need to put quotes around it: define('NOT_PATH_SEPARATOR', '/'); -ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date handling
On Nov 15, 2004, at 2:05 PM, Ryan wrote: Hello, I would like to find out the 'official' way to handle dates in PHP. There are many paths, choose the one best for you. :-) I am looking at the PEAR Date module and that seems to resolve these issues, but I would like to know if that is the standard/official way to handle dates in PHP applications as in my application, I would like to have one handler for dates, rather than separate code for dates within the Unix timestamp range and for dates outside - so if I switch to PEAR Date, I will use it everywhere in my code since I cannot take any chance of using date() or strftime() and possibly getting invalid data. I don't believe there is a standard way to do anything in php. I'd say if you find that it works for you, use it. I've used the PEAR Date package myself and it has worked in every case that I needed it. Additionally, are there any plans to make an official PHP date extension that handles dates outside a Unix timestamp range as something built into the language itself rather than as a '3rd party extension' which the PEAR Date module appears to be since it's not in the core PHP language? I believe I've heard rumors of this for php5.1. You might want to dig through the php-internals archive to find out for sure. Thanks, Ryan You're welcome, ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] isset opposite
On Nov 16, 2004, at 5:11 PM, Dustin Krysak wrote: Hi there.. I am pretty new to PHP, and I am familiar with php "isset" option now i was wondering (I have looked at the PHP site - but can not find it) how can you check if something is not set? I need to test if a $_GET is not set (not just empty). !array_key_exists('yourkey', $_GET); -ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mp3 parsing
Anyone out there have a way to read the header info out of an mp3 file? I'm able to parse out the id3 tags, but am having trouble finding a way to read the header info. The info I'm trying to get is the playtime and bitrate. thanks, ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mp3 parsing
On Nov 16, 2004, at 7:24 PM, Manuel Lemos wrote: Hello, On 11/16/2004 10:58 PM, Ryan King wrote: Anyone out there have a way to read the header info out of an mp3 file? I'm able to parse out the id3 tags, but am having trouble finding a way to read the header info. The info I'm trying to get is the playtime and bitrate. Here you can find several solutions that can do exactly that: http://www.phpclasses.org/browse/class/34.html Ah, I had tried phpclassses.org before but didn't find what I needed. Most of those classes only do id3 tags, while I need the frame headers, too. I see now that there is a class there that will help. thanks, ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mp3 cropping
Anyone out there know of a tool or technique for cropping an MP3 file (e.g., cutting the first 30 sec out into another file)? PHP would be nice, but not necessary. TIA, ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mp3 cropping
On Nov 17, 2004, at 10:05 PM, Robby Russell wrote: On Wed, 2004-11-17 at 21:53 -0600, Ryan King wrote: Anyone out there know of a tool or technique for cropping an MP3 file (e.g., cutting the first 30 sec out into another file)? PHP would be nice, but not necessary. TIA, ryan a php question would be nice, but not necessary. :-p An -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mp3 cropping
On Nov 17, 2004, at 10:05 PM, Robby Russell wrote: On Wed, 2004-11-17 at 21:53 -0600, Ryan King wrote: Anyone out there know of a tool or technique for cropping an MP3 file (e.g., cutting the first 30 sec out into another file)? PHP would be nice, but not necessary. TIA, ryan a php question would be nice, but not necessary. :-p An bit of help would be nice, but not necessary. -ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] require() in other directories?
Peter Lauri wrote: I get the Failed to open stream, no such file in directory If you were in one of these folders: /fr/ /eng/ And your classfile was namned classes.php and in the directory: /classes/ And you wanted to include the classfile, how would you write it? I would assume: require("/classes/classes.php"); require("classes/classes.php"); But that doesn't work. Help :) "Pluance" <[EMAIL PROTECTED]> skrev i meddelandet news:[EMAIL PROTECTED] What error happen? On Thu, 18 Nov 2004 09:15:22 +0100, Peter Lauri <[EMAIL PROTECTED]> wrote: Best groupmember, I have an webapplication that uses different languages and therefor I have set up different directorys for each language. All languages use the same classes. The problem I have is when I want to require() the classfile I can not require a file that is not in the same directory as my .php file. I have tried the following: require("../classes.php"); require("http://www.mydomain.com/classes.php";); and more. All gives me error messages, why? Anyone that could help me? - Best Of Times /Peter -- 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
Re: [PHP] Tabs or Spaces?
On Nov 21, 2004, at 4:30 PM, M. Sokolewicz wrote: Jon-Eirik Pettersen wrote: Daniel Schierbeck wrote: Hello there! There seems to be some tendency towards using spaces instead of tabs when indenting PHP code - personally i can't come up with any reason not to use tabs. I was just wondering if any of you freakees had some sort of explanation... One reason is that a space is a space and will allways be a space. A tab may be 5, 3 or whatever spaces depending on the editors configration. When more than one developer is developing on a project they will see the indenting differently when using tabs. that's indeed usually it. However, remember that both a space and a tab are actually only a single character, so if you're looking at the amount of space both take, it's exactly the same. However, when indenting with 3 spaces instead of a single tab, then your code-size WILL increase, and will include 3x more "space content" than it used to :) Who cares? -ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Tabs or Spaces?
On Nov 21, 2004, at 3:09 PM, Matthew Weier O'Phinney wrote: * Daniel Schierbeck <[EMAIL PROTECTED]>: There seems to be some tendency towards using spaces instead of tabs when indenting PHP code - personally i can't come up with any reason not to use tabs. I was just wondering if any of you freakees had some sort of explanation... Most likely due to PEAR standards: http://pear.sourceforge.net/en/standards.php I'm not sure what the rationale was behind using spaces instead of tabs, but it's a standard I've seen in perl as well; it's not entirely unheard I believe the rationale is that, since different environments define tabs as different sizes. So, the only way to be consistent across different environments is to use spaces. FWIW, many text editors can emulate tabs. That is, when typin, you can hit tab, but the text editor inserts spaces instead. I find this very useful. -ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Tabs or Spaces?
On Nov 21, 2004, at 5:09 PM, Chris Shiflett wrote: --- Ryan King <[EMAIL PROTECTED]> wrote: However, when indenting with 3 spaces instead of a single tab, then your code-size WILL increase, and will include 3x more "space content" than it used to :) Who cares? Just to point out the obvious, if you're not using a compiler cache, size does matter. Of course, if you're to the point where the difference is important to you, you're to the point where you should figure out how to use APC or something. :-) I agree. I can't imagine that having more whitespace characters in a script will significantly effect the performance of said script. I would guess that there would always be more significant issues to deal with in regards to performance- php compiling and optimizing SQL queries being chief in my mind. Its silly and inefficient (work-wise) to optimize the small issues in programming. Just remember, "Premature optimization is the root of all evil." (Knuth) -ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Where to learn about these topics
On Nov 22, 2004, at 11:33 AM, Chris Lott wrote: In MySQL I would say... If you have data which has to be inserted in serveral tables, you must first check if all conditions are ok. So, do some selects to check if everythin in your database is ok, and after that, execute the query. But, when you really want to make complex database driven applications, choose PostgreSQL! This database is better build for complexity (and not only that ;) ), and supports transactions and references, and more stuff like that which can be really helpful to you... And when you compare MySQL against PostgreSQL... PostgreSQL is a heavy system compared with MySQL, also free, but when you look at the functionality: SUPERIOR But even with Postgresql I have the same situation. No, you don't. Let's say a user wants to enter a new contact into the database. This contact lives in a new city and has a new kind of relationship. To make that city and relationship available, I need them in the related tables. Or I need my form action to check for each one, insert if they are not there, and then finally insert the new record. This last seems preferable (one form), but no books seem to deal with the real world, only the simplest, single-table cases... This is where stored procedures, triggers and update-able views become very handy. -ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: intalling pear:db
On Nov 25, 2004, at 1:56 AM, Merlin wrote: Hi, that did not help. The pear manual says that this can be installed via command line, plus "pear list" tells me that the package is installed. However if I call phpinfo() there is no mentioning about pear in any way?! Do I have to enable it first anyhow?` How about trying a var_dump() on your DB object? For me, this is always the first step in trying to solve a mystery like this. Chances are, your DB object is really a PEAR_Error object because your failed to connect to your database. -ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Grammar for PHP
On Nov 28, 2004, at 7:28 AM, Dominic Fox wrote: Hi, I would like to parse some PHP files to extract some information about them. Is there a formal grammar (EBNF or other) anywhere that I could use as a reference? I'd like to write the parser myself (in Haskell), so existing PHP parsers (in PHP itself, for instance) aren't quite what I'm looking for. Have you tried poking around in cvs.php.net? -ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] automatic responder
On Nov 28, 2004, at 10:38 AM, Alessandro Rosa wrote: Yes, but perhaps every 5 minutes. You have to solve this too, either cron job if you have it available or it can be trigered by user http requests (not very reliable). Thanks again! Yours e-mail fixed some procedural doubts I have been thinking about such automatic responder. Solution might be easy to achieve by implementing, on my own opinion, a Javascript code with a nested 'SetTimeOut' function recursively calling itself every 5 mins (for example) and re-direction to a php code performing the POP3 mailbox checking. (obviously the php code shall include ECHOes to the timing Javascript code again...) This seems like a very weak re-implementation of cron. Seriously, this problem has been solved. -ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Very fresh to php
On Nov 30, 2004, at 10:45 PM, suneel wrote: Hi...guys, I'm a new bee to php. Could any one tell me that who is the father of php? take care guys, That would be Rasmus Lerdorf - http://php.net/history -ryan - http://theryanking.com/blog -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with code
On Dec 5, 2004, at 9:05 PM, Richard Kurth wrote: I am having a problem with the code below it provides the first page with out any problem but when I select the next page it shows all the results from the first page and the results from the second page. It does the same thing on the third page also. I have been looking at it for two days and can not fined the error in the code I don't see where you set $page. And I'm betting that you don't. Variables are not persistent from one page-load to the next. try adding this line in here: $page = $_GET['page']; // If current page number, use it // if not, set one! if(!isset($page)){ $page = 1; } else { $page = $page; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PEAR performance/overhead
On Dec 7, 2004, at 12:34 PM, David Dickson wrote: I was told that PEAR has too much overhead to be considered for a large scale site. Does any one feel the same? Is this an outrageous comment? I would like to hear comments from people who are using PEAR, or people who have considered PEAR but decided not to use it and your reasons. The packages I am particularly interested in are HTML_QuickForm and DB. I think that when most people say PEAR has big overhead they're referring to the parsing work that must be done. Under a plain PHP implementation it can be quite expensive to re-parse those two packages for every request. However, if you are concerned with performance on your site you should be using a compiler so that this does not occur. A php compiler will easily improve your site's performance by an order of magnitude. -ryan -- http://theryanking.com/blog -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple Inheritance
On Dec 10, 2004, at 4:17 PM, Greg Beaver wrote: The biggest hogs in php programming are: 1) unnecessary images and animated crap/unnecessary javascript 2) terrible database usage 3) too much complexity in the design I would like to add 0) Compilation. Many scripts take longer to compile than execute. Adding a byte-code compiler will often increase performance by an order of magnitude. It doesn't matter whether you are using OO or functions - if your application has too many lines of code per task, it won't be fast. -ryan -- http://theryanking.com/blog -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple Inheritance
On Dec 10, 2004, at 3:50 PM, Greg Donald wrote: On Fri, 10 Dec 2004 10:32:30 -0800 (PST), Richard Lynch <[EMAIL PROTECTED]> wrote: What I do is not use classes. I agree. Some of the worst arguments for OO I've heard recently: "OO programming lets you organize your code better." So what you're saying is that you're not capable of organizing similar functions into files and directories and using include() or require() as needed? Just because someone thinks using OOP is better doesn't mean they don't think procedural programming is insufficient. "OO programming lets lots of developers work on the same code base easier." Malarkey[1]. The Linux Kernel crew gets along fine with no OO code. Hundreds of thousands (millions?) of lines of code with thousands of developers contributing daily. A good revision control system is all you need. Yeah, but in the case of the Linux kernel there's no programming language that is both OO and close enough to the metal to program a kernel (other than maybe Forth??). In other words, OOP is not a good option for a kernel. That means that we can't make a judgment as to the relative merits of procedural and object-based programming in kernel development. "Using OO programming is more efficient" Where are your benchmarks? Then you have scenarios where you have to come behind coders who think they know OO, but they make poorly designed classes and end up calling lots of functions statically like Object::foo().. which totally defeats the purpose of objects along the way. Now this certainly isn't an argument against OOP, but bad programming. I don't think anyone is going to argue for bad programming (unless they really like COBOL :-). Also, on the subject of static function calls, in my mind its the closest PHP will ever get to having namespaces and preventing function name collisions. At all. And then you run into real life. I'm working at a place right now where they love OO programming. We use Mojavi, PEAR, and Smarty everywhere. I understand OO pretty well I think, and I'm studying the latest Mojavi framework. Hopefully I'll be ahead of the curve on the next project later down the road. I don't really enjoy OO programming and I don't think I'd ever code one of my own projects with it, but I will go grab a PEAR module if it fits my needs. Code re-use may be the only redeeming quality of OO programming, and honestly I can re-use your code from a non-OO include file just as easily. Code reuse is a major reason for OOP. Obviously you believe that it is no better than old-fashioned procedural programming. I'm not going to disagree with you. Either approach is definitely doable. It is also possible to fuck up either approach. It just doesn't make sense to instantiate objects for a script whose total execution lifetime is less than a second or two. The overhead just isn't worth it. This is a good point. There are many times where it doesn't make sense. However, PHP5 is much better at this that PHP4 is. I think there's a major point missing here. OOP is just another way of providing abstractions to the programmer. Everything above machine-code is an abstraction of some sort and language designers try to provide abstractions which allow programmers to work better. Objects are abstractions, functions are abstractions, even variables are abstractions. Why do we need abstractions? Because it helps us comprehend systems more easily. If we can only hold some many thoughts in our mind at once, it is advantageous to have high-order (more abstract) ideas, rather than lower-level ideas. Just my $.02, -ryan -- http://theryanking.com/blog -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] assignment
On Dec 9, 2004, at 10:02 PM, Song Ken Vern wrote: Hi, Tried searching for what this $$ operator means. But can't get the right results by using $$ as search string in php manual. $temp = $$temp2; Is this an array assignment? No, its a variable varible: http://us2.php.net/manual/en/language.variables.variable.php -ryan -- http://theryanking.com/blog -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I got the mail form blues! HTML/POST/mail() question - Also request for style suggestions
On Dec 16, 2004, at 10:02 PM, Monique Verrier wrote: Hi! I have an html string stored in $message. I "submit" the form to a subroutine and the value in $message is lost. All the other variables come into feedback.php just fine. I would love any help. This is a new language for me so any suggestions for streamlining my code would also be much appreciated. Thanks -- Monique. Here's my code: $message=getmsg($message,$recemail,$sendername,$mailmessage,$rsList,$rn ame); mysql_free_result($rsList); echo $message; // this displays perfectly ?> ?>"> value="Name,Email,Subject,Updates,Message"> should be -ryan -- http://theryanking.com/blog -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php