[PHP] mail() function dying half way through.
PHP List, I have a database of about 120 users. Each weak I send out a newsletter. So far as I know, it's been working fine for the last couple of years. Then recently some users emailed me to let me know that they haven't been receiving all the messages. I added extra output to my script to echo out the name of each member that got an email sent to them, and I can now see that only about 50 of them are getting the email. The only think that has changed that I can think of is that I've upgraded to MySQL 5.0. However, given the type of problem I'm having, I don't think it's a MySQL problem, it appears much more likely to be a problem with my PHP code. This is the script that sends out the message (edited slightly to take out irrelevant bits of newsletter content): - - - - $count = 0; while ( $member = mysql_fetch_row($result) ) { set_time_limit(0); $subject = Newsletter subject line; $mailcontent = This message was sent to . $member[0] . at {$member[1]} Blah, blah, blah - newsletter content goes here.; mail($member[1], $subject, $mailcontent, $fromaddress); $count++; echo pNewsletter sent to . $member[0] . at . $member[1] . /p; } echo pA total of .$count . emails were sent out./p\n; - - - - The script actually dies before it gets to the last echo which echoes the value of $count. It outputs about 50 lines of Newsletter sent to usersname at [EMAIL PROTECTED] and then the cursor is stuck in hourglass mode and the browser is continually waiting a response. It stays like that indefinitely, and the only way it stops is if I go to another page or shut down the browser. I have heard that the mail() function does have limitations on how many emails it sends out. But I thought it took hundreds, somewhere between 500 and a thousand, of individual emails before it would die. And I also thought the set_time_limit(0) function would alleviate the problem of timing out. Where have I gone wrong with this? Any advice would be greatly appreciated. Thank you for taking the time to read this. -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update table to get consecutive Primary keys
On Thursday 08 June 2006 23:58, Antonio Bassinger wrote: Hi All! I've a MySQL table: table (id INT NOT NULL AUTO_INCREMENT, flag TINYINT NOT NULL, msgID VARCHAR(30) NOT NULL, msgName VARCHAR(30), size INT NOT NULL, PRIMARY KEY(id)); If I delete a row, say 5th, the id entries are 1 2 3 4 6 7 ... 10. I wish to keep entries consecutive, that is rearrange the table as 1 2 3 4 5 6 ... 9. How do I go about it? Thanks Regards, Antonio Simple. Don't. The whole point of having a numeric primary key is that it is both unique and constant. If you change the primary key, then you have to change every reference to it in every other table as well. You've just defeated the purpose of having a non-user-viewable primary key in the first place. You may as well just use the msgName field, save yourself a column in the database, and still have a huge problem with data integrity. As I said, don't do it. Stick with the numeric ID and don't change it. You gain nothing by re-naming your entire database. -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail() function dying half way through.
Dave M G wrote: PHP List, I have a database of about 120 users. Each weak I send out a newsletter. So far as I know, it's been working fine for the last couple of years. Then recently some users emailed me to let me know that they haven't been receiving all the messages. I added extra output to my script to echo out the name of each member that got an email sent to them, and I can now see that only about 50 of them are getting the email. The only think that has changed that I can think of is that I've upgraded to MySQL 5.0. However, given the type of problem I'm having, I don't think it's a MySQL problem, it appears much more likely to be a problem with my PHP code. This is the script that sends out the message (edited slightly to take out irrelevant bits of newsletter content): - - - - $count = 0; while ( $member = mysql_fetch_row($result) ) { set_time_limit(0); $subject = Newsletter subject line; $mailcontent = This message was sent to . $member[0] . at {$member[1]} Blah, blah, blah - newsletter content goes here.; mail($member[1], $subject, $mailcontent, $fromaddress); $count++; echo pNewsletter sent to . $member[0] . at . $member[1] . /p; } echo pA total of .$count . emails were sent out./p\n; - - - - The script actually dies before it gets to the last echo which echoes the value of $count. It outputs about 50 lines of Newsletter sent to usersname at [EMAIL PROTECTED] and then the cursor is stuck in hourglass mode and the browser is continually waiting a response. It stays like that indefinitely, and the only way it stops is if I go to another page or shut down the browser. I have heard that the mail() function does have limitations on how many emails it sends out. But I thought it took hundreds, somewhere between 500 and a thousand, of individual emails before it would die. And I also thought the set_time_limit(0) function would alleviate the problem of timing out. Ask your host if they have enabled email throttling. If you're sending out too quickly, they might be getting cut off by your host and you'll need to sleep() between each email being sent. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] substring with numric values
Is there any easy way to trim or pick out the none decimal values in a numric value? Like: 1,333 = 1 5,667 = 5 12,145 = 12 15,997 = 15 Thanks // Jonas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] substring with numric values
Jonas Rosling wrote: Is there any easy way to trim or pick out the none decimal values in a [numeric] value? Like: 1,333 = 1 5,667 = 5 12,145 = 12 15,997 = 15 $variable = 1,333; $trimmed = (int)$variable; # = 1 David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] xml validation
Hi all , Thanks to everbody in this group , really help me a lot. I have a raw xml file from our clients. My question is how to validate the xml file if the file is xml compliance ? Thanks - weetat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: order of elements in $_POST super global
On 08 June 2006 16:20, Ben Liu wrote: I probably should add some more details to my question: The names of the form checkboxes could be changed from ie: bool_careers, bool_speaking, bool_internship, etc. to a single array bool_questions[], for instance. The problem with that is that I am using the form checkbox names later to process related data. Specifically, I am building a user-input based query. So if the form checkbox names are the same as the names of the variables in the database, it makes for easy creating of the query, since the names become associative keys in the $_POST array. I iterate through the $_POST array, checking each for true/false state. I know you've found another (perfectly good) solution already, but I just wanted to point out that you could have used the above scenario with the names as the array indexes, like: input type=checkbox name=bool_questions[first_name] value=yes The above input shows up in $_POST['bool_questions']['first_name'], so you could iterate over $_POST['bool_questions'] to get the result you want. To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Job offers in Munich, Germany
Hi, We're a small company (~ 70 ppl) co-located on the Siemens AG campus in Munich, Germany. We're into Digital Forms, Digital Pen Paper and Web2Print Solutions, In particular we are mostly dealing with solution business for large scale customers. Our existing platform is PHP based, running on Linux of course. For further development and solution implementations we are looking for 2 skilled PHP and Linux freaks, for permanent employment preferrably but also contract-based, at your option. Additionally, we seek a freelance PHP coder for integration of several free php based projects in a centralized portal based on AWF and regular maintennance. For experienced, solution-oriented PHP/Linux gurus with a proven track record and strong understanding of software design processes and object orientation we offer exceptional payment and a very relaxed working environment in a team of young people. Working from home is possible a well, however, attendance at regular meetings in Munich is required. Good english and/or german is a obvious requirement. Please contact me via email with any questions you might have or apply with a short resume, a tack record and/or code samples of yor previous PHP work. No contractor companies, please. Thank you, / pit -- Karl Pitrich, CTO RED trade GmbH Wittelsbacherplatz 2 c/o Siemens AG, Geb. 00 - Raum 142 D - 80333 München -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Multidimension Array
Hi all , I have the arrays as shown below : How to get the array value in the [TBA04490054] and [JAE070406RT] ? For example , [0] = 'SAD04520AZD' ,[1]= 'SAL04430RE9' and so on. Anybody have any ideas or suggestions how to do it ? Thanks - weetat Array ( [TBA04490054] = Array ( [0] = SAD04520AZD [1] = SAL04430RE9 [2] = SAL04430M00 ) ) Array ( [JAE070406RT] = Array ( [0] = JAE070406RT [1] = JAB023808EC [2] = JAB030704WM ) ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multidimension Array
On 6/9/06, weetat [EMAIL PROTECTED] wrote: How to get the array value in the [TBA04490054] and [JAE070406RT] ? For example , [0] = 'SAD04520AZD' ,[1]= 'SAL04430RE9' and so on. Anybody have any ideas or suggestions how to do it ? Thanks - weetat Array ( [TBA04490054] = Array ( [0] = SAD04520AZD [1] = SAL04430RE9 [2] = SAL04430M00 ) ) Array ( [JAE070406RT] = Array ( [0] = JAE070406RT [1] = JAB023808EC [2] = JAB030704WM ) ) You can access the elments like: echo $arr['TBA04490054'][0]; Create new sub elements like: $arr['TBA04490054'][] = 'JAE...'; Manual: php.net/manual/en/language.types.array.php Rabin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] binary zero evaluates as true!?
On 09 June 2006 04:11, D. Dante Lorenso wrote: Jon wrote: The second thing that needs to be said here is simply a re-statement of the original, this time more verbosely. The list of things in php that evaluate as false is as follows: * the boolean FALSE itself * the integer 0 (zero) * the float 0.0 (zero) * the empty string, and the string 0 * an array with zero elements * an object with zero member variables (PHP 4 only) * the special type NULL (including unset variables) * SimpleXML objects created from empty tags now, all i'm saying is that if, of all ungodly things, the literal string 0 and empty arrays evaluate to false, isn't it appropriate to expect a binary zero to evaluate to false as well? Maybe i still don't get it. :( Jon, You are correct about the behavior you are observing, sorry I doubted your ability/methods. Here is a much shorter example of what you are trying to do: ?php // start with int '0' $as_int = (int) 0x0; var_dump($as_int); // convert into to binary string $as_binstr = (string) pack('C', $as_int); var_dump($as_binstr); // cast binary string as boolean $as_bool = (boolean) $as_binstr; var_dump($as_bool); // int(0) // string(1) !~unprintable~! // bool(true) You want to know WHY a single byte of all 8 bits set to '0' does not evaluate as FALSE. I don't know the answer, See above definition of what evaluates to FALSE. The string you have is a one-character string containing the character NUL (0x00). It is not the empty string, and it is not the string 0. Ergo it is TRUE, QED. Oddly, if you start with this in the example above: $as_int = (int) 48; Then, the is_bool will be false! Well, that makes sense. 48 is the ASCII code for the character '0', so packing it in the above fashion will result in the string 0. Which is by definition FALSE. Nothing odd there. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: XPath avg(), min(), max() functions not found
Rob Richards wrote: min(), max() and avg() don't exist in XPath 1.0 which is the version implemented in libxml2. You need to calculate these yourself. For example: Thanks for your help. Alex -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restrict uploaded scripts
Mathias: So what's wrong with either naming each file with a unique name or placing each file in a unique folder? If it's unique, then how can they overwrite it? I must not be understanding what you want. tedd At 7:24 AM +0200 6/9/06, Mathias Bundgaard Svesson wrote: Wouldn't they still be able to overwrite each other? I don't think I expressed myself clearly. The point of the protection is to keep the scripts from overwriting each other on purpose. It was a protection that would make it posible to upload scripts, even if you were not completly sure they were safe. tor, 08 06 2006 kl. 17:30 -0400, skrev tedd: At 10:37 PM +0200 6/8/06, Mathias Bundgaard Svesson wrote: Restrict them not to overwrite other modules or overwrite the CMS itself. Each module should have it's own directory, and it shouldn't be allowed to change anything outside it. tor, 08 06 2006 kl. 21:49 +1000, skrev chris smith: On 6/8/06, Mathias Bundgaard Svesson [EMAIL PROTECTED] wrote: Hi! I'm trying to create a CMS where it should be posible to upload script modules. Those modules should mostly be made by myself, but it is posible for others to create scripts too. My question is, is it posible to restrict the modules to their own directory so they don't overwrite some of the other modules or the CMS itself? Mathias: Well then, how about this? You can create a uniquely named id by using: $unique_id = md5(uniqid(microtime(), true)); and then use that name as a folder for each person submitting scripts OR use the unique id as a suffix for their cms file. Either way, it should stop persons from overwriting cms files. I would also suggest that you keep track of these id's in a dB. If you are still concerned about two people having the same unique, then you could search the dB to see if the recently created id exist. If it does, then generate another one. I use a similar method for making sure that the images I upload have unique names. hth's tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] xml validation
[snip] Thanks to everbody in this group , really help me a lot. I have a raw xml file from our clients. My question is how to validate the xml file if the file is xml compliance ? [/snip] http://www.php.net/xml -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] xml validation
This article has some good information about PHP/XML including validation: http://www.zend.com/php5/articles/php5-xmlphp.php -Brad weetat wrote: Hi all , Thanks to everbody in this group , really help me a lot. I have a raw xml file from our clients. My question is how to validate the xml file if the file is xml compliance ? Thanks - weetat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Differentiating between POST from an application or browser
Hello, In our product, we use PHP for webservices that is inbuilt in the app. Basically, the tool calls the PHP over which is hosted over internet and communicates using XML. We send the data as raw post and in the PHP we get it as: $xmlrcvd = file_get_contents(“php://”); Now if the user accesses the page from the browser then no POST is sent and strlen($xmlrcvd) would be 0 which is correct. But file_get_contents(..) is only available from 4.3.0 and above. Calling the script below that version throws up a fatal error. I would like to check the PHP version before the above statement but would like to show different message if the file is requested by -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.8.3/359 - Release Date: 6/8/2006 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: order of elements in $_POST super global
Hi Mike, Thanks for pointing that out. I hadn't thought of it but you are right. But I still don't think this addresses the issue of ordering. The basic problem is that the way a $_POST variable gets processed is in the order it is in on the original form. If you want to present the fields in one manner and process them in a different order, you have to either use styling tricks to change the presentation order or use some post processing to change the order of the array or use potentially a ton of if statements or as Joao suggests, a long switch statement. Anyhow, thanks for the tip. - BL On 6/9/06, Ford, Mike [EMAIL PROTECTED] wrote: I know you've found another (perfectly good) solution already, but I just wanted to point out that you could have used the above scenario with the names as the array indexes, like: input type=checkbox name=bool_questions[first_name] value=yes The above input shows up in $_POST['bool_questions']['first_name'], so you could iterate over $_POST['bool_questions'] to get the result you want. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Restrict uploaded scripts
Wouldn't they still be able to overwrite each other? I don't think I expressed myself clearly. The point of the protection is to keep the scripts from overwriting each other on purpose. It was a protection that would make it posible to upload scripts, even if you were not completly sure they were safe. So, you are concerned that someone will write a script that when RUN could purposely overwrite some other files. If I had people uploading their own code to my server, I would be concerned as well. In fact, 'concerned' is not quite a strong enough word. As far as I know, when the uploaded script runs, it will have all the same permissions that the user the webserver runs as has. So there would be no (easy) way to control the possibility that it will overwrite files, add records to your database, launch an attack on another host, send 100,000 spam messages to the whitehouse, download porn and email it to your minister, etc, etc, etc... JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] parsing out quoted text
$str='bass electric organ bagpipes'; $parser($str); $query=SELECT * FROM table WHERE tb_instr = bass AND tb_instr = electric organ //quoted phrase AND tb_instr = bagpipes; Anybody know where I can just copy code that will do the above? thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: order of elements in $_POST super global
Hello, The basic problem is that the way a $_POST variable gets processed is in the order it is in on the original form. I think it's very natural behaviour. But be careful with associative arrays, I think before version 5.12.there was a bug, if you want that PHP makes an associative array of form elements. http://bugs.php.net/bug.php?id=37276 Enjoy Mindaugas On 6/9/06, Ben Liu [EMAIL PROTECTED] wrote: Hi Mike, Thanks for pointing that out. I hadn't thought of it but you are right. But I still don't think this addresses the issue of ordering. The basic problem is that the way a $_POST variable gets processed is in the order it is in on the original form. If you want to present the fields in one manner and process them in a different order, you have to either use styling tricks to change the presentation order or use some post processing to change the order of the array or use potentially a ton of if statements or as Joao suggests, a long switch statement. Anyhow, thanks for the tip. - BL On 6/9/06, Ford, Mike [EMAIL PROTECTED] wrote: I know you've found another (perfectly good) solution already, but I just wanted to point out that you could have used the above scenario with the names as the array indexes, like: input type=checkbox name=bool_questions[first_name] value=yes The above input shows up in $_POST['bool_questions']['first_name'], so you could iterate over $_POST['bool_questions'] to get the result you want. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Mindaugas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: order of elements in $_POST super global
Hi Mindaugas, I wasn't trying to imply that there was something wrong or illogical about the way the $_POST variable is processed. It is logical that it processes in the order listed in html. Perhaps I should have said, my problem rather than the problem. I'll be sure to read about the bug you mention. Thanks. - BL On Jun 9, 2006, at 8:54 AM, Mindaugas L wrote: Hello, The basic problem is that the way a $_POST variable gets processed is in the order it is in on the original form. I think it's very natural behaviour. But be careful with associative arrays, I think before version 5.12.there was a bug, if you want that PHP makes an associative array of form elements. http://bugs.php.net/bug.php?id=37276 Enjoy Mindaugas On 6/9/06, Ben Liu [EMAIL PROTECTED] wrote: Hi Mike, Thanks for pointing that out. I hadn't thought of it but you are right. But I still don't think this addresses the issue of ordering. The basic problem is that the way a $_POST variable gets processed is in the order it is in on the original form. If you want to present the fields in one manner and process them in a different order, you have to either use styling tricks to change the presentation order or use some post processing to change the order of the array or use potentially a ton of if statements or as Joao suggests, a long switch statement. Anyhow, thanks for the tip. - BL On 6/9/06, Ford, Mike [EMAIL PROTECTED] wrote: I know you've found another (perfectly good) solution already, but I just wanted to point out that you could have used the above scenario with the names as the array indexes, like: input type=checkbox name=bool_questions[first_name] value=yes The above input shows up in $_POST['bool_questions'] ['first_name'], so you could iterate over $_POST['bool_questions'] to get the result you want. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Mindaugas smime.p7s Description: S/MIME cryptographic signature
RE: [PHP] parsing out quoted text
Set your string to an array and use the elements in your query. Jef -Original Message- From: sam [mailto:[EMAIL PROTECTED] Sent: Friday, June 09, 2006 6:53 AM To: PHP Subject: [PHP] parsing out quoted text $str='bass electric organ bagpipes'; $parser($str); $query=SELECT * FROM table WHERE tb_instr = bass AND tb_instr = electric organ //quoted phrase AND tb_instr = bagpipes; Anybody know where I can just copy code that will do the above? thanks -- 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] parsing out quoted text
$str='bass electric organ bagpipes'; $parser($str); $query=SELECT * FROM table WHERE tb_instr = bass AND tb_instr = electric organ //quoted phrase AND tb_instr = bagpipes; Anybody know where I can just copy code that will do the above? thanks Why will there be a quoted string in the database? If the data is properly escaped there will be no need for this. Also, how can tb_str have three differing values? The query is flawed. Unless I have been in the sun for too long. Tell us in more detail what you are trying to do. -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon!
[PHP] Set PDO to ALWAYS return fetched rows with PDO::FETCH_ASSOC?
I am trying to go through the PDO documentation to set up PDO to always use PDO::FETCH_ASSOC instead of being forced to include this attribute on each and every fetch call. Can anyone tell me if there is a setAttribute value I can set when I create the db connection handler that I reuse throughout my code? Thanks Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parsing out quoted text
sam a écrit : $str='bass electric organ bagpipes'; $parser($str); $query=SELECT * FROM table WHERE tb_instr = bass AND tb_instr = electric organ //quoted phrase AND tb_instr = bagpipes; Anybody know where I can just copy code that will do the above? you wish to split $str and keep what's between the intact ? you can split with spaces, then parse the array and treat difefrently if the first character of your element is a . $query = SELECT *FROM table WHERE ; $array = split ($str, ); foreach ($array as $element) { // element if ( substr($element,0,1) == \ ) { $quoted_element = $element; } // element elseif ( substr($element,strlen($element)-1,1) == \ ) { $query .= tb_instr = \.$quoted_element. .$element.\ AND ; $quoted_element = ; } // element after element elseif ($quoted_element != ) { $quoted_element .= .$element; } else { $query .= tb_instr = \.$element.\ AND ; } } // remove the last AND // please check if 4 or 5 characters to remove, 5 should be fine $query = substr ($query,0,strlen($query)-5); print $query; N F thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parsing out quoted text
sam wrote: $str='bass electric organ bagpipes'; $parser($str); $query=SELECT * FROM table WHERE tb_instr = bass AND tb_instr = electric organ //quoted phrase AND tb_instr = bagpipes; Anybody know where I can just copy code that will do the above? The following was just pushed out of my rear end at great personal expense and may not cover all possibilities, but should be enough for you to build on... ?php $str = 'bass electronic organ bagpipes'; preg_match_all('/\(.*?)\/i', $str, $matches); $words = array(); foreach ($matches[0] as $match) { $words[] = substr($match, 1, -1); $str = str_replace($match, '', $str); } foreach (explode(' ', $str) as $word) { $word = trim($word); if (strlen($word) 0) $words[] = $word; } print_r($words); ? Also, your SQL query will not work. tb_instr *cannot* be equal to all three strings at the same time.You either want to be using OR not AND, or you should be using LIKE instead of = with some %s thrown into the strings for good measure. Check the MySQL manual for details. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] arrays
if I have two arrays, example: $a = array (one, two, three, four, two); $b = array (seven, one, three, six, five); How can I get in another variable a new array with the same elements into $a and $b. -- Este mensaje ha sido analizado por MailScanner en busca de virus y otros contenidos peligrosos, y se considera que está limpio.
RE: [PHP] arrays
[snip] if I have two arrays, example: $a = array (one, two, three, four, two); $b = array (seven, one, three, six, five); How can I get in another variable a new array with the same elements into $a and $b. [/snip] http://www.php.net/array_merge -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] arrays
Hola Jesus. Hablo un pocitio espanol, pero en ingles no estoy seguro que quieres decir. Si te ayudara, envia el mensaje otra vez en espanol y tratare comprender. On 09/06/06, Jesús Alain Rodríguez Santos [EMAIL PROTECTED] wrote: if I have two arrays, example: $a = array (one, two, three, four, two); $b = array (seven, one, three, six, five); How can I get in another variable a new array with the same elements into $a and $b. -- Este mensaje ha sido analizado por MailScanner en busca de virus y otros contenidos peligrosos, y se considera que está limpio. -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon!
Re: [PHP] arrays
On 6/9/06, Jesús Alain Rodríguez Santos [EMAIL PROTECTED] wrote: if I have two arrays, example: $a = array (one, two, three, four, two); $b = array (seven, one, three, six, five); How can I get in another variable a new array with the same elements into $a and $b. php.net/array_intersect will get you the common elements. Rabin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Skip first 4 array values
Is there any way you can skip for example the first 4 array values/posisions in an array no matter how many values it contains? Thanks // Jonas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Skip first 4 array values
Why? Jef -Original Message- From: Jonas Rosling [mailto:[EMAIL PROTECTED] Sent: Friday, June 09, 2006 7:48 AM To: PHP List Subject: [PHP] Skip first 4 array values Is there any way you can skip for example the first 4 array values/posisions in an array no matter how many values it contains? Thanks // Jonas -- 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] Skip first 4 array values
On 09/06/06, Jonas Rosling [EMAIL PROTECTED] wrote: Is there any way you can skip for example the first 4 array values/posisions in an array no matter how many values it contains? Thanks // Jonas Skip $array[0], $array[1], $array[2], $array[3] if you are talking about integer-indexed arrays. Explain a little more please. -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon!
Re: [PHP] Skip first 4 array values
if numerically indexed: $max = count($array); for($i=0; $i$max;$i++) { if( $i = 3 ) continue; else { //do what you will } } for associative... $count = 0; foreach($arr as $k = $v ) { if($count = 3 ) conitnue; else { //do stuff } $count++; } -Brad Jonas Rosling wrote: Is there any way you can skip for example the first 4 array values/posisions in an array no matter how many values it contains? Thanks // Jonas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Skip first 4 array values
On 6/9/06, Jonas Rosling [EMAIL PROTECTED] wrote: Is there any way you can skip for example the first 4 array values/posisions in an array no matter how many values it contains? php.net/array_slice if you want to cut them off. Rabin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Restrict uploaded scripts
Wouldn't it even be posible, if the script couldn't be run directly, but had to be run through require or something like that? fre, 09 06 2006 kl. 08:38 -0400, skrev Jim Moseby: Wouldn't they still be able to overwrite each other? I don't think I expressed myself clearly. The point of the protection is to keep the scripts from overwriting each other on purpose. It was a protection that would make it posible to upload scripts, even if you were not completly sure they were safe. So, you are concerned that someone will write a script that when RUN could purposely overwrite some other files. If I had people uploading their own code to my server, I would be concerned as well. In fact, 'concerned' is not quite a strong enough word. As far as I know, when the uploaded script runs, it will have all the same permissions that the user the webserver runs as has. So there would be no (easy) way to control the possibility that it will overwrite files, add records to your database, launch an attack on another host, send 100,000 spam messages to the whitehouse, download porn and email it to your minister, etc, etc, etc... JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE: order of elements in $_POST super global
On 09 June 2006 13:55, Mindaugas L wrote: Hello, The basic problem is that the way a $_POST variable gets processed is in the order it is in on the original form. I think it's very natural behaviour. But be careful with associative arrays, I think before version 5.12.there was a bug, if you want that PHP makes an associative array of form elements. http://bugs.php.net/bug.php?id=37276 That's a strictly 5.1.3 bug -- everything's fine in 5.1.2 and previous, and in 5.1.4 (and subsequent versions!). Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Skip first 4 array values
On 6/9/06, Brad Bonkoski [EMAIL PROTECTED] wrote: if numerically indexed: $max = count($array); for($i=0; $i$max;$i++) { if( $i = 3 ) continue; else { //do what you will } } Why not start $i at 3 and skip the if else? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Skip first 4 array values
Eric Butera wrote: On 6/9/06, Brad Bonkoski [EMAIL PROTECTED] wrote: if numerically indexed: $max = count($array); for($i=0; $i$max;$i++) { if( $i = 3 ) continue; else { //do what you will } } Why not start $i at 3 and skip the if else? you could, just a simple example out of probably hundreds of ways to do it... of course this uses the same *logic* for both indexed and associative arrays, so I thought it would be more readable for the user. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Restrict uploaded scripts
Wouldn't it even be posible, if the script couldn't be run directly, but had to be run through require or something like that? Require just includes the code inline. It still runs on the webserver as the server user as if it were one big script. I think you would have to sanitize the uploaded code before allowing it to run. Writing the sanitation algorithm to perform such a task would be a nightmare. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] arrays
Jess Alain Rodrguez Santos wrote: if I have two arrays, example: $a = array ("one", "two", "three", "four", "two"); $b = array ("seven", "one", "three", "six", "five"); How can I get in another variable a new array with the same elements into $a and $b. $new_array = array_merge( $a, $b); regards, Mariano Guadagnini. No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.8.3/359 - Release Date: 08/06/2006 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Skip first 4 array values
On Fri, 2006-06-09 at 10:28, Brad Bonkoski wrote: Eric Butera wrote: On 6/9/06, Brad Bonkoski [EMAIL PROTECTED] wrote: if numerically indexed: $max = count($array); for($i=0; $i$max;$i++) { if( $i = 3 ) continue; else { //do what you will } } Why not start $i at 3 and skip the if else? you could, just a simple example out of probably hundreds of ways to do it... of course this uses the same *logic* for both indexed and associative arrays, so I thought it would be more readable for the user. Except your foreach version is buggy since $i never get incremented :B Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Tables vs. databases
Hi gang, Situation: I've a HTTP server. I intend to run a file upload service. There could be up to 1 subscribers. Each saving files up to 10 MB. I made a proof-of-concept service using PHP MySQL, where there is a single database, but many tables - a unique table for each subscriber. But I realize that I may land in trouble with such a huge database. Would it be better to have a separate database for each subscriber? Which approach is better, many tables in 1 database, or many databases with 1 or max 2 tables? Kindly suggest with pros and cons of each. Thanks Regards, Bassinger
Re: [PHP] Tables vs. databases
On 09/06/06, Antonio Bassinger [EMAIL PROTECTED] wrote: Hi gang, Situation: I've a HTTP server. I intend to run a file upload service. There could be up to 1 subscribers. Each saving files up to 10 MB. I made a proof-of-concept service using PHP MySQL, where there is a single database, but many tables - a unique table for each subscriber. But I realize that I may land in trouble with such a huge database. Would it be better to have a separate database for each subscriber? Which approach is better, many tables in 1 database, or many databases with 1 or max 2 tables? First off, why does each subscriber have their own table rather than being one record in a single subscribers table? I think you may need to think about the database design - the relational structure. -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon!
[PHP] Session puzzle... / why no new session?
Hi, I am working on a very simple script, basically adding features to an older script, I'll write down the main parts: ?php ini_set('session.name', 'COSTREAM_SESSION'); session_start(); ## authenticate user code comes here ## log the user my_log(login,$user,$_REQUEST['COSTREAM_SESSION']); ? and for logout.php I have: - ini_set('session.name', 'COSTREAM_SESSION'); session_start(); unset($_SESSION['user']); session_destroy(); -- redirect user comes here - but when I check the DB the session id is always the same hash, I should be getting new hashes everytime I login right? I am running the logout script before logging in again...why is it always giving me the same hash? What am I missing? Thanks! Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Tables vs. databases
Antonio Bassinger wrote: Hi gang, Situation: I've a HTTP server. I intend to run a file upload service. There could be up to 1 subscribers. Each saving files up to 10 MB. I made a proof-of-concept service using PHP MySQL, where there is a single database, but many tables - a unique table for each subscriber. But I why do you have a unique table for each user? realize that I may land in trouble with such a huge database. Would it be there is an upper limit on the number of tables dependent on your system; you don't want the kind of trouble that hitting that limit will bring. better to have a separate database for each subscriber? NO - I really don't think that is an option either - 1+ databases doesn't sound any better than 1+ tables. 1 database, 2 tables: USERS: user_id user_name ...etc FILES: file_id user_id file_location ...etc Which approach is better, many tables in 1 database, or many databases with 1 or max 2 tables? Kindly suggest with pros and cons of each. I can't think of a 'pro' for either of your approaches. Thanks Regards, Bassinger -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Skip first 4 array values
2006/6/9, Jonas Rosling [EMAIL PROTECTED]: Is there any way you can skip for example the first 4 array values/posisions in an array no matter how many values it contains? Thanks // Jonas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Maybe: array_slice() http://www.php.net/manual/en/function.array-slice.php
Re: [PHP] Tables vs. databases
On Fri, June 9, 2006 12:10 pm, Antonio Bassinger wrote: I've a HTTP server. I intend to run a file upload service. There could be up to 1 subscribers. Each saving files up to 10 MB. I made a proof-of-concept service using PHP MySQL, where there is a single database, but many tables - a unique table for each subscriber. But I realize that I may land in trouble with such a huge database. Would it be better to have a separate database for each subscriber? Which approach is better, many tables in 1 database, or many databases with 1 or max 2 tables? Kindly suggest with pros and cons of each. The one-database-for all method increases risk that an SQL error will leak information from one client to another. The overhead for multiple databases is tiny, except maybe in god-like admin pages that would access 2 databases at once. You do have to be methodical about db changes and applying them to ALL the dbs at once, or you'll have a version-control nightmare quickly... -- 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] Skip first 4 array values
Jonas Rosling wrote: Is there any way you can skip for example the first 4 array values/posisions in an array no matter how many values it contains? http://php.net/array_slice -- 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] substring with numric values
$int = (int) $value; On Fri, June 9, 2006 2:51 am, Jonas Rosling wrote: Is there any easy way to trim or pick out the none decimal values in a numric value? Like: 1,333 = 1 5,667 = 5 12,145 = 12 15,997 = 15 Thanks // Jonas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.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] mail() function dying half way through.
On Fri, June 9, 2006 12:59 am, Dave M G wrote: I have a database of about 120 users. Each weak I send out a newsletter. So far as I know, it's been working fine for the last couple of years. Then recently some users emailed me to let me know that they haven't been receiving all the messages. I added extra output to my script to echo out the name of each member that got an email sent to them, and I can now see that only about 50 of them are getting the email. The only think that has changed that I can think of is that I've upgraded to MySQL 5.0. However, given the type of problem I'm having, I don't think it's a MySQL problem, it appears much more likely to be a problem with my PHP code. This is the script that sends out the message (edited slightly to take out irrelevant bits of newsletter content): - - - - $count = 0; while ( $member = mysql_fetch_row($result) ) { set_time_limit(0); $subject = Newsletter subject line; $mailcontent = This message was sent to . $member[0] . at {$member[1]} Blah, blah, blah - newsletter content goes here.; mail($member[1], $subject, $mailcontent, $fromaddress); mail() returns a value to indicate if it failed/succeeded in queueing up the email. Check it. Also, every call to mail() fires up a sendmail process. This is expensive. maybe sleep(1) in between calls or consider switching to SMTP or sending ONE email with a Bcc... Though that has a slightly higher probability of being labeled as spam. $count++; echo pNewsletter sent to . $member[0] . at . $member[1] . /p; } echo pA total of .$count . emails were sent out./p\n; - - - - The script actually dies before it gets to the last echo which echoes the value of $count. It outputs about 50 lines of Newsletter sent to usersname at [EMAIL PROTECTED] and then the cursor is stuck in hourglass mode and the browser is continually waiting a response. It stays like that indefinitely, and the only way it stops is if I go to another page or shut down the browser. I have heard that the mail() function does have limitations on how many emails it sends out. But I thought it took hundreds, somewhere between 500 and a thousand, of individual emails before it would die. And I also thought the set_time_limit(0) function would alleviate the problem of timing out. Where have I gone wrong with this? Any advice would be greatly appreciated. Thank you for taking the time to read this. -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.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] transfer file
On Thu, June 8, 2006 10:16 pm, kristianto adi widiatmoko wrote: can php do transfer file betwen 2 server without using ftp function socket that use ftp port If you want to re-write all the FTP stuff in PHP, with http://php.net/fsockopen and fgets and fputs, sure, you could do that... Kinda silly to re-invent the wheel, but you could. -- 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] remove last comma in string
You're missing an = for the city. substr() should have worked. rtrim() won't work, as ',' is not whitespace. On Thu, June 8, 2006 7:58 pm, weetat wrote: Hi all, I am using php 4.3.2 and mysql , linux. I have a sql statement below : UPDATE tbl_chassis_temp SET country = 'Singapore', city 'SINGAPORE', building = 'Tampines Central 6', other = 'Level 03-40', I need to remove the last comma from sql text above. I have tried using substr and rtrim , without any success ? Anyone have any suggestion ? THanks - weetat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.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] order of elements in $_POST super global
On Thu, June 8, 2006 9:59 am, Ben Liu wrote: I'm using a form (method=POST) to collect 30 boolean values from the end user using a series of checkboxes in the form. The form is arranged in a table so that the 30 check boxes are not a long list but rather three columns (with related items columnized). The problem is when I iterate through the $_POST results: The order in which I wish to present the checkboxes to the end user is different than the order I want to have in the $_POST super global and subsequently when I dump that information out to a text file. You CANNOT rely on the browser to send POST data in any particular order, by the HTTP spec. While it's true that ALL known browsers send them in the order they appear in the HTML, they don't have to. And, of course, if they ever change that, a zillion scripts will break... Still, better safe than sorry. What would be the best way to solve this? Since you want them in a particular order, use the KEY of the array to order them: input type=checkbox name=array[0] / I'm first. input type=checkbox name=array[1] / I'm second. input type=checkbox name=array[2] / I'm third. 1) Is there a way to present the checkboxes in a certain order, yet have the data transmitted into the $_POST super global in a different order? Presentation order is all HTML. 2) Does it make more sense to process the $_POST super global array and reorder the items within the array? 3) Some other method? Thanks for any advice. - Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.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] remove last comma in string
weetat wrote: I have a sql statement below : UPDATE tbl_chassis_temp SET country = 'Singapore', city 'SINGAPORE', building = 'Tampines Central 6', other = 'Level 03-40', I need to remove the last comma from sql text above. I have tried using substr and rtrim , without any success ? At 06:10 PM 6/8/2006, Chris wrote: How about: $query = substr(trim($query), 0, -1); This feels like a hack to me -- it acts blindly, assuming that just the comma and no extra spaces are at the end of the string. Better I think to intelligently remove just those characters one wishes to remove. At 03:00 PM 6/9/2006, Richard Lynch wrote: rtrim() won't work, as ',' is not whitespace. Richard, you're wrong -- read the manual. All three functions trim(), ltrim(), and rtrim() allow you to append an optional list of characters to be trimmed: http://php.net/trim http://php.net/ltrim http://php.net/rtrim Regards, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: order of elements in $_POST super global
On Fri, June 9, 2006 7:34 am, Ben Liu wrote: The basic problem is that the way a $_POST variable gets processed is in the order it is in on the original form. This is an undocumented behaviour, almost for sure. Your script shouldn't rely on it, even if a skillion other scripts do. :-) -- 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] remove last comma in string
On Fri, June 9, 2006 5:17 pm, Paul Novitski wrote: rtrim() won't work, as ',' is not whitespace. Richard, you're wrong -- read the manual. All three functions trim(), ltrim(), and rtrim() allow you to append an optional list of characters to be trimmed: http://php.net/trim http://php.net/ltrim http://php.net/rtrim Yeah, those wacky PHP Devs keep adding features faster than I can learn and remember 'em :-) -- 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: order of elements in $_POST super global
name=bool[0][careers] might do what you want... it's really quite difficult to say without a concrete example... On Thu, June 8, 2006 10:20 am, Ben Liu wrote: I probably should add some more details to my question: The names of the form checkboxes could be changed from ie: bool_careers, bool_speaking, bool_internship, etc. to a single array bool_questions[], for instance. The problem with that is that I am using the form checkbox names later to process related data. Specifically, I am building a user-input based query. So if the form checkbox names are the same as the names of the variables in the database, it makes for easy creating of the query, since the names become associative keys in the $_POST array. I iterate through the $_POST array, checking each for true/false state. If the checkbox is checked, I add the associative key name to the query. Eliminating the checkbox names in favor of a numerical key only would make this more complicated. - Ben On 6/8/06, Barry [EMAIL PROTECTED] wrote: 1. Use Keys in your form like a[1],a[2] 2. order the array by usort (alphabetically or whatever u prefer) that way = 2: yes it is. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.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] server sending notifications to clients
On Thu, June 8, 2006 9:24 am, kartikay malhotra wrote: Is there a way for the server to notify the client about an event, provided the client was online in the past X minutes? To elaborate: A client comes online. A script PHP executes (serves the client), and terminates. Now if a new event occurs, how can the server notify the client about that event? Keep a table of notifications and what time they happened, and if the user has seen them -- perhaps even allowing the user to choose which ones to dismiss, perhaps even only having a little icon about notifications if there are any... When the users hits a page, check the notifications table for things they ought to know about. The exact rules of how/when to do what is up to you and your users, but give it a lot of thought before you go annoying the [bleep] out of users with a damn popup for each notification stacked up or something... :-) This takes a lot more thought about WHAT to do from a process/user-interface side than HOW to code it in 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] running php method in the background
On Thu, June 8, 2006 9:10 am, Nic Appleby wrote: I have a php web script which communicates with a server using sockets. There is a method in which the client listens for messages from the server, and this blocks the client. I need a way to 'fork' a process or to get this method to run in the background so that i can process user input while not interrupting the protocol. I have searched all over the web with no luck, can anyone point me in the right direction? http://php.net/fsockopen and friends discuss the non-blocking aspect. http://php.net/fork covers fork. You can't use fork (or any pcntl) in a web-server environment, only CLI -- 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] Using php4 to manage Apache 1.3 access database
I'm trying to make a web page to maintain my Apache authorization file with instead of dbmmanage. Since I have to have php loaded for other reasons I started there. Problem seems to be that the OpenBSD package and port systems only seem to gdbm for php-4 and gdbm is not supported by Apache 1.3 (gdbm does seem to be supported for Apache 2 but that is not an option for me). Sort of a catch 22. Is this correct or am I more likely malforming the gdbm database or something else? Context is: OpenBSD 3.9 with default chrooted Apache 1.3 db-4.2.52p8 gdbm-1.8.3p0 php4-core-4.4.1p0 php4-dba-4.4.1p0 Ruby 1.8 supports DB files but I don't really want to move all the Ruby stuff to /var/www/ (required for the chrooted Apache install). Any suggestions? Thanks, -- Doug Carter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session puzzle... / why no new session?
On 6/10/06, Ryan A [EMAIL PROTECTED] wrote: Hi, I am working on a very simple script, basically adding features to an older script, I'll write down the main parts: ?php ini_set('session.name', 'COSTREAM_SESSION'); session_start(); ## authenticate user code comes here ## log the user my_log(login,$user,$_REQUEST['COSTREAM_SESSION']); ? and for logout.php I have: - ini_set('session.name', 'COSTREAM_SESSION'); session_start(); unset($_SESSION['user']); session_destroy(); -- redirect user comes here - but when I check the DB the session id is always the same hash, I should be getting new hashes everytime I login right? I am running the logout script before logging in again...why is it always giving me the same hash? If you're logging straight back in after logging out, maybe not - the browser might remember the old session. If you log out, close the browser then go to the login page you should get a new id. If you want to guarantee a new id, use http://php.net/session_regenerate_id -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Tables vs. databases
On 6/10/06, Antonio Bassinger [EMAIL PROTECTED] wrote: Hi gang, Situation: I've a HTTP server. I intend to run a file upload service. There could be up to 1 subscribers. Each saving files up to 10 MB. I made a proof-of-concept service using PHP MySQL, where there is a single database, but many tables - a unique table for each subscriber. But I realize that I may land in trouble with such a huge database. Would it be better to have a separate database for each subscriber? On top of the replies you already have you should read these pages: http://arjen-lentz.livejournal.com/66547.html http://bobfield.blogspot.com/2006/03/million-tables.html Though you're not talking about those sort of numbers, you need to be aware of those limitations (there were more posts on planetmysql.org about this but I can't find the original page). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to tell if a socket is connected
Hello, Can any of you tell me how to tell whether a socket (from fsockopen()) is connected or not? Specifically, whether the remote server has closed the connection? Stream_get_meta_data() does not do it; in my tests, its output does not change even when the server closes the stream. Thank you, Michael W. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mail sending program (beginner)
Dear group, Description: Following is the code which I tried for learning propuses. It is a mail sending program which checks weather the user enters a correct mail id If he enters the correct mail ID then user name and e-mail will get stored in the mysql data base table. After getting stored then mail will sent to the user as a accknoledg process. For the propus of mail subject and mail body, I have created two external files. The problem: Filling the rows and col in the data base is no problem at all. The value getting stored. But after clicking the button for accknoledg the browser takes lot of time in execution. I doubt with either the file handling functions or infinit loop. Or Am I missing somthing basic? Pls mention if you faced a similear situation with file handling and infinit loop. Thanks. NOTE: Sorry for the very long code == the code= The html file: HTML body form method=post name=my_frm action=mail.php TABLE align =center tr td Name: /td td input id=text name=user_name /td /tr tr td E-mail: /td td input id=text name=user_email /td /tr /TABLE table align = center tr td input type=submit name=click_btn value=yes,I want my 'CMS' NewsLetter NOW! align=middle onClick=validt() /td /tr /table table align=center tr td a href=test.htmlfont size=2Or click here to see how you can learn everything br you need to know about CMS without signing up for our free newsletter /font /a /td /tr /table script language=javascript function validt() { var str= document.my_frm.user_email.value; var name = document.my_frm.user_name.value; if(str.indexOf(@) 0 || str.indexOf(.) 0) { my_error() } else alert(thanks for entering valid e-mail); } function my_error() { alert(pls enter a correct e-mail ID); document.my_frm.user_email.value = ; } /script /form /body /HTML the mail.php file: ^^^ ?php /*mail body file*/ function cnd($fname) { $fil = fopen($fname,r); if(!$fil) die(fopen error); while(!feof($fil)) $buffer = fgets($fil); while($buffer != NULL) { if($buffer == \n.) /*a line should not start with .*/ $buffer = str_replace(\n.,\n.., $buffer); if($buffer == \n $buffer 70) /*should be less than 70*/ $buffer = '\n'; } fclose($fil); return $buffer; } /*mail sub file*/ function sub($fname) { $fil = fopen($fname,r); if(!$fil) die(fopen err in sub file); while(!feof($fil)) $buff = fgets($fil); while($buff != NULL) { if($buff 15) { ? script language=javascript alert(the subject line should not be less than 15, pls check the sub.txtfile); /script ?php } } fclose($fil); return $buff; } function fetch_names() { $var = mysql_connect(localhost,root,); if(!$var) die(could not connect.mysql_error()); $db = mysql_select_db(sathya_clon,$var); if(!$db) die(could not find the data base.mysql_error()); $result = mysql_query(select name from users,$var) or die(unable to fetch rows); $rows = mysql_fetch_array($result); while($rows) { for($i=0; $i= $rows ; $i++) for($j=0;$j = i-1 ; $j++) $names[$i] = $rows[$j]; } return $names; } function fetch_emails() { $var = mysql_connect(localhost,root,); if(!$var) die(could not connect.mysql_error()); $db = mysql_select_db(sathya_clon,$var); if(!$db) die(could not find the data base.mysql_error()); $result = mysql_query(select email from users,$var) or die(unable to fetch rows); $rows = mysql_fetch_array($result); while($rows) { for($i=0; $i= $rows ; $i++) for($j=0;$j = i-1 ; $j++) $email[$i] = $rows[$j]; } return $email; } $var = mysql_connect(localhost,root,); if(!$var) die(could not connect.mysql_error()); $db = mysql_select_db(sathya_clon,$var); if(!$db) die(could not find the data base.mysql_error()); $name = $_POST['user_name']; $mail = $_POST['user_email']; $db_q = mysql_query(insert into users values('$name','$mail')); if(!$db_q) die(mysql error); $condt = cnd(cond.txt); $sub = sub (sub.txt); $name = fetch_names(); $email = fetch_emails(); $mail_stat = mail($email,$sub,$condt,from:[EMAIL PROTECTED]); if($mail_stat == NULL) echo mail sent failed; else echo mail sent sucess. Pls check for mail for further acction; ? ==code ends sorry english is not my native language.