php-general Digest 6 Oct 2007 17:41:37 -0000 Issue 5058
php-general Digest 6 Oct 2007 17:41:37 - Issue 5058 Topics (messages 262861 through 262873): Re: [PHP-DB] Re: MySQL Identifying worst-performing codes 262861 by: Lasitha Alawatta Php session settings 262862 by: Jeff Benetti 262863 by: Nathan Nobbe 262865 by: Jeff Benetti 262866 by: Tom Friedhof 262868 by: Jeff Benetti Re: Beginner Tutorials for using CLASSES in PHP4 262864 by: Nathan Nobbe 262867 by: Tony Marston 262869 by: Robert Cummings Re: Empty Array? 262870 by: tedd Re: error messages 262871 by: tedd Re: A two flavored post 262872 by: tedd 262873 by: tedd Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- Dear Col, I'm highly appreciate your reply. Best Regards, Lasitha -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Colin Guthrie Sent: Thursday, October 04, 2007 7:47 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: [PHP-DB] Re: MySQL Identifying worst-performing codes Lasitha Alawatta wrote: There is a tool call “idera” (SQL diagnostic manager). Basically it is a performance monitoring and diagnostics tool. It has a feature; Identifying of worst-performing codes – Identifies performance bottlenecks such as the worst-performing stored procedures, long-running queries, most frequently run queries, SQL Statements and SQL batches You can just turn on the MySQL option log slow queries and it logs them for you. Make those more efficient and you've already taken care of a lot of the low hanging fruit for db optimisation. Col. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php DOTW DISCLAIMER: This e-mail and any attachments are strictly confidential and intended for the addressee only. If you are not the named addressee you must not disclose, copy or take any action in reliance of this transmission and you should notify us as soon as possible. If you have received it in error, please contact the message sender immediately. This e-mail and any attachments are believed to be free from viruses but it is your responsibility to carry out all necessary virus checks and DOTW accepts no liability in connection therewith. This e-mail and all other electronic (including voice) communications from the sender's company are for informational purposes only. No such communication is intended by the sender to constitute either an electronic record or an electronic signature or to constitute any agreement by the sender to conduct a transaction by electronic means. ---End Message--- ---BeginMessage--- Hi all, I am new to PHP this is my second post to this group. I have tried using the following CMS systems on my web server (remote) Joomla CMS made simple Phpwebsite And more recently Coppermine photo album All of these apps use PHP heavily. None of these apps seem to run very well and they all require constantly refreshing the browser. When I installed CMS made simple (nice install program) it checked for MySQL database, permissions etc. everything passed the test but it flagged low memory allocation as a possible problem. The install succeeded but the program indicated that performance would be poor or crippled. My hosting service allows me to add a customized php.ini in the same folder as the app. I know nothing about php.ini so I was hoping someone could point me to which of the many settings would be best to tweak. Any help would be much appreciated Thanks, Jeff Quick recap: constantly refreshing browser, could tweak php.ini, total newbie, no hair left to pull out. ---End Message--- ---BeginMessage--- Jeff, is *memory_limit*http://docs.php.net/manual/en/ini.core.php#ini.memory-limitthe one youre looking for ? that sounds strange; im sure the default would be appropriate. i would recommend you create a script to show the current values of the php.ini settings before you start changing them. ?php echo phpinfo(); ? -nathan ---End Message--- ---BeginMessage--- SERVER_SOFTWARE Apache/1.3.34 (Unix) I have attached the output from phpinfo() I cc'd the php-general group but I am not sure how an attachment will be dealt with there. Thanks, Jeff _ From: Nathan Nobbe [mailto:[EMAIL PROTECTED] Sent: October 6, 2007 9:08 AM To: Jeff Benetti Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Php session settings Jeff, is http://docs.php.net/manual/en/ini.core.php#ini.memory-limit memory_limit the one youre looking for ? that sounds strange; im sure the default would be appropriate. i would recommend you create a script to show the current values of the php.ini settings before you start changing
[PHP] RE: [PHP-DB] Re: MySQL Identifying worst-performing codes
Dear Col, I'm highly appreciate your reply. Best Regards, Lasitha -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Colin Guthrie Sent: Thursday, October 04, 2007 7:47 PM To: [EMAIL PROTECTED] Cc: php-general@lists.php.net; [EMAIL PROTECTED] Subject: [PHP-DB] Re: MySQL Identifying worst-performing codes Lasitha Alawatta wrote: There is a tool call “idera” (SQL diagnostic manager). Basically it is a performance monitoring and diagnostics tool. It has a feature; Identifying of worst-performing codes – Identifies performance bottlenecks such as the worst-performing stored procedures, long-running queries, most frequently run queries, SQL Statements and SQL batches You can just turn on the MySQL option log slow queries and it logs them for you. Make those more efficient and you've already taken care of a lot of the low hanging fruit for db optimisation. Col. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php DOTW DISCLAIMER: This e-mail and any attachments are strictly confidential and intended for the addressee only. If you are not the named addressee you must not disclose, copy or take any action in reliance of this transmission and you should notify us as soon as possible. If you have received it in error, please contact the message sender immediately. This e-mail and any attachments are believed to be free from viruses but it is your responsibility to carry out all necessary virus checks and DOTW accepts no liability in connection therewith. This e-mail and all other electronic (including voice) communications from the sender's company are for informational purposes only. No such communication is intended by the sender to constitute either an electronic record or an electronic signature or to constitute any agreement by the sender to conduct a transaction by electronic means.
[PHP] Php session settings
Hi all, I am new to PHP this is my second post to this group. I have tried using the following CMS systems on my web server (remote) Joomla CMS made simple Phpwebsite And more recently Coppermine photo album All of these apps use PHP heavily. None of these apps seem to run very well and they all require constantly refreshing the browser. When I installed CMS made simple (nice install program) it checked for MySQL database, permissions etc. everything passed the test but it flagged low memory allocation as a possible problem. The install succeeded but the program indicated that performance would be poor or crippled. My hosting service allows me to add a customized php.ini in the same folder as the app. I know nothing about php.ini so I was hoping someone could point me to which of the many settings would be best to tweak. Any help would be much appreciated Thanks, Jeff Quick recap: constantly refreshing browser, could tweak php.ini, total newbie, no hair left to pull out. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php session settings
Jeff, is *memory_limit*http://docs.php.net/manual/en/ini.core.php#ini.memory-limitthe one youre looking for ? that sounds strange; im sure the default would be appropriate. i would recommend you create a script to show the current values of the php.ini settings before you start changing them. ?php echo phpinfo(); ? -nathan
Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
On 10/3/07, Tony Marston [EMAIL PROTECTED] wrote: Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 10/3/07, Tony Marston [EMAIL PROTECTED] wrote: Encapsulation is NOT data hiding. Take a look at please stop putting words into my mouth. i never once said encapsulation is data hiding. I stated PublicPrivateProctected facilitates encapsulation. The dictionary definition of facilitate is to make easier or better. Data and methods are either contained within the same capsule or they are not. There are no intermediate levels of encapsulation. Data hiding has absolutely no effect on encapsulation. Hiding data does not make encapsulation better, and not hiding data does not make encapsulation worse. Encapsulation and data hidng are NOT connected in any way. You can have encapsulation without data hiding, and you can have data hiding without encapsulation. i will now be strengthening my previous statements and issuing the new statement; information hiding is an integral part of encapsulation. here are excerpts from 4 books, 2 on java, one on c++, and one on php: This abstraction works only if we are careful to respect its boundaries. An object should be self-governing, which means that the variables contained in an object should be modified only within the object. Only the methods within an object should have access to the variables in that object. For example, the methods of the Coin class should be solely responsible for changing the value of the face variable. We should make it difficult, if not impossible, for code outside of a class to reach in and change the value of a variable that is declared inside the class. Page 220. - 221 Java Software Solutions foundations of program design 3rd edition Lewis Loftus The specification of what a function does and how it is invoked defines its interface. By hiding a module implementation, or encapsulating the module, we can make changes to it without changing the main function, as long as the interface remains the same. For example, you might rewrite the body of a function using a more efficient algorithm. Encpasulation: Hiding a module implementation in a separate block with a formally specified interface. Page 354 Programming and Problem Solving with C++ Second Edition Nell Dale, Chip Weems, Mark Headington OOP revolves around the concept of grouping code and data together in logical units called classes. This process is usually referred to as encapsulation, or information hiding, since its goal is that of dividing an application into separate entities whose internal components can change without altering their external interfaces. Page 113. Zend PHP5 Certification Study Guide Davey Shafik Access control is often referred to as implementation hiding. Wrapping data and methods within classes in combination with implementation hiding is often called encapsulation4* The result is a data type with characteristics and behaviors. * However, people often refer to implementation hiding alone as encapsulation. Page 231 Thinking in Java Third Edition Bruce Eckel tonight when i get home ill post a snippet from an entry level oop book (such that i recommend earlier) that says almost verbatim what i have. practically any non-trivial class will have member variables that it uses in order to facilitate its member functions. So what? Those variables do not have to be private or protected in order to function. They dont have to be marked private or protected to function, but in order to prevent client code from latching onto the implementation details of the class; they need to be hidden. many of those variables have nothing to do w/ the functionality the class exposes to client code. if those variables are modified directly, because they cant be protected by ppp, then the functionality of the class can be distorted. that is why ppp exists. PPP exists to place restrictions on stupid programmers. It does not add an functionality, or make the code run faster. Run faster, who said anything about that? Given that ive shown examples from 4 books, some with multiple authors, we can either assume there are a lot of stupid programmers out there or your opinion is the less popular of the 2. what you dont seem to understand is the important of stressing the distinction between specification and implementation. maybe youve had the benefit of working with other developers that arent infact stupid; and they know not to access class member variables directly; but the point is that is a very delicate system. stupid, or more likely uneducated developers will go in and latch onto class implementation details which leads to tight coupling, which makes systems a massive pain to extend and maintain. lets be fair though; youve defined encapsulation as grouping variables and methods, and defined data-hiding as a separate concept, fair enough. my criticism of php4, based upon
RE: [PHP] Php session settings
SERVER_SOFTWARE Apache/1.3.34 (Unix) I have attached the output from phpinfo() I cc'd the php-general group but I am not sure how an attachment will be dealt with there. Thanks, Jeff _ From: Nathan Nobbe [mailto:[EMAIL PROTECTED] Sent: October 6, 2007 9:08 AM To: Jeff Benetti Cc: php-general@lists.php.net Subject: Re: [PHP] Php session settings Jeff, is http://docs.php.net/manual/en/ini.core.php#ini.memory-limit memory_limit the one youre looking for ? that sounds strange; im sure the default would be appropriate. i would recommend you create a script to show the current values of the php.ini settings before you start changing them. ?php echo phpinfo(); ? -nathan System FreeBSD cgi20 4.10-RELEASE-p21 FreeBSD 4.10-RELEASE-p21 #0: Mo i386 Build Date Mar 22 2007 23:48:30 Configure Command ./configure --prefix=/usr/local/nf/php5 --exec-prefix=/usr/local/nf/php5 --enable-exif --enable-dbase --enable-mbstring --with-mysql=/usr/local/nf --enable-discard-path --with-config-file-path=/usr/local/nf/php5/etc --with-zlib-dir=/usr/local/nf --with-iconv=/usr/local/nf --with-libxml-dir=/usr/local/nf --with-png-dir=/usr/local/nf --with-jpeg-dir=/usr/local/nf --with-imagick=/usr/local/nf --with-gd --with-curl=/usr/local/nf --with-openssl=/usr/local/nf --without-xpm --without-freetype --with-libxml-dir=/usr/local/nf --with-mcrypt=/usr/local/nf Server API CGI Virtual Directory Support disabled Configuration File (php.ini) Path /usr/local/nf/php5/etc/php.ini PHP API 20041225 PHP Extension 20060613 Zend Extension 220060519 Debug Build no Thread Safety disabled Zend Memory Manager enabled IPv6 Support enabled Registered PHP Streams php, file, data, http, ftp, compress.zlib, https, ftps Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3, sslv2, tls Registered Stream Filters string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, convert.iconv.*, zlib.* This program makes use of the Zend Scripting Language Engine: Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies with the ionCube PHP Loader v3.1.28, Copyright (c) 2002-2007, by ionCube Ltd. PHP Credits Configuration PHP Core Directive Local Value Master Value allow_call_time_pass_reference On On allow_url_fopen On On allow_url_include Off Off always_populate_raw_post_data Off Off arg_separator.input arg_separator.output asp_tags Off Off auto_append_file no value no value auto_globals_jit On On auto_prepend_file no value no value browscap no value no value default_charset no value no value default_mimetype text/html text/html define_syslog_variables Off Off disable_classes no value no value disable_functions no value no value display_errors On On display_startup_errors Off Off doc_root no value no value docref_ext no value no value docref_root no value no value enable_dl On On error_append_string no value no value error_log no value no value error_prepend_string no value no value error_reporting no value no value expose_php On On extension_dir /usr/local/nf/php5/lib/php/extensions/no-debug-non-zts-20060613 /usr/local/nf/php5/lib/php/extensions/no-debug-non-zts-20060613 file_uploads On On highlight.bg #FF #FF highlight.comment #FF8000 #FF8000 highlight.default #BB #BB highlight.html #00 #00 highlight.keyword #007700 #007700 highlight.string #DD #DD html_errors On On ignore_repeated_errors Off Off ignore_repeated_source Off Off ignore_user_abort Off Off implicit_flush Off Off include_path .:/usr/local/nf/php5/lib/php .:/usr/local/nf/php5/lib/php log_errors Off Off log_errors_max_len 1024 1024 magic_quotes_gpc On On magic_quotes_runtime Off Off magic_quotes_sybase Off Off mail.force_extra_parameters no value no value max_execution_time 30 30 max_input_time -1 -1 open_basedir no value no value output_buffering 0 0 output_handler no value no value post_max_size 8M 8M precision 14 14 realpath_cache_size 16K 16K realpath_cache_ttl 120 120 register_argc_argv On On register_globals On On register_long_arrays On On report_memleaks On On report_zend_debug On On safe_mode Off Off safe_mode_exec_dir /usr/local/php/bin /usr/local/php/bin safe_mode_gid Off Off safe_mode_include_dir no value no value sendmail_from no value no value sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i serialize_precision 100 100 short_open_tag On On SMTP localhost localhost smtp_port 25 25 sql.safe_mode Off Off track_errors Off Off unserialize_callback_func no value no value upload_max_filesize 2000 2000 upload_tmp_dir /tmp/ /tmp/ user_dir no value no value variables_order EGPCS EGPCS xmlrpc_error_number 0 0 xmlrpc_errors Off Off y2k_compliance On On
Re: [PHP] Php session settings
I almost always up the memory_limit in the php.ini. Set the memory limit to 16M, or 32M (the default is 8M). You want a higher memory_limit if you're working with big file uploads or creating images with php or anything else that takes a lot of memory. Also, if you're still researching which CMS to use, don't forget to check out Drupal at http://drupal.org. You can learn a lot about PHP by diving into a well written project. The Drupal code is very clean and organized. Tom Friedhof On 10/6/07, Jeff Benetti [EMAIL PROTECTED] wrote: SERVER_SOFTWARE Apache/1.3.34 (Unix) I have attached the output from phpinfo() I cc'd the php-general group but I am not sure how an attachment will be dealt with there. Thanks, Jeff -- *From:* Nathan Nobbe [mailto:[EMAIL PROTECTED] *Sent:* October 6, 2007 9:08 AM *To:* Jeff Benetti *Cc:* php-general@lists.php.net *Subject:* Re: [PHP] Php session settings Jeff, is *memory_limit* http://docs.php.net/manual/en/ini.core.php#ini.memory-limitthe one youre looking for ? that sounds strange; im sure the default would be appropriate. i would recommend you create a script to show the current values of the php.ini settings before you start changing them. ?php echo phpinfo(); ? -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 10/3/07, Tony Marston [EMAIL PROTECTED] wrote: Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 10/3/07, Tony Marston [EMAIL PROTECTED] wrote: Encapsulation is NOT data hiding. Take a look at please stop putting words into my mouth. i never once said encapsulation is data hiding. I stated PublicPrivateProctected facilitates encapsulation. The dictionary definition of facilitate is to make easier or better. Data and methods are either contained within the same capsule or they are not. There are no intermediate levels of encapsulation. Data hiding has absolutely no effect on encapsulation. Hiding data does not make encapsulation better, and not hiding data does not make encapsulation worse. Encapsulation and data hidng are NOT connected in any way. You can have encapsulation without data hiding, and you can have data hiding without encapsulation. i will now be strengthening my previous statements and issuing the new statement; information hiding is an integral part of encapsulation. Encapsulation and information hiding are separate topics. It is possible to have one without the other. here are excerpts from 4 books, 2 on java, one on c++, and one on php: This abstraction works only if we are careful to respect its boundaries. An object should be self-governing, which means that the variables contained in an object should be modified only within the object. Only the methods within an object should have access to the variables in that object. The principle of encapsulation has no such rule! Encapsulation is merely the act of placing variables and the methods which act upon those variables in the same object. It is not necessary to hide any variables. Encapsulation is NOT data hiding. Take a look at http://www.javaworld.com/javaworld/jw-05-2001/jw-0518-encapsulation.html http://www.itmweb.com/essay550.htm http://c2.com/cgi/wiki?EncapsulationIsNotInformationHiding For example, the methods of the Coin class should be solely responsible for changing the value of the face variable. We should make it difficult, if not impossible, for code outside of a class to reach in and change the value of a variable that is declared inside the class. Page 220. - 221 Java Software Solutions foundations of program design 3rd edition Lewis Loftus The specification of what a function does and how it is invoked defines its interface. By hiding a module implementation, or encapsulating the module, we can make changes to it without changing the main function, as long as the interface remains the same. For example, you might rewrite the body of a function using a more efficient algorithm. Encpasulation: Hiding a module implementation in a separate block with a formally specified interface. The implementation is the CODE behind the method, not the DATA that the code manipulates. Encapsulation is IMPLEMENTATION hiding, not DATA hiding. Page 354 Programming and Problem Solving with C++ Second Edition Nell Dale, Chip Weems, Mark Headington OOP revolves around the concept of grouping code and data together in logical units called classes. This process is usually referred to as encapsulation, Correct. or information hiding, INCORRECT since its goal is that of dividing an application into separate entities whose internal components can change without altering their external interfaces. No. The idea behind encapsulation is that the implementation, the code behind a method, can change at any time without the outside world being aware of it. Data is *NOT* the implemetation. Page 113. Zend PHP5 Certification Study Guide Davey Shafik Access control is often referred to as implementation hiding. But wrongly! Access control is NOT implementation hiding, it is a totally separate issue. Wrapping data and methods within classes in combination with implementation hiding is often called encapsulation4* That is correct. But only the implementation (the code behnd each method) is hidden, not the data. The result is a data type with characteristics and behaviors. * However, people often refer to implementation hiding alone as encapsulation. Page 231 Thinking in Java Third Edition Bruce Eckel tonight when i get home ill post a snippet from an entry level oop book (such that i recommend earlier) that says almost verbatim what i have. practically any non-trivial class will have member variables that it uses in order to facilitate its member functions. So what? Those variables do not have to be private or protected in order to function. They dont have to be marked private or protected to function, but in order to prevent client code from latching onto the implementation details of the class; they need to be hidden. Wrong! DATA does not define the implementation, it is the CODE which
RE: [PHP] Php session settings
Thanks, I added a one line file called php.ini with the following line memory_limit = 16M so far CMS made simple seems to run better (faster, no need for page refresh) Yes I will check out drupal Jeff _ From: Tom Friedhof [mailto:[EMAIL PROTECTED] Sent: October 6, 2007 11:18 AM To: Jeff Benetti Cc: php-general@lists.php.net Subject: Re: [PHP] Php session settings I almost always up the memory_limit in the php.ini. Set the memory limit to 16M, or 32M (the default is 8M). You want a higher memory_limit if you're working with big file uploads or creating images with php or anything else that takes a lot of memory. Also, if you're still researching which CMS to use, don't forget to check out Drupal at http://drupal.org. You can learn a lot about PHP by diving into a well written project. The Drupal code is very clean and organized. Tom Friedhof On 10/6/07, Jeff Benetti [EMAIL PROTECTED] wrote: SERVER_SOFTWARE Apache/1.3.34 (Unix) I have attached the output from phpinfo() I cc'd the php-general group but I am not sure how an attachment will be dealt with there. Thanks, Jeff _ From: Nathan Nobbe [mailto:[EMAIL PROTECTED] Sent: October 6, 2007 9:08 AM To: Jeff Benetti Cc: php-general@lists.php.net Subject: Re: [PHP] Php session settings Jeff, is http://docs.php.net/manual/en/ini.core.php#ini.memory-limit memory_limit the one youre looking for ? that sounds strange; im sure the default would be appropriate. i would recommend you create a script to show the current values of the php.ini settings before you start changing them. ?php echo phpinfo(); ? -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
On Sat, 2007-10-06 at 15:42 +0100, Tony Marston wrote: OOP revolves around the concept of grouping code and data together in logical units called classes. This process is usually referred to as encapsulation, Correct. or information hiding, INCORRECT since its goal is that of dividing an application into separate entities whose internal components can change without altering their external interfaces. No. The idea behind encapsulation is that the implementation, the code behind a method, can change at any time without the outside world being aware of it. Data is *NOT* the implemetation. Tony is right here. Encapsulation is about hiding the details of the implementation and this *can* include information hiding in cases where the purpose of the member variables is likely to change. However, encapsulation does not necessarily imply information hiding. That said information hiding is often achieved using private members and encapsulation. There is a strong relationship between the two, but they are not the same thing. Also, don't forget that abstraction, encapsulation, and information hiding all have a price. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Empty Array?
At 10:33 AM -0400 10/5/07, marek wrote: Even better: ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; SQL injection? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error messages
At 10:27 PM +0200 10/5/07, Zoltán Németh wrote: 2007. 10. 5, péntek keltezéssel 12.57-kor tedd ezt írta: I long for the time where my editor said Offending syntax on line 236. my editor still says parse error and shows me the line number... ;) greets Zoltán Németh Consider yourself lucky, or me unfortunate. :-) All my development is spent online -- the browser god is not forgiving. One of these days I'll get the Zend IDE to work. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
At 12:58 PM -0400 10/5/07, Daniel Brown wrote: ? $s = $_GET['s']; ? script language=JavaScript function writeHREF(value,title) { var url = http://www.crusar.org/test.php;; var currentTime = new Date(); var month = currentTime.getMonth(); var day = currentTime.getDate(); var year = currentTime.getFullYear(); var jsvalue = month + '/' + day + '/' + year; document.write('a href=' + url + '?s=' + value + 'jsvalue=' + jsvalue + '' + title + '/a'); } /script This is where your JS link will appear, Tedd: script language=JavaScript writeHREF('?=$s;?','Test Link'); /script Daniel That's slick. I solved the problem by using: a href=img.php?i=?php echo($value);? onclick=window.location = this.getAttribute( 'href' ) + 's=' + s; return false; But, I am sure I will be using your's sometime soon. Thanks, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
At 1:26 PM -0400 10/5/07, Nathan Nobbe wrote: strange; i missed that when i put it together; my bad, it was late. here is a revision that works. html head script type=text/javascript window.onload = function() { var someLink = document.getElementById('someLink'); someLink.href += anotherVar=8; alert(document.getElementById('someLink').href); } /script /head body a id=someLink href= http://somesite.com?a=5; click here /a /body /html the problem was the local variable was being assigned the value of the attribute, not the reference to the tag in the dom. i have now set it to be a reference to the variable in the dom. -nathan: Not that I provided information otherwise, but document.getElementById won't work in this case because there are several links involved. As such, I have to use document.getElementByClass and that has problems. Unfortunately, my solution isn't unobtrusive. a href=img.php?i=?php echo($value);? onclick=window.location = this.getAttribute( 'href' ) + 's=' + s; return false; However, I couldn't see a way to make it so. Many thanks for your time and effort. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
On Sat, 2007-10-06 at 13:41 -0400, tedd wrote: At 1:26 PM -0400 10/5/07, Nathan Nobbe wrote: strange; i missed that when i put it together; my bad, it was late. here is a revision that works. html head script type=text/javascript window.onload = function() { var someLink = document.getElementById('someLink'); someLink.href += anotherVar=8; alert(document.getElementById('someLink').href); } /script /head body a id=someLink href= http://somesite.com?a=5; click here /a /body /html the problem was the local variable was being assigned the value of the attribute, not the reference to the tag in the dom. i have now set it to be a reference to the variable in the dom. -nathan: Not that I provided information otherwise, but document.getElementById won't work in this case because there are several links involved. As such, I have to use document.getElementByClass and that has problems. Unfortunately, my solution isn't unobtrusive. a href=img.php?i=?php echo($value);? onclick=window.location = this.getAttribute( 'href' ) + 's=' + s; return false; However, I couldn't see a way to make it so. Why not? I'm guessing because you need to the link to have the JavaScript variable in it. If this is the case then the href target should link to a page informing the user that they need to have JavaScript installed. By doing so you inform them of why clicking on the link is not having the desired outcome :) Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sending lots of emails - 2 choices - choose the best one
Hello-- I want to send email to 100+ recipients. Two choices I thought of: 1) once call mail() and use BCC, but the negative of this method is that every recipient in BCC has header To same (so I used to put my email in here - not email of one of the recipients). 2) several calls to mail() function with each recipient's emal Thanks for ideas, --Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mySQL Results To XML
Hi, Here's the mission, creating a movie DB, I need the results returned from mySQL in an XML format for use with the FLASH Professional DataGrid. Any tips on formating mySQL results would be grand. Here's the structure of the DB, if needed. DVD Table *Title ID *Title *Genre *Actor *Director *Producer *Date Purchased *Price *Date Released *Length *Plot *Review(*) *Rating person table *Producer ID *First Name *Last Name *Director ID *First Name *Last Name Actors_Link actor_link_id just a primary auto-increment number person_id movie_id role_id
[PHP] mySQL Results To XML
Hi, Here's the mission, creating a movie DB, I need the results returned from mySQL in an XML format for use with the FLASH Professional DataGrid. Any tips on formating mySQL results would be grand. Here's the structure of the DB, if needed. DVD Table *Title ID *Title *Genre *Actor *Director *Producer *Date Purchased *Price *Date Released *Length *Plot *Review(*) *Rating person table *Producer ID *First Name *Last Name *Director ID *First Name *Last Name Actors_Link actor_link_id just a primary auto-increment number person_id movie_id role_id
Re: [PHP] mySQL Results To XML
On 10/6/07, CK [EMAIL PROTECTED] wrote: Hi, Here's the mission, creating a movie DB, I need the results returned from mySQL in an XML format for use with the FLASH Professional DataGrid. Any tips on formating mySQL results would be grand. Here's the structure of the DB, if needed. you could easily just print the xml manually. dvd titleIDfoo/titleID baretc/bar /dvd or, i believe mysql will return XML output but i'm not sure a PHP function exists to do that. no need to use fancy DOM functions, outputting XML is easy, parsing it is when you need to use the special functions and such. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mySQL Results To XML -- my xmltag() functions
-Original Message- you could easily just print the xml manually. dvd titleIDfoo/titleID baretc/bar /dvd or, i believe mysql will return XML output but i'm not sure a PHP function exists to do that. no need to use fancy DOM functions, outputting XML is easy, parsing it is when you need to use the special functions and such. Here's the 'functions_xml.inc.php' file I use, it has served me well and handles I believe all tag cases, personally I'm a big fan of using the attributes as they're most easily parsed out in the PHP DOM functions: 8-- --- ?php /** * Aborts XML output with an Error message * * @return string xml formatted tags and data * @paramstring $message the error message to output * @version 1.3 * @date 07/14/05 */ function XML_exit($message) { header( Content-type: text/xml ); print ?xml version=\1.0\ encoding=\utf-8\ ?\n; //TODO: [dv] we should probably put an error code so that it's easier for the scripts to parse //print xmltag('error', array('code'='TBD', 'string'=$message)); print xmltag('error',null, 1); print xmltag('code','TBD'); print xmltag('string',$message); print xmltag('error',null, 2); exit; } /** * Returns a well formed lowercase XML tag string suitable for printing to screen * * tagType=1: is like tagType=3, but without the / * tagType=2: is the closing /xmltag only. * * tagType=3: * xmltag foo=bar / * * also note that array('foo'='bar','__VALUE'='1234') will generate: * xmltag foo=bar1234/xmltag * * tagType=4: * xmltag * foobar/foo * /xmltag * * @return string xml formatted tags and data * @paramstring $xmltag is the tag name to surround * @parammixed $data data to output between the tags, if $data is an array, it will be expanded as KEY=VALUE in the tag. If there is an array element __VALUE that will be a value between XML tags after the list of attributes * @paramint $tagType 1=start tag only, 2=end tag only, 3=default, 4=verbose tag * @todo use recursion to get nested arrays working, especially for tagType=4 * @version 1.6 * @date 01/16/06 */ function xmltag($xmltag, $data, $tagType = 3) { // convert spaces to underscores and makes it lowercase as per XML specification $xmltag = strtolower(str_replace(' ','_', $xmltag )); // encode all characters that need to be converted for export into XML $data = xmlentities($data); //we put this first, as it is used most frequently if ($tagType == 3) { if (isset($data)) { if (is_array($data)) { if (isset($data['__VALUE'])) { $value_data = $data['__VALUE']; unset($data['__VALUE']); } $tmp = ''.$xmltag; foreach($data as $key = $value) { if ( is_bool($value) ) $value = ($value === true)?'true':'false'; $tmp .= ' '.$key.'='.$value.''; } if (isset($value_data)) { if ( is_bool($value_data) ) $value_data = ($value_data === true)?'true':'false'; $tmp .= .$value_data./.$xmltag.\r\n; } else $tmp .= /\r\n; return $tmp; } else { if ( is_bool($data) ) $data = ($data === true)?'true':'false'; return ''.$xmltag.''.$data.'/'.$xmltag.\r\n; } } else return ''.$xmltag. /\r\n; } //tag type 3 if ($tagType == 1) { $tmp = ''.$xmltag; if (is_array($data)) { foreach($data as $key = $value) { if ( is_bool($value) ) $value = ($value === true)?'true':'false'; $tmp .= ' '.$key.'='.$value.''; } } $tmp .= \r\n;
RE: [PHP] Sending lots of emails - 2 choices - choose the best one
Option 3) setup a dedicated program to handle the mail, such as mailman and then send ONE email from PHP to the listserver which will then dispatch the mail accordingly, properly, in batches. http://www.gnu.org/software/mailman/index.html (at least, that's how I do it currently) -Original Message- From: Martin Zvarík [mailto:[EMAIL PROTECTED] Sent: Saturday, October 06, 2007 11:13 AM To: php-general@lists.php.net Subject: [PHP] Sending lots of emails - 2 choices - choose the best one Hello-- I want to send email to 100+ recipients. Two choices I thought of: 1) once call mail() and use BCC, but the negative of this method is that every recipient in BCC has header To same (so I used to put my email in here - not email of one of the recipients). 2) several calls to mail() function with each recipient's emal Thanks for ideas, --Martin -- 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] mySQL Results To XML -- my xmltag() functions
On 10/6/07, Daevid Vincent [EMAIL PROTECTED] wrote: Here's the 'functions_xml.inc.php' file I use, it has served me well and handles I believe all tag cases, personally I'm a big fan of using the attributes as they're most easily parsed out in the PHP DOM functions: I made this at one point: function array2xml($array, $complete = true) { $xml = $array[NODE] ; unset($array['NODE']); ksort($array); foreach(array_keys($array) as $key) { $xml .= $key=\$array[$key]\ ; } if($complete) { $xml .= /; } $xml .= ; return $xml; } it takes an associative array with a key of NODE for the node name and makes it a single xml node with all the content in attributes. it even alphabetizes the attributes. special preparing of the data (like htmlspecialchars()) might be needed to ensure XML compliance. i made one to translate it into nodes, but i think at the time i read that attribute parsing is quicker. calling it looks like this: $context['NODE'] = context-info; $context['current-datetime'] = format_time_xml(time(),UTC); $context['current-hostname'] = $_SERVER['HTTP_HOST']; $context['current-page'] = $_SERVER['PHP_SELF']; $xml = array2xml($context); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Sending lots of emails - 2 choices - choose the best one
Martin Zvarík wrote: Hello-- I want to send email to 100+ recipients. Two choices I thought of: 1) once call mail() and use BCC, but the negative of this method is that every recipient in BCC has header To same (so I used to put my email in here - not email of one of the recipients). 2) several calls to mail() function with each recipient's emal I like #2, within a loop. E.g., // variables defined: $subject = 'My weekly newsletter'; $headers = [your mail headers here] $message = Blah blah \n . and furthermore yada yada \n . and finally so on; while ( $record = mysql_query('SELECT email from clients etc') ) { $to = $record[email]; mail($to, $subject, $message, $headers); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Something you can do with AJAX + PHP as well
Hey, I've made a nice video where you see ajax in combination with php. and it works really well although really is misspelled realy. Here is the video: http://magedb.mageprojects.com/videos/MageDB%202nd%20WIP%20demonstration%20with%20AJAX.mpeg Cool huh? Mark. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mySQL Results To XML -- my xmltag() functions
posted mailed mike wrote: I made this at one point: function array2xml($array, $complete = true) { $xml = $array[NODE] ; unset($array['NODE']); ksort($array); foreach(array_keys($array) as $key) { $xml .= $key=\$array[$key]\ ; } if($complete) { $xml .= /; } $xml .= ; return $xml; } What about the reverse - converting the XML back to MySQL? (I'm interested for an address book project, but don't know too much of XML or mySQL!) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Handling profile view counters
Hi all, I'm contemplating on a proper way of handling a counter for profile views on my auto dealership website. I'm currently confused with the type of algorithm to approach this with. Say a user has a registered session, and views profile a). I can increment the counter for that vehicle. The user can then surf vehicles b,c,dN etc and I'll increment the counter. However, if the same session tries to visit profile a,b,c,d should I not increment the counter? How would you all do it? Any examples with code would be very insightful and appreciated. Thank you kindly. - sf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
At 1:49 PM -0400 10/6/07, Robert Cummings wrote: On Sat, 2007-10-06 at 13:41 -0400, tedd wrote: Unfortunately, my solution isn't unobtrusive. a href=img.php?i=?php echo($value);? onclick=window.location = this.getAttribute( 'href' ) + 's=' + s; return false; However, I couldn't see a way to make it so. Why not? I'm guessing because you need to the link to have the JavaScript variable in it. If this is the case then the href target should link to a page informing the user that they need to have JavaScript installed. By doing so you inform them of why clicking on the link is not having the desired outcome :) Cheers, Rob. Rob: I would agree with you IF I was creating a web page for the general public. However, what I am creating in my laboratory is a monster of my own making that will be used only by my clients AND those clients will be required to have javascript turned on. Sometimes, programming for the lowest common denominator limits possibilities. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
ALSO: a href=img.php?i=?php echo($value);? onclick=window.location = this.getAttribute( 'href' ) + 's=' + s; return false; can be altered to be: a href=img.php?i=?php echo($value);? onclick=this.setAttribute(this.getAttribute( 'href') + 's=' + s); What exactly do you need to do, anyways? Maybe there'll be some better way to do this. On 10/6/07, tedd [EMAIL PROTECTED] wrote: At 1:49 PM -0400 10/6/07, Robert Cummings wrote: On Sat, 2007-10-06 at 13:41 -0400, tedd wrote: Unfortunately, my solution isn't unobtrusive. a href=img.php?i=?php echo($value);? onclick=window.location = this.getAttribute( 'href' ) + 's=' + s; return false; However, I couldn't see a way to make it so. Why not? I'm guessing because you need to the link to have the JavaScript variable in it. If this is the case then the href target should link to a page informing the user that they need to have JavaScript installed. By doing so you inform them of why clicking on the link is not having the desired outcome :) Cheers, Rob. Rob: I would agree with you IF I was creating a web page for the general public. However, what I am creating in my laboratory is a monster of my own making that will be used only by my clients AND those clients will be required to have javascript turned on. Sometimes, programming for the lowest common denominator limits possibilities. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- 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] Beginner Tutorials for using CLASSES in PHP4
On 10/6/07, Robert Cummings [EMAIL PROTECTED] wrote: Tony is right here. Encapsulation is about hiding the details of the implementation rob, here is tonys definition of encapsulation: Encapsulation is the act of placing data and the operations that perform on that data in the same class. The data does not have to be private at all. tony did not at any point say that encapsulation is about hiding implementation details. im the one who indicated encapsulation is about hiding implementation details. tonys definition is contrary to all the definitions i have pulled from books on object oriented programming (see last post). actually, its not contrary, but it is only part of the definition. encapsulation is infact about hiding implementation details; its about driving client code through a well defined interface, to get access to the behavior the class supplies. in order to implement this behavior there are often times variables *and* methods that client code should not have access to. i pointed out that classes that do not utilize ppp allow client code to become dependent upon their implementation. because weve only been stressing the hiding of member variables (i guess thats what data hiding means) in this conversation i think we have glossed over the fact that it is also important to be able to hide certain member functions as well. this cannot be done in php4, and as i said can lead to systems where client code is made dependent upon the implementation of other classes, which leads to very delicate systems. you guys are not the only php4 advocates ive run into; it just so happens i have a good friend with a very strong php background who tells me practically the same thing, ppp isnt that big of a deal. i disagree, why, is it because ive had a classical education in oop, because ive worked with a number of languages that dont allow you to create class members without specifying an access level? for those reasons and because ive had the misfortune of working in places that have tightly coupled code. im talking about hundreds of thousands of lines of madness. ppp could have saved these systems greatly. Also, don't forget that abstraction, encapsulation, and information hiding all have a price. if youre referring to performance i think the price of not using these tools is also worth mention. namely code which is easily subject to tight coupling, which as i said leads to systems that are difficult to maintain and extend. personally i value maintainability and extensibility over performance, but thats merely a personal preference. (tony) I strongly disagree. It *IS* possible to write perfectly adequate OO programs using PHP 4. If you cannot then you have been taught some bad habits. and what exactly does adequate mean? any oo php4 'program' is inherently weak for the reasons i have sighted, namely the implementation can be latched onto producing tightly coupled code. dont worry tony, i can construe some pretty decent php4 code myself; i wrote a date time package that ive ported to 3 projects including a conversion to php5 in one of those. the point is that the other developers i work with dont have a clue about object oriented concepts which in my experience constitutes the vast majority of php developers. the even bigger point, on the topic of this thread is that php4 is out the door, so there is yet another possibly more important reason not to waste time learning oop studying php4. ive studied oop for years and worked with a number of oop languages; many of the bad habits i had at one point or another have been removed. guess what the first one was, not letting client code access member variables directly :) if you dont mind brittle oop code, php4 will suffice. if you want to tap into real object oriented features, many of which i consider fundamental (such as ppp [to name just one]) go for php5. truthfully i still think there are some features missing; interface hierarchies being the main one, perhaps well get lucky in php6... -nathan