[PHP] class constructor polymorphism
Hi to all, I'm a C++ programmer and I've to convert some simple classes from C++ to PHP. My toolbar_button class must have two or more constructors so I ask you if this is possible with PHP: class toolbar_button { CString m_name, m_tooltip, m_image, m_action; bool m_state, m_is_separator; toolbar_button(void) { /* my code here */ }; toolbar_button(AnsiString name, bool state) { /* my code here */ }; toolbar_button(toolbar_button *abutton) { /* my code here */ }; } I'm using PHP 5.0.4 for Windows. Thank you very much Silverio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need help: change a string in a file
Richard, Thanks for the answer. I understand that I can't do it the way I wanted . I have changed my design. Thanks ALL who answered. -Saswat On Apr 7, 2005 8:18 AM, Richard Lynch [EMAIL PROTECTED] wrote: On Wed, April 6, 2005 10:07 am, Saswat Praharaj said: I need some help in searching string in a file. My requirement is to search the string,append something to the string . Write the string back to the file without changing other parts of the file. e.g Suppose I have the following string in a file Set-Cookie: T_COOKIE=127.0.0.1-saswat-9; path=/ The fixed string is Set-Cookie: T_COOKIE=and rest of the string is variable. I would like to change the string 127.0.0.1-saswat-9 to say 127.0.0.1-saswat-9-1234 Problem is, that's *MORE* bytes than are already there. You can't just smush a few more bytes in. You will *HAVE* to write out a new file. But you can read in only the first couple hundred bytes until you find your Set-Cookie: T_COOKIE, and then you write out the stuff before that, write out your new data, then read/write the whole rest of the file. You may also want to consider using, say, awk or sed or whatever from http://php.net/exec -- I don't expect them to be that much faster than PHP, but what do I know? My constraint is : I don't want to read the whole file into a buffer and work on that buffer as the file can be very large , sometimes more than 10 mb. My advantage is : I know that I will get the search string in first 200 bytes of the file , so I just need to read 200 bytes,play with that and write it back (overwriting the first 200 bytes with new 200 some bytes) .. If it's really 200 bytes for 200 bytes, yeah, fopen(..., 'r+') will work. But if you can't squeeze your bytes into the same space as is already there, you can't do that. You might also be able, for the future, to start using: 127.0.0.1-saswat-9-000 and then you'd be able to replace up to and get back something you can easily read/write/format to be meaningful. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] threaded comments
i am developing a comment/discussion board and i want to display the results in a threaded style. so far i have it all working except this one issue: each row has an ID and a parentid, say i have 5 rows: id : 10 most oranges come from florida id : 16 Re: most oranges come from florida (parentid 10) id : 22 - Re: most oranges come from florida (parentid 16) id : 24 - Re: most oranges come from florida (parentid 22) id : 28 Re: most oranges come from florida (parentid 16) i want the rows to know the id directly above itself so for example, row 5 (id 28) will some how know its parentid (16) is not directly above it and is not accociated with the result its above (24) i want to 'highlight' a row when the parent it belongs to is directly above and do nothing if its not. does this make any sense? very confusing nonetheless. hope someone understands. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php wget: Return an empty file
Greetings PHP(eople), I have a wget process that runs to download a file from a web site, however, if no file exists at the location I`m pulsing, how do I get it to abort ? Here is the code : ?php $getfile = 'wget -dv -o log.txt http://www.somesite.co.za/somefile.php'; $get = shell_exec($getfile); ? I looked at filesize(), but if no file is brought back then there is nothing for the function to check. If someone could point me to the right PHP function, or a link somewhere... Regards -- Chris Blake Cell: 082 775 1492 Work: +27 11 782 0840 Fax : +27 11 782 0841 Mail: [EMAIL PROTECTED] I have a very good DENTAL PLAN. Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Multilingual Web application - how to?
Hello list, I need to develop a multilingual web site and I am looking for the best way of handling this task. There are three main issues I know: 1. Storing multilingual data in a database. Possible solutions I know: a. many tables, one per each supported language, e.g. news_en, news_de. b. one table having many columns with translations, e.g. (id, date, text_en, text_de) We use MySQL 4.1 as a back-end. 2. Multilingual HTML templates, possible solutions: a. one generic template for everything, one per each language, like contents_en.tpl.html, contents_de.tpl.html b. many localized templates for each page, e.g news_en.tpl.html, news_de.tpl.html Template engine is Smarty. 3. Storing current language variable, possible solutions: a. inside the URL like /en/news/ b. using cookies c. using sessions Web server is Apache2+mod_rewrite with PHP5 What are pros and cons for each solution? What are other possible solutions for the above issues? Best regards, Denis Gerasimov Outsourcing Services Manager, VEKOS, Ltd. www.vekos.ru -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php wget: Return an empty file [Solved]
On Fri, 2005-04-08 at 09:47, Chris Blake wrote: Greetings PHP(eople), I have a wget process that runs to download a file from a web site, however, if no file exists at the location I`m pulsing, how do I get it to abort ? Here is the code : ?php $getfile = 'wget -dv -o log.txt http://www.somesite.co.za/somefile.php'; $get = shell_exec($getfile); ? I looked at filesize(), but if no file is brought back then there is nothing for the function to check. If someone could point me to the right PHP function, or a link somewhere... No worries, file_exists() was what I was looking for. Regards -- Chris Blake Cell: 082 775 1492 Work: +27 11 782 0840 Fax : +27 11 782 0841 Mail: [EMAIL PROTECTED] When managers hold endless meetings, the programmers write games. When accountants talk of quarterly profits, the development budget is about to be cut. When senior scientists talk blue sky, the clouds are about to roll in. Truly, this is not the Tao of Programming. When managers make commitments, game programs are ignored. When accountants make long-range plans, harmony and order are about to be restored. When senior scientists address the problems at hand, the problems will soon be solved. Truly, this is the Tao of Programming. -- Geoffrey James, The Tao of Programming -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] threaded comments
Sebastian wrote: i am developing a comment/discussion board and i want to display the results in a threaded style. so far i have it all working except this one issue: each row has an ID and a parentid, say i have 5 rows: id : 10 most oranges come from florida id : 16 Re: most oranges come from florida (parentid 10) id : 22 - Re: most oranges come from florida (parentid 16) id : 24 - Re: most oranges come from florida (parentid 22) the indentation in your example is off, 24 should be indented one more right? id : 28 Re: most oranges come from florida (parentid 16) i want the rows to know the id directly above itself so for example, row 5 (id 28) will some how know its parentid (16) is not directly above it and is not accociated with the result its above (24) yes, it will probably involve javascript. also rather than outputting table rows (belonging to a single table) think about outputting as nested DIVs (or ULs.) div id : 10 most oranges come from florida div id : 16 Re: most oranges come from florida (parentid 10) div id : 22 - Re: most oranges come from florida (parentid 16) div id : 24 -- Re: most oranges come from florida (parentid 22) /div id : 28 Re: most oranges come from florida (parentid 16) /div /div /div such a setup would give you a very easy structure to grab/find parents using the DOM/javascript i want to 'highlight' a row when the parent it belongs to is directly above and do nothing if its not. does this make any sense? very confusing nonetheless. hope someone understands. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multilingual Web application - how to?
Denis Gerasimov wrote: Hello list, I need to develop a multilingual web site and I am looking for the best way of handling this task. There are three main issues I know: 1. Storing multilingual data in a database. Possible solutions I know: a. many tables, one per each supported language, e.g. news_en, news_de. b. one table having many columns with translations, e.g. (id, date, text_en, text_de) We use MySQL 4.1 as a back-end. what about 1 table, 3 columns: translatekey (varchar) - string to translate lang- lang code/id/name translation (varchar/text) - translated string 2. Multilingual HTML templates, possible solutions: a. one generic template for everything, one per each language, like contents_en.tpl.html, contents_de.tpl.html b. many localized templates for each page, e.g news_en.tpl.html, news_de.tpl.html Template engine is Smarty. using Smarty I sometimes assign an assoc array of translated strings: $Lang['yes'] = 'yessiree'; $Lang['no'] = 'nocando'; then in Smarty: div class=LangExample 'yes' is {$Lang.yes}, 'no' is {$Lang.no} /div 3. Storing current language variable, possible solutions: a. inside the URL like /en/news/ best in terms of SEO. b. using cookies handy for presistence. c. using sessions provides cleaner URLS. I see no reason to do all 3. Web server is Apache2+mod_rewrite with PHP5 What are pros and cons for each solution? What are other possible solutions for the above issues? Best regards, Denis Gerasimov Outsourcing Services Manager, VEKOS, Ltd. www.vekos.ru -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] threaded comments
-Original Message- From: Sebastian [mailto:[EMAIL PROTECTED] Sent: Thursday, April 07, 2005 10:17 PM i want the rows to know the id directly above itself so for example, row 5 (id 28) will some how know its parentid (16) is not directly above it and is not accociated with the result its above (24) Have a ref in the database, it refereres to the parent. If the ref is NULL, it´s the start thread i want to 'highlight' a row when the parent it belongs to is directly above and do nothing if its not. Set $last_id = $id; in the end of the while and I the start of the while set: if($last_id == $ref) // highlight the line Is that what You are looking for? -- Med venlig hilsen / best regards ComX Networks A/S Kim Madsen Systemudvikler/systemdeveloper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] POST method to php page from php page
Hello all Does anyone know if its possible to post data using the http POST method to another form using php? I know its possible to use: header( Location: somelocation.php? .SIDsomevar=$somevar ); But this uses the GET method any help or pointing me to any relevant documentation would be greatly appreciated. Cheers Bob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Multilingual Web application - how to?
Denis Gerasimov wrote: I need to develop a multilingual web site and I am looking for the best way of handling this task. There are three main issues I know: Mabye consider of using gettext.. http://www.php.net/gettext BTW: why doesn't Smarty support gettext? How can gettext be implemented into Smarty (with simplier syntax)? -thanks, Eli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST method to php page from php page
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bob Pilly wrote: | Hello all Hi, | Does anyone know if its possible to post data using the http POST method | to another form using php? | I know its possible to use: | header( Location: somelocation.php? .SIDsomevar=$somevar ); | But this uses the GET method | any help or pointing me to any relevant documentation would be greatly | appreciated. You can use Curl to post datas to a remote script. http://www.php.net/curl Regards, Aurélien -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFCVk1s2e0VO2fZtNYRAo/jAKC+rteA24gR9RvJSGu4VFm2F6btAQCfYvLT cX6YCT49OEI+pR3iShAlk20= =X2ll -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST method to php page from php page
Aurélien Cabezon wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bob Pilly wrote: | Hello all Hi, | Does anyone know if its possible to post data using the http POST method | to another form using php? | I know its possible to use: | header( Location: somelocation.php? .SIDsomevar=$somevar ); | But this uses the GET method | any help or pointing me to any relevant documentation would be greatly | appreciated. You can use Curl to post datas to a remote script. http://www.php.net/curl Regards, Aurélien also, I think Bob is a tad confused about what header does exactly. Because header() adds lines to the RESPONSE-header, not the REQUEST-header. The REQUEST header can send its request as a GET/POST/PUT/whatever, while the response header doesn't do anything even remotely like that. Basically, the 'Location'-response-header tells the browser that the file can be found at a different location, so the browser redirects there automatically. This is *not* a GET! Since you've added your query to the URL and browsers, by default, use the GET method of requesting data, the URL the browser will redirect to will be requested with the GET method, so it might seem asif you were using GET to request the page, for the browser, but in truth you don't have anything to day about it. Now, what Aurélien is talking about, cURL, is the other end of the story. cURL can take on the role of both ends of the line, so it can send either the request, or the response. But, it will not send it to the user('s browser), but instead over a connection that it was told to send it over. Basically, this means that you can't tell a browser it needs to do a POST request to another page via PHP. There :) hope that helps you in understanding, - tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] class constructor polymorphism
[EMAIL PROTECTED] wrote: Hi to all, I'm a C++ programmer and I've to convert some simple classes from C++ to PHP. My toolbar_button class must have two or more constructors so I ask you if this is possible with PHP: You can't overload a constructor, I mean a function in PHP. Maybe extending two classes from the base would be a good work-around. Hope this helps, -- Josip Dzolonga http://josip.dotgeek.org jdzolonga[at]gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php wget: Return an empty file
Chris Blake wrote: Greetings PHP(eople), I have a wget process that runs to download a file from a web site, Why would you do that ? There're bultin functions in PHP for doing it. -- Josip Dzolonga http://josip.dotgeek.org jdzolonga[at]gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XML Select
Hi NG I've a question about searching in a xmlfile. Is there a mehtod to select a xml-node with a specific value? e.g. xml nameabc/name namedef/name /xml and I want search for the node with name abc. Or is it possible with a xpath definition? Thanks in advance Stefan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php wget: Return an empty file
On Fri, 2005-04-08 at 13:52, Josip Dzolonga wrote: Chris Blake wrote: Greetings PHP(eople), I have a wget process that runs to download a file from a web site, Why would you do that ? There're bultin functions in PHP for doing it. wget was the first thing I thought of :) -- Chris Blake Cell: 082 775 1492 Work: +27 11 782 0840 Fax : +27 11 782 0841 Mail: [EMAIL PROTECTED] A woman was in love with fourteen soldiers. It was clearly platoonic. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] XML Select
There's a few xml - array libraries out there which is probably the easier way to examine xml stuff. I use http://keithdevens.com/software/phpxml but there are many others. M -Original Message- From: Stefan [mailto:[EMAIL PROTECTED] Sent: 08 April 2005 13:26 To: php-general@lists.php.net Subject: [PHP] XML Select Hi NG I've a question about searching in a xmlfile. Is there a mehtod to select a xml-node with a specific value? e.g. xml nameabc/name namedef/name /xml and I want search for the node with name abc. Or is it possible with a xpath definition? Thanks in advance Stefan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ This message has been checked for all known viruses. _ This message has been checked for all known viruses. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-I18N] Multilingual Web application - how to?
Hi Denis, You can look into using or analyzing a multilingual CMS. Last time I looked, the following PHP open source CMSs offered this feature: TYPO3, Glasnost, eZ publish and OVIDENTIA. (links are provided on MultilingualDev). You may get some insight on how why they chose specific technical solutions to your 3 questions. This page contains many links related to this matter. There is a great video from eTranslate: http://tikiwiki.org/MultilingualDev Another issue is how to manage to keep all versions in sync and how to handle untranslated pages. This page explains well the difference between The Two-Tree concept and the one-tree-fits-all-languages concept: http://typo3.org/1220.0.html Tiki CMS/Groupware handles multilingual content in upcoming version 1.9 It is still in developer release stage however, I have been using the multilingual feature in production sites for several months. Tiki uses Smarty as a template engine. Best regards, -- M ;-) // // / Marc Laporte | http://marclaporte.com / / Avantech.net | http://avantech.net / / Tiki CMS/Groupware | http://tikiwiki.org/UserPagemarclaporte / // // Denis Gerasimov wrote: Hello list, I need to develop a multilingual web site and I am looking for the best way of handling this task. There are three main issues I know: 1. Storing multilingual data in a database. Possible solutions I know: a. many tables, one per each supported language, e.g. news_en, news_de. b. one table having many columns with translations, e.g. (id, date, text_en, text_de) We use MySQL 4.1 as a back-end. 2. Multilingual HTML templates, possible solutions: a. one generic template for everything, one per each language, like contents_en.tpl.html, contents_de.tpl.html b. many localized templates for each page, e.g news_en.tpl.html, news_de.tpl.html Template engine is Smarty. 3. Storing current language variable, possible solutions: a. inside the URL like /en/news/ b. using cookies c. using sessions Web server is Apache2+mod_rewrite with PHP5 What are pros and cons for each solution? What are other possible solutions for the above issues? Best regards, Denis Gerasimov Outsourcing Services Manager, VEKOS, Ltd. www.vekos.ru -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php wget: Return an empty file
Chris Blake wrote: wget was the first thing I thought of :) You thought wrong :-) Are you are going to parse the file after you've downloaded it ? See this function, http://www.php.net/file_get_contents , if allow_url_fopen is set to TRUE in your php.ini, there will be no problems opening a URL, so $contents = file_get_contents($url); is going to to the job perfectly ! Hope this helps, -- Josip Dzolonga http://josip.dotgeek.org jdzolonga[at]gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] zipfile problems - SOLVED
-Original Message- snip 08while (false !== ($file = readdir($handle))){ 09$fn = explode(.,$file); 10if ($fn[1]==pdf){ 11echo $inputpath.$file.br; 12$handle = fopen($inputpath.$file,r); 13$filedata = fread($handle, filesize($inputpath.$file)); 14$zipfile - add_file($filedata, dir/.$file); 15} 16} /snip Do you need to also close the files you have opened? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Variable Passing
Hi, I am curious how to pass a variable without using something like id=321. I have seen sites that have something like http://www.website.com/something/321 and the variable is passed how exactly is that done? And is it called something specific so I know how to refer to it in the future? Thanks, Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with outputing a new line
Or if you aren't \r\n might work. Brent Baisley wrote: Uhm, well, if you are outputting it to a web browser, you would need to use HTML. Either br / or p. On Apr 7, 2005, at 3:41 PM, Bosko Vukojevic wrote: just reading: http://ca3.php.net/echo Regardless, I am not able to output a new line on the screen. Windows XP Perl 5.04 IIS 6 Php pages are processed correctly, i.e., the hook between IIS and Perl is working. This is the snippet of the code that does not work ?php $relative_path = /000/013/; #$absolute_path = getenv(absolute_path) . $relative_path; $absolute_path = $_SERVER[SCRIPT_FILENAME]; echo relative path: $relative_path . chr(13) . chr(10); echo absolute path: $absolute_path . chr(13) . chr(10); $absolute_path = $_SERVER[DOCUMENT_ROOT]/web_root_relative_path_to_header.lib; #echo absolute path: $absolute_path; ? Any help appreciated ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Kyriacos Sakkas Netsmart Development Team Tel: + 357 22 452565 Fax: + 357 22 452566 kyriacos(at)netsmart.com.cy http://www.netsmart.com.cy Taking Business to a New Level! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable Passing
On Apr 8, 2005 4:11 PM, Brad Brevet [EMAIL PROTECTED] wrote: Hi, I am curious how to pass a variable without using something like id=321. I have seen sites that have something like http://www.website.com/something/321 and the variable is passed how exactly is that done? And is it called something specific so I know how to refer to it in the future? Thanks, Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php in fact thats probably for search engine optimization. Try http://www.seochat.com for more details and info. Basically apache will use a thing called the URL rewrite engine (it rewrites URL) to change http://www.website.com/something/321 into probably something like http://www.website.com/index.php?thing=somethingnumber=321. other ways of passing variables by not using URI: cookies session forms... POST / http/1.1 hope this helps... i am sorry if i haven't explained it properly enough. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable Passing
Brad Brevet: Hi, I am curious how to pass a variable without using something like id=321. I have seen sites that have something like http://www.website.com/something/321 and the variable is passed how exactly is that done? And is it called something specific so I know how to refer to it in the future? You can do that with $_SERVER[PATH_INFO]. If your script is /something, this variable will be set to /321 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: using rand()
first I would suggest you get the largest value from the auto increment field (maybe use last_insert_id()). Then use rand(1,$cno_max) three times to get three random cno numbers, then select ... from ... where cno=$val1 or cno=$val2 or cno=$val3 should return the three values. rand() can also be directly in the sql statement. Also manual suggests using mt_rand instead of rand for better performance. K.Sakkas Ryan A wrote: Hey, need some advise on what would be the best way to do this: I have a table with these fields: cno (just a auto_increment field), username, sex (2 values: man, woman), has_pic (0=no,1=yes), pic_name I need to randomly get 3 womens pictures and one guys picture from the above table... I know I need to use rand() and i thought maybe shuffle() but am getting a bit lost in the logic part...help please? Thanks, Ryan -- Kyriacos Sakkas Netsmart Development Team Tel: + 357 22 452565 Fax: + 357 22 452566 kyriacos(at)netsmart.com.cy http://www.netsmart.com.cy Taking Business to a New Level! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable Passing
Brad Brevet wrote: Hi, I am curious how to pass a variable without using something like id=321. I have seen sites that have something like http://www.website.com/something/321 and the variable is passed how exactly is that done? And is it called something specific so I know how to refer to it in the future? That's done with a little bit of Apache's mod_rewrite magic ;). I suggest you to read this article [ http://www.sitepoint.com/article/guide-url-rewriting ] which is of a great help, however checking the manual reference ( google for 'mod_rewrite' ) will help you a lot too. If you get stuck somewhere, state your questions here :) Hope this helps, -- Josip Dzolonga http://josip.dotgeek.org jdzolonga[at]gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: using rand()
i guess a good question would be which one of these methods has more overhead - having php calculate the random numbers for queries, or having the mysql db pick them at random itself? i don't really focus that much on optimization, but if you expect heavy traffic on your site, it might be in your best interest to find out which one executes quicker. On Apr 8, 2005 9:41 AM, kyriacos sakkas [EMAIL PROTECTED] wrote: first I would suggest you get the largest value from the auto increment field (maybe use last_insert_id()). Then use rand(1,$cno_max) three times to get three random cno numbers, then select ... from ... where cno=$val1 or cno=$val2 or cno=$val3 should return the three values. rand() can also be directly in the sql statement. Also manual suggests using mt_rand instead of rand for better performance. K.Sakkas Ryan A wrote: Hey, need some advise on what would be the best way to do this: I have a table with these fields: cno (just a auto_increment field), username, sex (2 values: man, woman), has_pic (0=no,1=yes), pic_name I need to randomly get 3 womens pictures and one guys picture from the above table... I know I need to use rand() and i thought maybe shuffle() but am getting a bit lost in the logic part...help please? Thanks, Ryan -- Kyriacos Sakkas Netsmart Development Team Tel: + 357 22 452565 Fax: + 357 22 452566 kyriacos(at)netsmart.com.cy http://www.netsmart.com.cy Taking Business to a New Level! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- dc .. drewcore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: using rand()
I guess so, but I dont think the difference would be all that great using rand() in php or order by rand in mysql.. worth checking up for programmer show off rights anyway :-) Cheers, Ryan i guess a good question would be which one of these methods has more overhead - having php calculate the random numbers for queries, or having the mysql db pick them at random itself? i don't really focus that much on optimization, but if you expect heavy traffic on your site, it might be in your best interest to find out which one executes quicker. On Apr 8, 2005 9:41 AM, kyriacos sakkas [EMAIL PROTECTED] wrote: first I would suggest you get the largest value from the auto increment field (maybe use last_insert_id()). Then use rand(1,$cno_max) three times to get three random cno numbers, then select ... from ... where cno=$val1 or cno=$val2 or cno=$val3 should return the three values. rand() can also be directly in the sql statement. Also manual suggests using mt_rand instead of rand for better performance. K.Sakkas Ryan A wrote: Hey, need some advise on what would be the best way to do this: I have a table with these fields: cno (just a auto_increment field), username, sex (2 values: man, woman), has_pic (0=no,1=yes), -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.5 - Release Date: 4/7/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I get the first element's key of an array of objects?
Mattias Thorslund mailto:[EMAIL PROTECTED] on Thursday, April 07, 2005 5:20 PM said: ?php $keys = array_keys($object_array); $first_key = $keys[0]; I wonder if that will work, when the first element has the key 3... ? This might work better: $keys = array_keys($object_array); $first_key = reset($keys); Read www.php.net/array_keys and you shall have your answer. From the php docs: ?php $array = array(0 = 100, color = red); print_r(array_keys($array)); ? Will output. Array ( [0] = 0 [1] = color ) Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST method to php page from php page
Hello all Does anyone know if its possible to post data using the http POST method to another form using php? Yes. If you search around you'll find some pure-PHP code snippets to do this... or do it yourself... To programmatically make a POST request you need to open a socket connection to the web server on port 80 and send the following information: -- POST /path/to/form.php HTTP/1.1 Host: www.somehost.com Content-type: application/x-www-form-urlencoded Content-length: 71 Connection: close =urlencoded_xxx_datayyy=urlencoded_yy_data -- Each line is terminated by a single newline (\n). Content-length is simply the length of the data being sent (the last line in this case). You'll need to urlencode the data in order to transport it safely. See this for more info on what this does: http://us3.php.net/urlencode. Only encode the actual data though... that is the stuff after the equal sign. Then you'll need to read back the response headers and do whatever you want from there... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Extern Executions (Perl)
HI Suggestion 1: configure apache to parse files with php extension thru php binary Suggestion 2: place a shebang on the start of the php file like #! /usr/bin/php Suggestion 3: rewrite your script and have the php script call the perl ;-) Tada Andy On Friday 08 April 2005 07:05, Eli wrote: with some parameters. When running the perl program throu unix shell, then perl executes the PHP program as expected, and returns its output. When running the perl program throu Apache (using cgi-bin on a browser), then perl opens the PHP file for reading and doesn't execute the PHP script, and returns the PHP code of the script. The Perl line trying to execute the PHP script is: open (PIPE,./my_prog.php $arg1 $arg2 |); while (PIPE) $res=$res.$_; print got:\n,$res; Does anyone have any clue why Perl behaves differently on different enviorments? OR: does anyone have a suggestion for a stable solution? -thanks, Eli -- Registered Linux User Number 379093 -- Feel free to check out these few php utilities that I released under the GPL2 and that are meant for use with a php cli binary: http://www.vlaamse-kern.com/sas/ -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Why is it possible to assign data to _not_declared_ vars in a class (PHP 5.0.3)?
Hello All, Why is this working? ?php class foobar { public $a, $b; public function __construct() { $this-a = Hello ; $this-b = world! ; $this-c = Good bye... ; } public function foo() { echo $this-a.br; echo $this-b.br; echo $this-c.br; } } ? CALL: $test = new foobar(); $test-foo(); OUTPUT: Hello world Good bye... If i understand right, all variables should be declared in PHP5. So why is it possible to add a membervariable called c to the object without making a declaration? I got no error with this. I thought E_STRICT should show me things like that. Could someone explain me that? I found this problem by building one dynamic get and set method for all member variables with the help of the interceptor method __call() . In this method i originally has build a try catch block that looks like this: example_code try { $this-non_existent_member = FooBar; } catch (Exception $e) { echo The variable 'non_existent_member' is not declared!; } /example_code I expected that the try block should catch the ERROR run the catch block but this doesn't heppend and and took some time to figure that out. I think it is really bad, that this kind of logical error must be catched in some way or must be at least reported with E_STRICT on. I am only develping with E_STRICT and thought this will give hints to all design faults. Kind regards Johannes Findeisen P.S.: I am going crazy ... This works too: ?php class foobar { public $a, $b; var $bla; public function __construct() { $this-a = Hello ; $this-b = world! ; $this-c = Good bye... ; } public function foo() { echo $this-a.br; echo $this-b.br; echo $this-c.br; } } class failover { public $foobar; public function __construct() { $this-foobar = new foobar(); $this-foobar-d = ...all Aliens! ; } public function bar() { echo $this-foobar-a.br; echo $this-foobar-b.br; echo $this-foobar-c.br; echo $this-foobar-d.br; } } ? CALL: $test = new foobar(); $test-foo(); $test2 = new failover(); $test2-bar(); OUTPUT: Hello world! Good bye... Hello world! Good bye... ...all Aliens! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] parsing values from a form post
Hello, Here is an example of what could be posted from a form: Array ( [tax0] = GST [amount0] = 10.23 [type0] = Goods [tax1] = GST [amount1] = 6.5 [type1] = Goods [tax2] = HST [amount2] = 3.54 [type2] = Goods [tax3] = HST [amount3] = 8.95 [type3] = Hotel [tax4] = GST [amount4] = 44.5 [type4] = Goods ) I need to be able to break out the tax, amount and type that were entered on each line of a form and then apply calculations and do database inserts on each. As you can see what I need is in sets of three denoted by the integer at the end (tax0, amount0, type0, tax1 etc.) I can't figure out how to separate these variables and values so that I can do what I need to do. I've got foreach($_POST as $var=$value) { } but can't seem to figure out what to do inside. Ideas?? Thanks Chris
[PHP] sessions not being stored : DAY 2
I'm receiving this when trying to store a session : Warning: session_start(): open(/tmp/sess/sess_d280d6af3a2059aa58f43477d6b2c166, O_RDWR) failed: Permission denied (13) in /usr/local/apache2/htdocs/calendario/calendarix/cal_header.inc.php on line 19 Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /usr/local/apache2/htdocs/calendario/calendarix/cal_header.inc.php:19) in /usr/local/apache2/htdocs/calendario/calendarix/cal_header.inc.php on line 19 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /usr/local/apache2/htdocs/calendario/calendarix/cal_header.inc.php:19) in /usr/local/apache2/htdocs/calendario/calendarix/cal_header.inc.php on line 19 Warning: Cannot modify header information - headers already sent by (output started at /usr/local/apache2/htdocs/calendario/calendarix/cal_header.inc.php:19) in /usr/local/apache2/htdocs/calendario/calendarix/cal_header.inc.php on line 89 * the /tmp directory is owned by root * the /tmp/sess directory is owned by the apache user and has 777 permissions * the directory in php.ini to store sessions is : /tmp/sess * there's not a php user I'm using : RedHat 9 Apache 2.0.48 php 4.3.4 ___ Join Excite! - http://www.excite.com The most personalized portal on the Web! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Controlling file access with PHP
Problem: I have db with users, groups, passwords and permissions. I need to restrict access to some files for general public, but allow certain groups to download those files. Access restrictions should be based on permissions in the database. I can set_time_limit() to a very big number, output file header, read file through PHP and output it through PHP, but that's not a very elegant solution. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parsing values from a form post
I can't figure out how to separate these variables and values so that I can do what I need to do. I've got foreach($_POST as $var=$value) { } but can't seem to figure out what to do inside. Ideas?? What you could do is rename the form field names. Instead of naming the field 'tax0', you could name it 'tax[0]'. Once you do that you will find your form infinitely easier to work with doing what you want to do. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sessions not being stored : DAY 2
Yuri Huitrón Alvarado mailto:[EMAIL PROTECTED] on Friday, April 08, 2005 10:02 AM said: * the /tmp directory is owned by root * the /tmp/sess directory is owned by the apache user and has 777 permissions * the directory in php.ini to store sessions is : /tmp/sess * there's not a php user Try running the system command 'whoami' within PHP to see what user is being used. Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Still not working: PHP4 running on server, but not on dev box (SuSE 9.2)
Hi folks, Been through the suggestions offered here, have compared the config files on my development box and my server, and I'm still stuck. To recap, I set up SuSE 9.2 with Apache 2 and PHP 4.3.8 on a server and it's running fine. When I installed, I included Apache and PHP from the very start. Then I took an existing desktop 9.2 box, added Apache 2 and PHP 4 to it via YAST later. I can't get PHP to respond to function calls. Apache is serving up static pages fine, but it's not recognizing PHP. I've compared /etc/apache2/httpd.conf, default-server.conf, and php4.conf (in conf.d), and they're basically the same. (The two differences are that the document root is different on the two boxes, and I've got virtual hosts set up on the server. Neither should affect this problem.) I've done no manually editing or modifying, other that the two differences just mentioned. I don't know where to turn next to troubleshoot this; it seems like Apache on the dev box doesn't see PHP, but how to test? How to tell it? Thanks, Whil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with in_array function
Hi all i have problem with in_array() function to comparing string of filepath. I read from a directory and write the filepath into database if the flag is off. If the file is modified i update the last time of modify and if there are new file i add this file into Db. i have write a function to explain the problem to this link: http://www.fadelabor.net/update.php Thanks so much to all. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sessions not being stored : DAY 2
On Saturday 09 April 2005 01:02, Yuri Huitrón Alvarado wrote: I'm receiving this when trying to store a session : Warning: session_start(): open(/tmp/sess/sess_d280d6af3a2059aa58f43477d6b2c166, O_RDWR) failed: Permission denied (13) in /usr/local/apache2/htdocs/calendario/calendarix/cal_header.inc.php on line 19 * the /tmp directory is owned by root * the /tmp/sess directory is owned by the apache user and has 777 permissions * the directory in php.ini to store sessions is : /tmp/sess * there's not a php user what is the output of: ls -al /tmp/sess -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- New Year Resolution: Ignore top posted posts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Still not working: PHP4 running on server, but not on dev box (SuSE 9.2)
On Saturday 09 April 2005 01:35, Whil Hentzen wrote: Then I took an existing desktop 9.2 box, added Apache 2 and PHP 4 to it via YAST later. I can't get PHP to respond to function calls. Apache is serving up static pages fine, but it's not recognizing PHP. I'm pretty sure the people over at SuSE would be far more familiar with how *SuSE* has setup Apache + PHP, and hence would be far more likely to know what's going on. I don't know where to turn next to troubleshoot this; it seems like Apache on the dev box doesn't see PHP, but how to test? How to tell it? Go through the installation instructions in the [PHP] manual Installation on Unix systems Apache 2.0 on Unix systems. In particular verify steps 14 and 15. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- New Year Resolution: Ignore top posted posts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Why is it possible to assign data to _not_declared_ vars in a class (PHP 5.0.3)?
* Johannes Findeisen [EMAIL PROTECTED]: Hello All, Why is this working? ?php class foobar { public $a, $b; public function __construct() { $this-a = Hello ; $this-b = world! ; $this-c = Good bye... ; } public function foo() { echo $this-a.br; echo $this-b.br; echo $this-c.br; } } ? CALL: $test = new foobar(); $test-foo(); OUTPUT: Hello world Good bye... If i understand right, all variables should be declared in PHP5. So why is it possible to add a membervariable called c to the object without making a declaration? I got no error with this. I thought E_STRICT should show me things like that. Could someone explain me that? You don't understand correctly. Class properties/attributes do not need to be explicitly declared in PHP. This did *not* change in PHP5. What changed in PHP5 is visibility. By default, unless declared otherwise, a class attribute is publicly visible -- the same behaviour seen in PHP4. -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Installation Warning?
Hi all, I'm in the process of getting started on a new web app and want to compare performance etc. of: php5, MySQL, Apache and Smarty on Windows 2000 Server vs. Red Hat Linux FC3 While installing php5, in the install doc it says Do not use Apache 2.0.x and PHP in a production environment neither in Windows or Unix. For information on why, read the following FAQ entry ...I've read the whole document and it only talks about the risks of running cgi on a webserver. Anyone have any ideas on why it is suggesting NOT to use php and Apache 2.0.x in a production environment? I'm planning on developing several large apps for my company and expect 300-400 people to be hitting it throughout the business day. John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Session Info Storage: Session File or MySQL DB?
* Michael [EMAIL PROTECTED]: I am currently developing a few security functions for my website and have finally decided to use the session functions that I have been avoiding for years since I did not want to change from what I am used to developing. So now that I have refreshed my brain on how to use sessions I have to make a decision, Where should I store my session data, in the session file or on my mysql database, Speed is my main drive here and I believe the file might be just a few microseconds faster, but what do you suggest I use? Files are faster, but you really only need to worry about those microseconds on high traffic sites or if your PHP is doing heavy lifting. Some things to think about: * Are you on a web cluster? If so, you'll want centralized session storage. Your options are a database or a distributed file system (NFS or openGFS, for instance) * Are you using a shared host? If so, it's possible for session collision and snooping to happen when using file based sessions. Database storage might be a good idea in this situation. -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parsing values from a form post
Beautiful Chris. That does make things easier. Thanks. On Apr 8, 2005, at 1:02 PM, Chris Boget wrote: I can't figure out how to separate these variables and values so that I can do what I need to do. I've got foreach($_POST as $var=$value) { } but can't seem to figure out what to do inside. Ideas?? What you could do is rename the form field names. Instead of naming the field 'tax0', you could name it 'tax[0]'. Once you do that you will find your form infinitely easier to work with doing what you want to do. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Chris Bruce [EMAIL PROTECTED] Idextrus E-Business Architects http://www.idextrus.com 3282 Wilmar Cres. Mississauga, ON L5L4B2 CA 905.828.9189 South Office 705.361.0331 North Office Skype: callto://chrisrjbruce This e-mail and its contents are privileged, confidential and subject to copyright. If you are not the intended recipient, please delete this e-mail immediately. Any unauthorized use or disclosure of the information herein is prohibited.
Re: [PHP] Installation Warning?
Please turn off your return receipts when sending to a mailing list. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PEAR::SOAP, nusoap, PHP 4.2.2
Im running PHP 4.2.2 on RedHat 9.0 Just using one of the many free Google API search scripts using nusoap or pear::soap, I get no response. When I run the same script on a different server (identical, just a later version of PHP) it works like a charm. Is there a syntax difference in 4.2.2 and 4.2.2 which is insignificant enough not to give an error, but significant enough to prevent a SOAP request from coming through? Russ Jones -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mcrypt_generic_init(): Iv size incorrect
I have an odd php issue with mcrypt. I'm getting a lot of this type of error, but only sometimes: mcrypt_generic_init(): Iv size incorrect; supplied length: 0, needed: 32 (note, the supplied length: 0 is not always the same. sometimes it is 1, 16, etc). It doesn't seem to affect the decoding of the file, but it is throwing a notice in to my error log. I've tried doing this: @mcrypt_generic_init($this-td, $key, $iv) but that doesn't stop it from throwing an error. The only thing I can think is that I have mcrypt_module_close($this-td) commented out because my code was dying with it... System: Linux w/ Apache 1.3.31 PHP Version 4.3.4 libmcrypt version 2.5.7 Suggestions? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Installation Warning?
Apache2 uses threads. Searching the archives (both php-general below and php-dev would be good places to look) will give you the answer for this question. -- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-generalw=2 STFM | http://php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins signature.asc Description: OpenPGP digital signature
Re: [PHP] Installation Warning?
Here is that faq url http://www.php.net/manual/en/faq.installation.php#faq.installation.apache2 Cheers Andy -- Registered Linux User Number 379093 -- Feel free to check out these few php utilities that I released under the GPL2 and that are meant for use with a php cli binary: http://www.vlaamse-kern.com/sas/ -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
AW: [PHP] Re: pasring complex string question
Thank you very much. If anybody has some good links to ereg tutorials, I would love to get that teached. Thanks Mirco Blitz -Ursprüngliche Nachricht- Von: Eli [mailto:[EMAIL PROTECTED] Gesendet: Freitag, 8. April 2005 06:40 An: php-general@lists.php.net; Webmaster Betreff: [PHP] Re: pasring complex string question Eli wrote: Webmaster wrote: Hello, i have a string looking like this. ## /T (KEY1)/V (VALUE1)|| ## /T (KEY2)/V (VALUE2)|| ## /V (VALUE3)/T (KEY3)|| I know want to separete it in to keys and values and insert them into an array. Note that /T always shows that teh upcoming value in() is a Key and that /V always is a Value. And that the set can be flipped. Thank you very much for helping. Mirco Blitz It seems you complex yourself too much.. ;) Try using regexp with the 'e' modifier: ?php $data=## /T (KEY1)/V (VALUE1)|| ## /T (KEY2)/V (VALUE2)|| ## /V (VALUE3)/T (KEY3)||; $data_array=array(); preg_replace( array( /\#\#\s*/T\s*\(([^\)]*)\)\s*\V\s*\(([^\)]*)\)\s*\|\|/e, /\#\#\s*/V\s*\(([^\)]*)\)\s*\T\s*\(([^\)]*)\)\s*\|\|/e ), array( \$data_array['\\1']='\\2';, \$data_array['\\2']='\\1'; ), $data ); print_r($data_array); //see if you get it as expected ? I believe there's an easier way to store your data as strings (like serialize), so why not using them?! see alse: http://www.php.net/serialize Sorry... a little correction: ?php $data=## /T (KEY1)/V (VALUE1)|| ## /T (KEY2)/V (VALUE2)|| ## /V (VALUE3)/T (KEY3)||; $data_array=array(); preg_replace( array( /\#\#\s*\/T\s*\(([^\)]*)\)\s*\/V\s*\(([^\)]*)\)\s*\|\|/e, /\#\#\s*\/V\s*\(([^\)]*)\)\s*\/T\s*\(([^\)]*)\)\s*\|\|/e ), array( \$data_array['\\1']='\\2';, \$data_array['\\2']='\\1'; ), $data ); print_r($data_array); //see if you get it as expected ? -- 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] Variable Passing
This seems to be what I was looking for, but I am curious, will the / be included in the variable? Will I have to do a stripslashes() command on it? Brad Hans Juergen von Lengerke [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Brad Brevet: Hi, I am curious how to pass a variable without using something like id=321. I have seen sites that have something like http://www.website.com/something/321 and the variable is passed how exactly is that done? And is it called something specific so I know how to refer to it in the future? You can do that with $_SERVER[PATH_INFO]. If your script is /something, this variable will be set to /321 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Simple Licensing System
Hi Guys! I need a help with a licensing system, I want something very simple, for example a simple var store into the configuration file, and witch is sent to a server called licenses.hostname.com.br, and this one returns true or false... I don't wanna use SOAP or XML. Does any body have a simple idea for it? Best Regards, Bruno B B Magalhaes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
re: [PHP] Installation Warning?
So it seems that Apache's multi-threading is the issue. So IIS is the way to go then or Apache 1.x eh? The trouble with going the Apache 1.x route is that I've been having trouble downgrading from 2.x to 1.x... Well someday I'll find a use for Linux...The check is in the mail, Mr. Gates. John Here is that faq url http://www.php.net/manual/en/faq.installation.php#faq.installation.apache2 Cheers Andy -- Registered Linux User Number 379093 -- Feel free to check out these few php utilities that I released under the GPL2 and that are meant for use with a php cli binary: http://www.vlaamse-kern.com/sas/ -- -- 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] pasring complex string question
On Thu, April 7, 2005 5:32 pm, Webmaster said: ## /T (KEY1)/V (VALUE1)|| ## /T (KEY2)/V (VALUE2)|| ## /V (VALUE3)/T (KEY3)|| I know want to separete it in to keys and values and insert them into an array. Note that /T always shows that teh upcoming value in() is a Key and that /V always is a Value. And that the set can be flipped. Question #1: What happens when your KEY or VALUE contains ##, /T, or /V Depending on your answer to that, the best solution will change a bit. In the short term: $string = ## /T (KEY1)/V (VALUE1)|| ## /T (KEY2)/V (VALUE2)|| ## /V (VALUE3)/T (KEY3)|| ; $keyvalues = explode(##, $string); $answer = array(); while (list(, $keyvalue) = each($keyvalues)){ $keyvalue = trim($keyvalue); if (substr($keyvalue, 0, -2) != '||'){ die(Unexpected keyvalue: $keyvalue); } $keyvalue = substr($keyvalue, 0, -2); preg_match(#/T(.*)(/V|$)#, $keyvalue, $key); $key = $key[1]; preg_match(#/V(.*)(/T|$)#, $keyvalue, $value); $value = $value[1]; $answer[$key] = $value; } -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Info Storage: Session File or MySQL DB?
On Tue, April 5, 2005 8:43 pm, michael said: I am currently developing a few security functions for my website and have finally decided to use the session functions that I have been avoiding for years since I did not want to change from what I am used to developing. So now that I have refreshed my brain on how to use sessions I have to make a decision, Where should I store my session data, in the session file or on my mysql database, Speed is my main drive here and I believe the file might be just a few microseconds faster, but what do you suggest I use? Only a test under real-world conditions on YOUR hardware/software will give you the correct answer. Anything else is Voodoo Programming. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql regexp select questions
On Thu, April 7, 2005 5:32 pm, Andras Kende said: I would like to do the following: mysql db: andrew anthony joe janice john simon sql_query ( select names . I would need only the distinct first character from the query result would be: a,j,s I think maybe its REGEXP but never did it before... select distinct substring(name, 1, 1) from names -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How can i do refresh my web since java script?
input name=refrescar type=submit class=btn id=refresh onClick=sendrefresch() value=Refrescar script language=JavaScript type=text/JavaScript !-- function sendrefresch() { How can I do for refresch my web, by the button Refresh? } some help please?. thanks very mouch. best regards TOMAS - Este correo fue escaneado en busca de virus con el MDaemon Antivirus 2.27 en el dominio de correo angerona.cult.cu y no se encontro ninguna coincidencia. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: AW: [PHP] Re: pasring complex string question
Webmaster wrote: Thank you very much. If anybody has some good links to ereg tutorials, I would love to get that teached. Thanks Mirco Blitz http://www.regular-expressions.info/ have a good article, however there's a great book on this topic (IIRC 'Mastering Regular Expressions', too lazy to google now :)), search Amazon. -- Josip Dzolonga http://josip.dotgeek.org jdzolonga[at]gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] AutoPostgreSQLBackup Released
Greetings, I am proud to announce the initial release of AutoPostgreSQLBackup! It is based on the AutoMySQLBackup script written by [EMAIL PROTECTED] A previous version of this script was ported to Postgresql by Friedrich Lobenstock [EMAIL PROTECTED]. I have been using the script for a couple weeks, and so far it's working like a charm. Visit the project page for my details: http://autopgsqlbackup.frozenpc.net Any problems, questions, bugs can be posted on the forum. I hope others can find this as useful as I do! -- Aaron Axelsen [EMAIL PROTECTED] Great hosting, low prices. Modevia Web Services LLC -- http://www.modevia.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Regular Expressions?
Windows 2000 Server IIS 5/Apache 1.3.33 MySQL 4.1.1 Smarty 2.6.9 PHP 5.0.3 Hi all, I am looking for help handling a form input to SQL. I believe the solution has to do with regular expressions. My big problem is that when a user submits data such as: Joe's Crabshack The ' apostrophe or can cause an early truncation of the data. My code thinks that the closing identifier is after the word Joe and the rest of the input is lost. Further, if the data does get by and it could possibly break a SQL statement. Am I right in thinking the solution in this matter is using regular expressions? If so, where is a good resource to polish my skills? What about turning off/on magic quotes? John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Regular Expressions?
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] on Friday, April 08, 2005 3:43 PM said: The ' apostrophe or can cause an early truncation of the data. My code thinks that the closing identifier is after the word Joe and the rest of the input is lost. Further, if the data does get by and it could possibly break a SQL statement. Am I right in thinking the solution in this matter is using regular expressions? If I understand you correctly the answer to that question is 'no'. If so, where is a good resource to polish my skills? A great utility for practicing with regular expressions is theregexcoach (search for it). What about turning off/on magic quotes? I would keep magic quotes off and do the escaping myself. This way you know exactly what is happening. What you need to do is addslashes() to the data before putting it in the sql query. HTH, Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Compress Files
How do I compress two or more files using PHP? All I have been able to find information on is compressing strings, or just one file. Jeremy White Manager, Online Marketing IMEX Research 408-268-0800 1474 Camino Robles San Jose, CA 95120 [EMAIL PROTECTED] http://www.imexresearch.com
RE: [PHP] Regular Expressions?
Ok that would solve my SQL statements from breaking but how about in the submitted form data at submit time? John [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] on Friday, April 08, 2005 3:43 PM said: The ' apostrophe or can cause an early truncation of the data. My code thinks that the closing identifier is after the word Joe and the rest of the input is lost. Further, if the data does get by and it could possibly break a SQL statement. Am I right in thinking the solution in this matter is using regular expressions? If I understand you correctly the answer to that question is 'no'. If so, where is a good resource to polish my skills? A great utility for practicing with regular expressions is theregexcoach (search for it). What about turning off/on magic quotes? I would keep magic quotes off and do the escaping myself. This way you know exactly what is happening. What you need to do is addslashes() to the data before putting it in the sql query. HTH, Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and Excel and COM
Hi, I am trying to control Excel with PHP via COM. I am wondering if there are some resources available with all the keywords (I didn't find anything on the net...). F.i. : I try to modify the content of a textbox in a worksheet. In VBA, I have: ActiveSheet.Shapes(Shape1).Select Selection.Characters.Text = foo If I try it on PHP, I have: $excel-Workbooks[1]-Worksheets[1]-Shapes[Shape1]-Characters-Text = foo; I get the following error: Uncaught exception 'com_exception' with message 'Unable to lookup `Characters': Unknown Apparently it does not recognize Characters. What should I use then??? Thanx for your help. Wongy _ MSN Messenger : discutez en direct avec vos amis ! http://www.msn.fr/msger/default.asp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Regular Expressions?
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] on Friday, April 08, 2005 4:08 PM said: Ok that would solve my SQL statements from breaking but how about in the submitted form data at submit time? Do you mean you're having this problem? input type=text name=.. value=She said Hi! / ? If so, do htmlentities() to the data being displayed. That will turn the into quot; which will not get the form confused. Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Storing password in cookie
What is a better way to store password in a cookie? md5()? base64_encode()? mhash()? mcrypt_generic()? crypt()? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parsing values from a form post
On 8 Apr 2005 Chris Bruce wrote: I need to be able to break out the tax, amount and type that were entered on each line of a form and then apply calculations and do database inserts on each. As you can see what I need is in sets of three denoted by the integer at the end (tax0, amount0, type0, tax1 etc.) I can't figure out how to separate these variables and values so that I can do what I need to do. The other suggestion is a good one but if you want to do it with the variables as you named them you can also use something like this: for ($i = 0; $i $maxlines; $i++) { $tax = $_POST['tax' . $i]; $amount = $_POST['amount' . $i]; $type = $_POST['type' . $i]; . } There is more one should usually do here, for security -- anything coming in via _POST should be processed through functions designed to remove malicious data. For example, an approach something like this: $value = strip_tags((substr(trim($_POST[$fldname]), 0, MAX_LEN)); -- Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular Expressions?
[EMAIL PROTECTED] wrote: Windows 2000 Server IIS 5/Apache 1.3.33 MySQL 4.1.1 Smarty 2.6.9 PHP 5.0.3 Hi all, I am looking for help handling a form input to SQL. I believe the solution has to do with regular expressions. My big problem is that when a user submits data such as: Joe's Crabshack The ' apostrophe or can cause an early truncation of the data. My code thinks that the closing identifier is after the word Joe and the rest of the input is lost. Further, if the data does get by and it could possibly break a SQL statement. Am I right in thinking the solution in this matter is using regular expressions? If so, where is a good resource to polish my skills? What about turning off/on magic quotes? John If you don't plan on doing anything this weekend, pick yourself up a copy of O'Reilly's Regular Expressions. It's The Owl Book, by the cover. The reason why I ask if you have all weekend is because it's a good book, but at 300+ pages, it's a good read. I still don't know my regex's very well, but then again, I just kinda skipped through it. However, it is laid out in a format that makes it a very good reference book, so if you're looking to do something, then this book makes it easy to piece things together and find a regex that works quite well. Thanks -dant -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing password in cookie
On Fri, April 8, 2005 5:18 pm, Computer Programmer said: What is a better way to store password in a cookie? md5()? base64_encode()? mhash()? mcrypt_generic()? crypt()? D) None of the above. You only think you need to store a password in a Cookie. You don't. Use sample code from http://php.net/session_start instead -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular Expressions?
[EMAIL PROTECTED] wrote: snip Joe's Crabshack The ' apostrophe or can cause an early truncation of the data. My code thinks that the closing identifier is after the word Joe and the rest of the input is lost. Further, if the data does get by and it could possibly break a SQL statement. Am I right in thinking the solution in this matter is using regular expressions? If so, where is a good resource to polish my skills? What about turning off/on magic quotes? John No need for a regex. Use something like mysql_escape_string() or addslashes(). That's what these functions are made for. The Camel book is a good place to start your regex learning. -- By-Tor.com ...it's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing password in cookie
Computer Programmer wrote: What is a better way to store password in a cookie? There is no good way to store a password in a cookie. Just don't do it. -- By-Tor.com ...it's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular Expressions?
On Fri, April 8, 2005 3:43 pm, [EMAIL PROTECTED] said: I am looking for help handling a form input to SQL. I believe the solution has to do with regular expressions. My big problem is that when a user submits data such as: Joe's Crabshack The ' apostrophe or can cause an early truncation of the data. My code thinks that the closing identifier is after the word Joe and the rest of the input is lost. Further, if the data does get by and it could possibly break a SQL statement. Am I right in thinking the solution in this matter is using regular expressions? If so, where is a good resource to polish my skills? You would be far better off using the built-in mysql_escape_string (recent PHP versions) or http://php.net/addslashes You might want to try to use Regex as an exercise, but this ain't the place for it on a real site. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mcrypt_generic_init(): Iv size incorrect
Hi, Saturday, April 9, 2005, 3:35:21 AM, you wrote: MH I have an odd php issue with mcrypt. MH I'm getting a lot of this type of error, but only sometimes: MH mcrypt_generic_init(): Iv size incorrect; supplied length: 0, needed: 32 MH (note, the supplied length: 0 is not always the same. sometimes it is MH 1, 16, etc). MH It doesn't seem to affect the decoding of the file, but it is throwing a MH notice in to my error log. I've tried doing this: MH @mcrypt_generic_init($this-td, $key, $iv) MH but that doesn't stop it from throwing an error. MH The only thing I can think is that I have MH mcrypt_module_close($this-td) MH commented out because my code was dying with it... MH System: MH Linux w/ Apache 1.3.31 MH PHP Version 4.3.4 MH libmcrypt version 2.5.7 MH Suggestions? I do this to set a zero iv $td = mcrypt_module_open(MCRYPT_TripleDES, , MCRYPT_MODE_ECB, ); $key = substr($secret, 0, mcrypt_enc_get_key_size ($td)); $iv = pack(a.mcrypt_enc_get_iv_size($td),$iv); mcrypt_generic_init ($td, $key, $iv); -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple Licensing System
On Fri, April 8, 2005 1:06 pm, Bruno B B Magalhães said: I need a help with a licensing system, I want something very simple, for example a simple var store into the configuration file, and witch is sent to a server called licenses.hostname.com.br, and this one returns true or false... I don't wanna use SOAP or XML. Does any body have a simple idea for it? Best Regards, Bruno B B Magalhaes Generate an SSH key-pair. Give them the public key, or use that to sign their license. Then you can just test that it's signed. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Compress Files
On Fri, April 8, 2005 3:54 pm, IMEX Research said: How do I compress two or more files using PHP? All I have been able to find information on is compressing strings, or just one file. You could use http://php.net/exec with tar and gzip, but you'd have to be sure only ONE script was doing this at a time for any given file[s] -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: using rand()
On Fri, April 8, 2005 7:41 am, kyriacos sakkas said: first I would suggest you get the largest value from the auto increment field (maybe use last_insert_id()). Then use rand(1,$cno_max) three times to get three random cno numbers, then select ... from ... where cno=$val1 or cno=$val2 or cno=$val3 should return the three values. rand() can also be directly in the sql statement. Also manual suggests using mt_rand instead of rand for better performance. Reasons NOT to do this: If you ever delete a record, then $val2 might not *BE* there. To get the max(id) requires an extra query. MySQL does *NOT* promise the numbers will be 1, 2, 3, 4, ... Sure, they happen to be that *NOW* and it's unlikely to change, but it's *NOT* a documented feature. What if $val1 and $val2 both happen to come out as 42 one day? Then you're not going to get 3 different records. ORDER BY rand() will always return 3 different records. It's unlikely that PHP's mt_rand() will be enough faster to justify using it when a single SQL statement is so much more clear than 5 lines of PHP. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] threaded comments
On Thu, April 7, 2005 1:17 pm, Sebastian said: i am developing a comment/discussion board and i want to display the results in a threaded style. so far i have it all working except this one issue: each row has an ID and a parentid, say i have 5 rows: id : 10 most oranges come from florida id : 16 Re: most oranges come from florida (parentid 10) id : 22 - Re: most oranges come from florida (parentid 16) id : 24 - Re: most oranges come from florida (parentid 22) id : 28 Re: most oranges come from florida (parentid 16) i want the rows to know the id directly above itself so for example, row 5 (id 28) will some how know its parentid (16) is not directly above it and is not accociated with the result its above (24) i want to 'highlight' a row when the parent it belongs to is directly above and do nothing if its not. $query = select ID, parentid from ...; $lines = mysql_query($query); $last_id = ''; while (list($ID, $parentid) = mysql_fetch_row($lines)){ $class = $last_id == $parentid ? 'highlight' : 'normal'; echo span class='$class'$ID/spanbr /\n; $last_id = $ID; } -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] threaded comments
On Thu, April 7, 2005 1:17 pm, Sebastian said: i am developing a comment/discussion board and i want to display the results in a threaded style. so far i have it all working except this one issue: each row has an ID and a parentid, say i have 5 rows: id : 10 most oranges come from florida id : 16 Re: most oranges come from florida (parentid 10) id : 22 - Re: most oranges come from florida (parentid 16) id : 24 - Re: most oranges come from florida (parentid 22) id : 28 Re: most oranges come from florida (parentid 16) i want the rows to know the id directly above itself so for example, row 5 (id 28) will some how know its parentid (16) is not directly above it and is not accociated with the result its above (24) i want to 'highlight' a row when the parent it belongs to is directly above and do nothing if its not. $query = select ID, parentid from ...; $lines = mysql_query($query); $last_id = ''; while (list($ID, $parentid) = mysql_fetch_row($lines)){ $class = $last_id == $parentid ? 'highlight' : 'normal'; echo span class='$class'$ID/spanbr /\n; $last_id = $ID; } -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] threaded comments
On Thu, April 7, 2005 1:17 pm, Sebastian said: i am developing a comment/discussion board and i want to display the results in a threaded style. so far i have it all working except this one issue: each row has an ID and a parentid, say i have 5 rows: id : 10 most oranges come from florida id : 16 Re: most oranges come from florida (parentid 10) id : 22 - Re: most oranges come from florida (parentid 16) id : 24 - Re: most oranges come from florida (parentid 22) id : 28 Re: most oranges come from florida (parentid 16) i want the rows to know the id directly above itself so for example, row 5 (id 28) will some how know its parentid (16) is not directly above it and is not accociated with the result its above (24) i want to 'highlight' a row when the parent it belongs to is directly above and do nothing if its not. $query = select ID, parentid from ...; $lines = mysql_query($query); $last_id = ''; while (list($ID, $parentid) = mysql_fetch_row($lines)){ $class = $last_id == $parentid ? 'highlight' : 'normal'; echo span class='$class'$ID/spanbr /\n; $last_id = $ID; } -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sessions not being stored : DAY 2
running whoami in php returns : root --- On Fri 04/08, Chris W. Parker [EMAIL PROTECTED] wrote: From: Chris W. Parker [mailto: [EMAIL PROTECTED] To: [EMAIL PROTECTED], php-general@lists.php.net Date: Fri, 8 Apr 2005 10:21:16 -0700 Subject: RE: [PHP] sessions not being stored : DAY 2 Yuri Huitrón Alvarado mailto:[EMAIL PROTECTED]bron Friday, April 08, 2005 10:02 AM said:brbr * the /tmp directory is owned by rootbr * the /tmp/sess directory is owned by the apache user and has 777br permissions br * the directory in php.ini to store sessions is : /tmp/sessbr * there's not a php userbrbrTry running the system command 'whoami' within PHP to see what user is being used.brbrbrbrChris.brbr--brPHP General Mailing List (http://www.php.net/)brTo unsubscribe, visit: http://www.php.net/unsub.phpbrbr ___ Join Excite! - http://www.excite.com The most personalized portal on the Web! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[suspicious - maybe spam] [PHP] [suspicious - maybe spam] Re: [PHP] How do I get the first element's key of an array of objects?
Chris W. Parker wrote: Read www.php.net/array_keys and you shall have your answer. From the php docs: ?php $array = array(0 = 100, color = red); print_r(array_keys($array)); ? Will output. Array ( [0] = 0 [1] = color ) Duh! Yes, I replied a little too fast on that one. /Mattias -- More views at http://www.thorslund.us -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] threaded comments
thanks a million, it works. so simple and i tried something similar except i was using parentid at the end of the loop vs the id itself. thanks again, its not the first time you helped me out :) - Original Message - From: Richard Lynch [EMAIL PROTECTED] On Thu, April 7, 2005 1:17 pm, Sebastian said: i am developing a comment/discussion board and i want to display the results in a threaded style. so far i have it all working except this one issue: each row has an ID and a parentid, say i have 5 rows: id : 10 most oranges come from florida id : 16 Re: most oranges come from florida (parentid 10) id : 22 - Re: most oranges come from florida (parentid 16) id : 24 - Re: most oranges come from florida (parentid 22) id : 28 Re: most oranges come from florida (parentid 16) i want the rows to know the id directly above itself so for example, row 5 (id 28) will some how know its parentid (16) is not directly above it and is not accociated with the result its above (24) i want to 'highlight' a row when the parent it belongs to is directly above and do nothing if its not. $query = select ID, parentid from ...; $lines = mysql_query($query); $last_id = ''; while (list($ID, $parentid) = mysql_fetch_row($lines)){ $class = $last_id == $parentid ? 'highlight' : 'normal'; echo span class='$class'$ID/spanbr /\n; $last_id = $ID; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing password in cookie
On Saturday 09 April 2005 02:18, Computer Programmer wrote: What is a better way to store password in a cookie? md5()? base64_encode()? mhash()? mcrypt_generic()? crypt()? It doesn't matter how you encrypt it. DO NOT STORE PASSWORDS ON USERS COMPUTER I hope that's clear enough. What you can do, and in fact I do for production sites is when the user logs on, you create an unique identifier and make a hash from it using your favorite encryption method. (sha1, md5, crc32). I like sha1. Save that hash in a temporary table and link it to the user's ID. Set an exipry date and extend that on each subsequencial request. Additionally you can save the IP number there as well. But that can lead to issues if they are connected trough a firewall, router, or proxy. Think of it as assigning a temporary password, only it is transparent to the user. Structure Login Password Validated Create unique id save in connections table set cookie with unique id and userid Page Request Check for cookie lookup unique id in connections table id expired? No - User still loged in No Cookie Do Login This way, you automatically log out users that are logging in on another computer. Kind regards Andy -- Registered Linux User Number 379093 -- Feel free to check out these few php utilities that I released under the GPL2 and that are meant for use with a php cli binary: http://www.vlaamse-kern.com/sas/ -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php