Re: [PHP] Mysql Select
SELECT DISTINCT(gallery.design) FROM gallery : I want to limit to 1 the same names returned from the query like: [CUT] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ODBC looping on Linux
hello I have some queries in a script on the following environment: Linux Debian Apache 1.3.19 Patched Ben Php 4.0.6 patched UnixODBC driver manager latest version (installed yesterday) freeTDS driver DMBS - MicrosoftSQL 7. I have a few queries: line 15 - connection string line 20: qry nr. 1 - SELECT line 25 qry nr. 2 - SELECT line 30 qry nr. 3 - UPDATE The SELECTs do work. The UPDATE doesn't, THE BROWSER (Mozilla) goes into a looping cicle (re-calling the same page with no end) If I move the UPDATE qry UPDATE up to line 16 immediately after the connection, then it works correctly. Data are updated So, why??? The code sample is as follows - connection string is here --- $SQL_R_AVAILABLE = SELECT top 1 etc etc; $res_r_avail = odbc_exec( $conn, $SQL_R_AVAILABLE ); if ( $res_r_avail ) { odbc_fetch_row($res_r_avail); $sendavailable = odbc_result($res_r_avail, sendavailable); $ttoday = odbc_result($res_r_avail, ttoday); odbc_free_result($res_r_avail); if ( $ttoday == ) { $sql = UPDATE tableT SET ttoday=getdate() where condition; $resUpd = odbc_exec( $conn, $sql ); ^ THIS QUERY MAKES THE SCRIPT (BROWSER) GO IN A LOOP } } // I maybe suspect it's because the result is occupied by the select above but ... don't know what to put before UPDATE to free the resources. odbc_free_result doesn't seem to work.. Thank you all Nicola Delbono /// Il notiziario dei notiziari http://www.notiziarioweb.it/ /// www.smscitta.com | www.musicalbox.it www.filosofo.it | www.bollicine.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Security of PHP code
would be really silly if http://www.php.net/source.php?url=/index.php - Original Message - From: Tim Taubert [EMAIL PROTECTED] To: PHP Mailingliste [EMAIL PROTECTED] Sent: Wednesday, July 04, 2001 5:27 PM Subject: RE: [PHP] Security of PHP code found 2 other servers having the same problem... mailed to the webmasters and admins instead of posting it.. now i feel a little bit better :) Tim Taubert - Tim Taubert | [EMAIL PROTECTED] | http://www.shogunat.com/rg/ - .o] -Original Message- .o] From: Tim Taubert [mailto:[EMAIL PROTECTED]] .o] Sent: Wednesday, July 04, 2001 5:16 PM .o] To: PHP Mailingliste .o] Subject: RE: [PHP] Security of PHP code .o] .o] .o] mh i know it was the wrong decision. didn't think about it. already said that. feeling .o] guilty now .o] *argh* .o] .o] Tim Taubert .o] .o] - .o]Tim Taubert | [EMAIL PROTECTED] | http://www.shogunat.com/rg/ .o] - .o] .o] .o] -Original Message- .o] .o] From: PHPBeginner.com [mailto:[EMAIL PROTECTED]] .o] .o] Sent: Wednesday, July 04, 2001 5:17 PM .o] .o] To: [EMAIL PROTECTED]; PHP Mailingliste .o] .o] Subject: RE: [PHP] Security of PHP code .o] .o] .o] .o] .o] .o] Just for the respect of the community, Tim, you shouldn't have posted that. .o] .o] Poor them, they are under the risks, of course the things will be probably .o] .o] fixed, but if someone cares he might be already in the machine just for the .o] .o] sake of it. .o] .o] .o] .o] -maxim maletsky .o] .o] .o] .o] .o] .o] -Original Message- .o] .o] From: Tim Taubert [mailto:[EMAIL PROTECTED]] .o] .o] Sent: Thursday, July 05, 2001 12:09 AM .o] .o] To: PHP Mailingliste .o] .o] Subject: RE: [PHP] Security of PHP code .o] .o] .o] .o] .o] .o] oh thanks for the disclaimer ;) forgot it.. .o] .o] .o] .o] richard: didn't think about it.. but should have done it.. first and last .o] .o] time i did it *promised* .o] .o] :) .o] .o] .o] .o] Tim Taubert .o] .o] .o] .o] - .o] .o]Tim Taubert | [EMAIL PROTECTED] | http://www.shogunat.com/rg/ .o] .o] - .o] .o] .o] .o] .o] -Original Message- .o] .o] .o] From: PHPBeginner.com [mailto:[EMAIL PROTECTED]] .o] .o] .o] Sent: Wednesday, July 04, 2001 5:09 PM .o] .o] .o] To: [EMAIL PROTECTED]; PHP Mailingliste .o] .o] .o] Subject: RE: [PHP] Security of PHP code .o] .o] .o] .o] .o] .o] .o] .o] .o] Yup, I believe you - that's not your site. .o] .o] .o] .o] .o] .o] That is what I meant: It is no PHP, it is how you use PHP. .o] .o] .o] .o] .o] .o] DISCLAIMER: .o] .o] .o] No one's fault (except the programmer) that there was THAT BIG security .o] .o] hole .o] .o] .o] on the site. .o] .o] .o] .o] .o] .o] -maxim maletsky .o] .o] .o] .o] .o] .o] .o] .o] .o] .o] .o] .o] .o] .o] .o] -Original Message- .o] .o] .o] From: Tim Taubert [mailto:[EMAIL PROTECTED]] .o] .o] .o] Sent: Wednesday, July 04, 2001 11:58 PM .o] .o] .o] To: PHP Mailingliste .o] .o] .o] Subject: RE: [PHP] Security of PHP code .o] .o] .o] .o] .o] .o] .o] .o] .o] you're totally right.. look at this .o] .o] .o] .o] .o] .o] .o] .o] censored** .o] .o] .o] .o] .o] .o] *no comment* and not my site... .o] .o] .o] .o] .o] .o] Tim Taubert .o] .o] .o] .o] .o] .o] - .o] .o] .o]Tim Taubert | [EMAIL PROTECTED] | http://www.shogunat.com/rg/ .o] .o] .o] - .o] .o] .o] .o] .o] .o] .o] -Original Message- .o] .o] .o] .o] From: PHPBeginner.com [mailto:[EMAIL PROTECTED]] .o] .o] .o] .o] Sent: Wednesday, July 04, 2001 4:09 PM .o] .o] .o] .o] To: [EMAIL PROTECTED]; php-general .o] .o] .o] .o] Subject: RE: [PHP] Security of PHP code .o] .o] .o] .o] .o] .o] .o] .o] .o] .o] .o] .o] SECURE, SECURE. .o] .o] .o] .o] .o] .o] .o] .o] It is not how secure PHP is, it is how well YOU protect it. .o] .o] .o] .o] For example = make this line show_source($file); then go to .o] .o] .o] .o] your page like .o] .o] .o] .o] file.php?file=/etc/passwd and you're freaked! .o] .o] .o] .o] .o] .o] .o] .o] There is a whole bunch of way to hack your pages if not protected .o] .o] well .o] .o] .o] .o] enough, but PHP itself has no vital security problems. .o] .o] .o] .o] .o] .o] .o] .o] Try to search the archives for this topic and see what people .o] .o] .o] .o] think/suggest. .o] .o] .o] .o] You will find there thousands of tips on what to do to have a .o] .o] .o] .o]
Re: [PHP] Security of PHP code
maybe one could be ? $allowed_path = /www/sites/mysite/teaching; if (substr($file, 0, str_len($allowed_path)) $allowed_path ) { die(not allowed!); } else { show_source($file); } ? - Original Message - From: Hankley, Chip [EMAIL PROTECTED] To: PHP Mailingliste [EMAIL PROTECTED] Sent: Wednesday, July 04, 2001 5:45 PM Subject: RE: [PHP] Security of PHP code OK, I'm pretty new to PHP, and have been reading this thread, and am just a little freaked. If I understand this right, the only way reason we can view the source code of those pages is that the web server on which the page resides essentially has a PHP page somewhere on their site that has some variation of: ?show_source($file);? as it's content, right? While I can see the utility of that for some situations (teaching...examples, etc.), it seems like a huge potential for security breaches. Is it possible to have such a function on your site w/o giving access to ALL of your documents... Chip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Security of PHP code
Yes, I supposed there could be that eventuality... I supposed or hoped that wasn't a valid path. /usr/local/apache/htdocs/../../../../etc/passwd as path.. I'm not very practice of paths... actually On Wed, 4 Jul 2001, Steve Werby wrote: Jon Haworth [EMAIL PROTECTED] wrote: Yes, I would have thought this would do it: if (strstr($file, /usr/local/apache/htdocs/) { show_source($file); [..] Something along those lines will work. Without some kind of limitations built in, the page will be able to load any file that's world-readable so it's a good idea to limit access to certain directories or hardcode the directory you want to give access to. Imagine someone passing in /usr/local/apache/htdocs/../../../../etc/passwd as path.. - Sascha Experience IRCG http://schumann.cx/http://schumann.cx/ircg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] emalloc / erealloc problem (was: help with custom session handler)
I had the same problem whenever retrieving data from MSSQL using ODBC from a NULL field. To solve the problem I had to add a character asd default to that field. I added a dot. descr nvarchar default '.' . (the sql sintax here is not the correct one.) - Original Message - From: Aral Balkan [EMAIL PROTECTED] To: Rasmus Lerdorf [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Sunday, July 01, 2001 1:52 AM Subject: Re: [PHP] emalloc / erealloc problem (was: help with custom session handler) Well finally I am 99.9% sure that the problem is with Metabase. I've managed to bring the code down to the absolute minimum to simplify things and I can now state the bug clearly: On Pentium III 500Mhz running WinMe, Apache 1.3.19 and PHP 4.0.5, use of Metabase calls in custom session handler to update a MySQL database randomly crash Apache with (again, randomly) errors in either PHP4TS.DLL or MSVCRT.DLL. When Apache does not crash, the code does work (I tested this with a simple variable increment). When the Metabase session handler is replaced with one using MySQL calls, the problem goes away. Entries noticed in Apache's error.log that may be related are: FATAL: emalloc(): Unable to allocate 1701082243 bytes FATAL: erealloc(): Unable to allocate 369098752 bytes I've already written to Manuel about this and I'm sure he'll have the problem figured out in no time but in the meanwhile, I'm posting my code here so that this post may benefit others trying to do this in the future (and with the hope that maybe someone can discover something that *I'm* doing wrong that could be causing all this!) ?php /* metabase sesssions library error: makes Apache crash randomly with errors in PHP4TS.DLL and MSVCRT.DLL running on WinMe with Apache 1.3.19 and PHP 4.0.5 based on the code of Sterling Hughes (PHP Developer's Cookbook, pgs. 222 - 224) and Ying Zhang (PHPBuilder, Custom Session Handlers in PHP4, http://www.phpbuilder.com/columns/ying2602.php3?page=1) metabase by Manuel Lemos ([EMAIL PROTECTED], http://www.phpclasses.upperdesign.com/) copyright (c) 2001, aral balkan ([EMAIL PROTECTED]) http://www.aralbalkan.com */ // metabase database abstraction layer require_once metabase/metabase_parser.php; require_once metabase/metabase_manager.php; require_once metabase/metabase_database.php; require_once metabase/metabase_interface.php; $SESS_LIFE = get_cfg_var('session.gc_maxlifetime'); // default life of session to an hour if ($SESS_LIFE == '') { $SESS_LIFE = 3600; } function on_session_start ($save_path, $session_name) { global $database; /* db_init.php holds the values for $db_type, $db_user, $db_pass, $db_host */ require_once('db_init.php'); $metabase_init = array( Type=$db_type, User=$db_user, Password=$db_pass, Host=$db_host, IncludePath=metabase/, Persistent=TRUE ); $metabase_error = MetabaseSetupDatabase($metabase_init, $database); if ($metabase_error != '') { die('Database setup error: '.$metabase_error); return false; // failure } // select database $previous_database_name = MetabaseSetDatabase($database, $db_name); return true; } function on_session_end() { // Nothing needs to be done in this function // since we used a persistent connection return true; } function on_session_read ($key) { global $database; $key = MetabaseGetTextFieldValue($database, $key); $stmt = SELECT sessionData FROM sessions; $stmt .= WHERE sessionID = $key; $stmt .= AND sessionExpire . time(); if (!($result = MetabaseQuery($database, $stmt))) { // query failed echo ' Main query (sql) failed.'.$e; echo ' Error: '.MetabaseError($database).$e; die(); } $stmt_rows = MetabaseNumberOfRows($database, $result); if ($stmt_rows) { $sessionData = MetabaseFetchResult($database, $result, 0, 'sessionData');; return($sessionData); } else { return false; } } function on_session_write ($key, $val) { global $session_db, $SESS_LIFE; global $database; // convert the text value to a format suitable for use in current database $expiry = time() + $SESS_LIFE; $key = MetabaseGetTextFieldValue($database, $key); $val = MetabaseGetTextFieldValue($database, $val); $replace_stmt = REPLACE INTO sessions (sessionID, sessionData, sessionExpire) . values($key, $val, $expiry); $success = MetabaseQuery($database, $replace_stmt); return $success; } function on_session_destroy ($key) { global $database; $key = MetabaseGetTextFieldValue($database, $key); $stmt = DELETE FROM sessions WHERE sessionID = $key; $success = MetabaseQuery($database, $stmt); return $success; } function on_session_gc ($max_lifetime) { global $database; $stmt = delete from sessions where sessionExpire . time(); $success = MetabaseQuery($database, $stmt); return $success; } // Set the save handlers
Re: [PHP] Week Number
You can use Date_Calc class http://www.phpinsider.com/php/code/Date_Calc/ - Original Message - From: Don Read [EMAIL PROTECTED] To: Matt TrollBoy Wiseman [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, June 29, 2001 10:19 PM Subject: RE: [PHP] Week Number On 28-Jun-01 Matt \TrollBoy\ Wiseman wrote: Does know of anyway to get PHP to return the week number? As in there are 52 weeks in a year and this is week x? don't bet on it. If there is no internal feature, perhaps something built into PHPLib? date('z') / 7; strftime('%U %V %W'); Regards, -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Parse error: Needs T_VARIABLE or $
Try this: $r = trim($rowData[3]); if ( !empty( $r ) ) { $tdStr.= trim($rowData[3]); } I tokk a look at the manual: 1. Note: empty() is a language construct. so: !empty is like to say !if or !while : so it's wrong- 2. Note that this is meaningless when used on anything which isn't a variable; i.e. empty (addslashes ($name)) has no meaning since it would be checking whether something which isn't a variable is a variable with a false value. - Original Message - From: Jason Lustig [EMAIL PROTECTED] To: Php-General@Lists. Php. Net [EMAIL PROTECTED] Sent: Friday, June 29, 2001 11:55 PM Subject: [PHP] Parse error: Needs T_VARIABLE or $ This is really weird. Very, very, very weird. I have the following code in a script: if (!empty(trim($rowData[3]))) { $tdStr.= trim($rowData[3]); } Now, when I run it, I get the following error: Parse error: parse error, expecting `T_VARIABLE' or `'$'' in c:\server\wwwroot\contributors.php on line 70 (note: line 70 is the first liine of the code snippet above) Now, this shouldn't be a problem. There is no problem with the parens, and I don't see anything wrong with the code. Can someone help me out with this? This is happening in another script (when I use the empty() function) and it is really weird... --Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Function
you can use array_walk array_walk (PHP 3= 3.0.3, PHP 4 = 4.0b1) array_walk -- Apply a user function to every member of an array Description int array_walk (array arr, string func, mixed userdata) - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, June 28, 2001 10:48 AM Subject: [PHP] Function Hi, Is there any function to replace a character in an Array ??. Thanx in adv. ~ Karthick. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Filtering out \ when a ' is user entered?
Hello, I had the same problem: So I tried stripslashes.. But Queries do break if unslashed ' or are present. and furthermore, there are many other problems .. So I created a function called entities.. Let's imagine a user made an input of name: Simon The Snake surname:O'Connors you can simply call the function like this: entities($HTTP_POST_VARS); and you'll have echo $name; // will produce:Simon #034;The Snake#034; $surname = // will produce:O#039;Connors /* = $description = book's description; = $title = book's title ; = $arr = array(description=$description,title=$title); = entities($arr); returns variables, but with entities and other things changed- ie: $title= book#39;s title; $description= book#39;s description; or just simply: entities($HTTP_POST_VARS) for variables passed from one page to another */ function entities($arr) { $arrct = count($arr); for(reset($arr); $key = key($arr); next($arr)) { global $$key; $$key = htmlentities($arr[$key]); $$key = stripslashes($$key); $$key = str_replace(',#039;,$$key); $$key = str_replace('',#034;,$$key); } } It's basically something like array_walk. - Original Message - From: Richard Lynch [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, June 27, 2001 10:30 AM Subject: Re: [PHP] Filtering out \ when a ' is user entered? I'm pretty new to PHP but all I've seen of it so far I pretty much love! I've built a web log but when the user enters their data and they use ' or (and you know they will) php always shows it from the included web log as \' How can I filter out these backslashes so they don't appear on the final public viewable page? You need those \ in there to store it into a database. If you don't use a database, you can turn MagicQuotes off in php.ini If you *do* use a database, you can use http://php.net/stripslashes to strip out the slashes. If, after turning off MagicQuotes, or calling stripslashes, you find you need them back in there after all for something, you use http://addslashes -- WARNING [EMAIL PROTECTED] address is an endangered species -- Use [EMAIL PROTECTED] Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Adding a line of text to every page PHP spits out
you can use auto_prepend - Original Message - From: Brandon Orther [EMAIL PROTECTED] To: PHP User Group [EMAIL PROTECTED] Sent: Wednesday, June 27, 2001 9:51 PM Subject: [PHP] Adding a line of text to every page PHP spits out Hello, I want to have a DOC Type ate the top of every PHP script I run. Is there a way to edit the PHP.ini to make PHP spit out a line of text before echoing anything? Thank you, Brandon Orther WebIntellects Design/Development Manager [EMAIL PROTECTED] 800-994-6364 www.webintellects.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] user tool to admin groups, subgroups, and users.
Is there any? I need to create a tool for creating administering users like this. user1, user2, user3, etc.. Under user1 there are subuserA, subuserB, subuserC, etc.. Under subuserA there are many other users... it's like a piramyd. Does anyone know any link about such a tool? Thanks Nicola -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] sorting multi-dimensional arrays
Try this (it should work): while(list($k, $v) = each($myarray)){ $myarray[$k] = (int) $v; } arsort($myarray); reset($myarray); while(list($k, $v) = each($myarray)){ echo $k, ' == ', $v, "BR\n; } For better comprehension look at this post: Hey guys.. I have this array that looks like this: $myarray = ( "apples" = 0, "oranges" = 2, "peaches" = 9, "pineapples" = 12, "stovetopstuffing" = 3, "grits" = 8); Fine and dandy. But, when I try to sort it in reverse order: arsort($myarray); I get THIS for output, obviously NOT what I want: peaches = 9 grits = 8 stovetopstuffing = 3 oranges = 2 pineapples = 12 apples = 0 Obviously, I want the pineapples entry to be at the top, since it has the highest value. What do I need to do? You have stored strings as your values, instead of ints. IE:(string) '9' (string) '12' returns TRUE You will need to take care in creating your array to have (int) values instead of strings. If all else fails, the following should work: while(list($k, $v) = each($myarray)){ $myarray[$k] = (int) $v; } arsort($myarray); reset($myarray); while(list($k, $v) = each($myarray)){ echo $k, ' == ', $v, "BR\n; } - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, April 14, 2001 5:19 AM Subject: [PHP] sorting multi-dimensional arrays I have a question about sorting multidimensional arrays. Here is my problem: I have an 2-d array: $joke[1][rating]=10; $joke[2][rating]=20; $joke[3][rating]=15; I would like to sort the jokes into an array based on the rating from highest to lowest. The end result would be something like this: Joke 2 : 20 points Joke 3: 15 points Joke 1: 10 points How do I accomplish this? I have tried fooling around with sort(), arsort(), and array_multisort(), but I just can't get it. Thank you very much for your time. Shane -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] sorting multi-dimensional arrays
hh, no, maybe the samplecode I posted it's not your case, sorry... I have a question about sorting multidimensional arrays. Here is my problem: I have an 2-d array: $joke[1][rating]=10; $joke[2][rating]=20; $joke[3][rating]=15; I would like to sort the jokes into an array based on the rating from highest to lowest. The end result would be something like this: Joke 2 : 20 points Joke 3: 15 points Joke 1: 10 points How do I accomplish this? I have tried fooling around with sort(), arsort(), and array_multisort(), but I just can't get it. Thank you very much for your time. Shane -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Building an array from a URL
I think the function parse_str does exactly what you want. http://www.php.net/manual/en/function.parse-str.php - Original Message - From: "Knut H. Hassel Nielsen" [EMAIL PROTECTED] To: "Mike Gifford" [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, April 04, 2001 6:12 PM Subject: Re: [PHP] Building an array from a URL Did you try to see if $HTTP_GET_VARS can help you ? Its an array of every variable posted by GET (the way you described) Else : Split the different key/values with the delimiter '' and thereafter split the elements in the array by '=' But first split the string into page and variables : list( $page, $str ) = split("?","superRSS.phtml?150=1150superRSS166=1166superRSS168=1168superRS S175=1188"); function make_arr_from_str( $str ) { $exp_arr = Explode( "", $str ); $new_arr = Array(); for ( $i = 0 ; $i count( $exp_arr ) ; $i++ ) { list( $key, $val ) = split( "=", $exp_arr[ $i ] ); $new_arr["$key"] = $val; } return $new_arr; } $array = make_arr_from_str( $str ); var_dump($array); On Wed, 4 Apr 2001, Mike Gifford wrote: Hello, I'm trying to build an array out of data submitted from a URL. Essentially, I want to pull certain records out of a database which have been selected on another form. The URL presently looks like this: superRSS.phtml?150=1150superRSS166=1166superRSS168=1168superRSS175=1188 I'd like to take these independent variables and merge them into a single array: $array_superRSS = implode (":", $superRSS[]); So I can then pipe these values directly into another function: while ($array_superRSS) { display_superRSS($array_superRSS[]); } Obviously I'm missing a step or two here, but would really appreciate someone filling in some of the gaps. Thanks! Mike -- Knut -- Knut H. Hassel Nielsen Principal Engineer / Avdelingsingenir Norwegian University of Science and Technology / NTNU Department of Computer and Information Science / IDI N-7491 Trondheim, Norway Phone Office / Telefon jobb : (+47) 73 59 18 46 Fax Office / Telefax jobb : (+47) 73 59 17 33 Cell. Phone / Mobiltelefon : 91 59 86 06 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] send a mail
To me, the SMTP in php.ini is wrongly configured. Secondo me settato male l'SMTP nel php ini. Ciao Hi, I am new of php I have a file: send.php3 c:\type f:/http/php/send.php3 ? mail("[EMAIL PROTECTED]", "Subject test", "test text"); ? c:\ when I get the page from my web server(apache under Win NT), the mail is sent correctly, but the browser is hung for 30 seconds, and after I have the following error: Fatal error: Maximum execution time of 30 seconds exceeded in f:/http/php/send.php3 on line 4 Someone can help me? Thanks Emanuele -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Maximum execution time
put this line set_time_limit(500) ; at the beginning of your script if you want to enlarge execution time for 500 seconds. - Original Message - From: "Liam Gibbs" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, January 23, 2001 4:48 PM Subject: [PHP] Maximum execution time Can anyone tell me how to up the max. execution time in PHP? I know it's been said before, but I can't remember how it's done. Liam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] R: [PHP] Can a PHP program recieve an e-mail and write it to a file???
It depends on your MAIL SERVER (and on your OS.) For Linux I think SendMail can forward mails to an external program For WinNT I know POSTOFFICE allows this. But PostOffice is commercially released not for free. In this case the mails are redirected to the program via STDIN Bye N. -Messaggio originale- Da: Jeremy Bowen [EMAIL PROTECTED] A: [EMAIL PROTECTED] [EMAIL PROTECTED] Data: gioved 18 gennaio 2001 20.32 Oggetto: [PHP] Can a PHP program recieve an e-mail and write it to a file??? Hey, Here is what I need to do, I need to have a PHP script recieve an e-mail and write it to a file after erasing whatever was in the file before. I suppose that it should have some sort of authentication built in to prevent people from e-mailing PHP code that could be processed and do bad things. Is there any way to do this? Can a PHP script recieve and e-mail? Could the e-mail be written to a mail queue say [EMAIL PROTECTED] and the script periodically check the mail queue for new e-mail print its contents to a text file somewhere in the serverroot and then erase the mail queue??? Does this sound possibile??? Thanks, Jeremy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]