Re: [PHP] PHP vs JAVA
On 20/08/13 15:00, Tedd Sperling wrote: Hi guys: A teacher at my college made the statement that JAVA for Web Development is more popular than PHP. Where can I go to prove this right or wrong -- and/or -- what references do any of you have to support your answer? (sounds like a teacher, huh?) Here are my two references: http://w3techs.com/technologies/details/pl-php/all/all http://w3techs.com/technologies/history_overview/programming_language/ms/y But I do not know how accurate they are. What say you? Cheers, tedd ___ tedd sperling t...@sperling.com tedd, Java is a meticulously-constructed language with very strict typing and a large commercial organisation which purports to support and develop it. PHP is a scruffy heap of loosely typed cruft which is easy to knock together and build big things from, but has a semi-commercial and community support structure. Guess which one the big commercial organistations (banks, industry etc.) prefer to trust? Guess which is then popular for college courses since it provides the students with a basis in something that is commercially desirable? From my personal point of view, I started with BASIC, then FORTRAN (in a scientific environment), then C/C++, then Java (which I saw as the language C++ should have been), and then moved on to PHP in a search to find a way of building web apps in the sort of timescales that small-medium enterprises are prepared to accept. Popularity is in the eye of the beholder... Cheers Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP is Zero
On 13/06/13 08:59, BUSCHKE Daniel wrote: Hi all, I want to start a discussion about a PHP behaviour that drives me crazy for years. For the beginning I would like you to guess what the result of the following snippet will be: var_dump('PHP' == 0); I know the difference of == and === but the result was unexcpected for me. And I hope it is also for you. The result is simply true. Why is it true? I guess this happens because of the conversion from 'PHP' to a number which will be 0 in PHP. And of course 0 equals 0. There are several points that I just want to drop into this mailinglist to discuss about: 1. Why? :) 42 2. Why is PHP converting the String into a Number instead of converting the Number into a String? (If my guess concerning the behaviour is correct) Since PHP is a weakly-typed language, it has to choose one way or the other. The behaviour *is* predictable if you know what the rule is (I'm sure the order of conversion is documented somewhere). 3. Why is PHP throwing data away which has the developer explicit given to the interpreter? Because PHP is weakly-typed, the developer is not being sufficiently explicit. Try php -r 'var_dump(intval('PHP') == 0);' and php -r 'var_dump('PHP' == strval(0));' to see explicit code. Anything less is implicit. 4. Why does var_dump(0 == 'PHP'); has the same result as the snippet above? This meens that the equal operator is not explictly implemented in the string or integer? The rule is consistent: it always converts the string to an integer whatever the order. 5. Thats a bug I have opend: https://bugs.php.net/bug.php?id=51739 where I also had the same problems because 8315e839da08e2a7afe6dd12ec58245d was converted into float(INF) by throwing everything starting from da08.. away. That's a very different proposition, and probably has more to do with word size: float is 32-bit, so only the first 32 bits are used and if anything else is found the conversion falls back to INF. To handle really big integers like 8315e839da08e2a7afe6dd12ec58245d you probably need a more specialist library (or language) I am using PHP since the year 2000. This means I have 13 years of experience in PHP and I really would like you to NOT just answer works as designed. I know it works as designed but I want to discuss the design. Also I know that the fuzzy behaviour of type conversion is a main feature of PHP. I guess this is one point which makes PHP that successfull. But - in my opinion - the described behaviour is to fuzzy and just confuses developers. The weak typing *is* a feature of PHP: other languages are more suitable when you need more enforcement of types: Java, for example. With all due respect to an experience programmer, years of experience do not make up for a limited tool set. Best Regards Daniel Buschke Cheers Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: AW: [PHP] PHP is Zero
On 13/06/13 10:44, BUSCHKE Daniel wrote: Hi, thanks for your answer. Especially the answer 42 made me laughing :) My Why questions should be understand as Why must it be like that questions. On 13/06/13 08:59, BUSCHKE Daniel wrote: 5. Thats a bug I have opend: https://bugs.php.net/bug.php?id=51739 where I also had the same problems because 8315e839da08e2a7afe6dd12ec58245d was converted into float(INF) by throwing everything starting from da08.. away. That's a very different proposition, and probably has more to do with word size: float is 32-bit, so only the first 32 bits are used and if anything else is found the conversion falls back to INF. To handle really big integers like 8315e839da08e2a7afe6dd12ec58245d you probably need a more specialist library (or language) For me it is not. PHP throws things away during conversion. In my opinion a language (compiler, interpreter whatever) should not do that. Never ever! Either it is able to convert the value or it is not. What about of returning null instead of 0 if the conversion is not perfect? So intval('F') could return NULL and intval('0') could return 0. Regards Daniel I've had a bit of a play with your big hex number, and the problem is much more subtle: floatval(8315e839da08e2a7afe6dd12ec58245d) is truncated at 8315e839 because it tries to parse it as an exponential float: floatval(8315e83) becomes 8.315 x 10^86, but 8.315e839 is 8.315 x 10^842 which is (as far as PHP is concerned) an infinitely large number! So we try replacing that first 'e' with a 'd' (for example) and then php -r 'var_dump(floatval(8315d839da08e2a7afe6dd12ec58245d));' returns float(8315) It gives up when it finds a non-numeric character (as the documentation would tell you) Perhaps what you need is php -r 'var_dump(floatval(0x8315e839da08e2a7afe6dd12ec58245d));' float(1.7424261578436E+38) In other words, you need to tell the interpreter that you have a number (in base-16) rather than a string. A proper strongly-typed language would just tell you that it's nonsense... Cheers Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Tree menu list in php
On 26/07/11 18:20, alekto wrote: Hi, is there a way to create a tree menu list only by using php/html/css? I found some, but they are all in JavaScript, do I have to make them by using JavaScript or is there a way in php as well? This is how I imagine the tree menu should look like: v First level Second level Second level v Second level Third level Third level Third level Second level Second level ( = menu is closed, v = menu is open ) Cheers! Look, I know this is loopy and I haven't tried it (for the protection of my sanity, mainly), but how about the tree being an image generated using PHP, and then used as an image map to submit the page every time a click is made on the image - you could then use the coordinates of the click to determine the new state of the tree and render an appropriate image for it... I'll get my coat... Pete -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Constants in strings
On 06/07/11 17:33, Robert Williams wrote: Where I've made most use of heredocs is when I want to do nothing but define a bunch of long strings in one file. I find the most useful thing about heredocs is that they don't care about quotation marks, so I often use them for SQL statements where I might have a mixture of ' and eg. $sql =EoSQL SELECT foo AS Foo FROM Bar WHERE baz='quux' EoSQL; -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ftp upload
On 15/06/11 01:24, Marc Guay wrote: I bought a 1GB external hard drive for $1000. Did I just choke on my lunch? If that was about 20 years ago, then it would be fine! -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP download page blocking other HTTP requests
On 06/06/11 21:07, Richard Quadling wrote: On 6 June 2011 13:55, Pete Fordp...@justcroft.com wrote: Is there something on the Apache/PHP end that might be causing this blocking? (Apache 2.2.10, PHP 5.2.14) The browser and / or OS may be obeying the settings about the number of simultaneous connections per host. http://support.microsoft.com/kb/183110 / http://www.ietf.org/rfc/rfc2616.txt 8.1.4 Practical Considerations ... Clients that use persistent connections SHOULD limit the number of simultaneous connections that they maintain to a given server. A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy. A proxy SHOULD use up to 2*N connections to another server or proxy, where N is the number of simultaneously active users. These guidelines are intended to improve HTTP response times and avoid congestion. Also, (from googling) http://forums.serverbeach.com/showthread.php?6192-Max-Concurrent-Connections-Per-Host, mod_throttle and/or mod_bandwidth may be capable of restricting the number and/or speed of connections. Thanks Richard, There's no mod_throttle or mod_bandwidth, but I SHOULD have remembered RFC2616. I'll look into working with that, although I'm having trouble reproducing the problem since my dev machine sits on the same network as the server and the files come down too quickly! Maybe I can use a redirect or something to force a new connection... -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP download page blocking other HTTP requests
I have a file download 'guardian' page which does something like this: $size = filesize($path); $fi = @finfo_file($path, FILEINFO_MIME_TYPE); @header('Content-type: ' . $fi); @header('Content-Length: ' . $size); @readfile($path); exit; ($path is derived from parameters in the request, including checks for nasties and some access control checks in the system) When a link is clicked which points to this script, the file is downloaded (well and good...), but in Firefox (3.x, 4.x at least), it seems to block any further interaction with the browser until the download is complete - some of the files are 60Gb and the server is on a 2mbit line, so it can take some time to download. Is there something on the Apache/PHP end that might be causing this blocking? (Apache 2.2.10, PHP 5.2.14) I suspect not, since using Chrome as the browser doesn't appear to have the same problem, but I wondered whether there was some way that FF was handling the headers might be causing it. I can't seem to devise a suitable Google search to get any mention of similar behaviour so I thought I'd ask some experts :) -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing Session (Revisited)
On 22/05/11 06:46, Roger Riordan wrote: On Thu, 05 May 2011 08:28:53 -0400, sstap...@mnsi.net (Steve Staples) wrote: On Thu, 2011-05-05 at 21:41 +1000, Roger Riordan wrote: I have developed a common engine which I use for several different websites. I had been using PHP 5.2.? and IE6 (yes; I know!), and had been able to have multiple sessions open at once, displaying the same or different websites, without them interfering with each other. This was incredibly useful; I could be looking at, or even edit, different parts of the same, or different, websites simultaneously without any problems. But I recently had a hard disk crash and had to re-install all the system software. Now I have PHP 5.3 and IE 8, and find that if I try to do this the various sessions interfere with each other. From the above comment I gather that this is because IE 8 combines all the instances, whereas previously each instance was treated as a different user. Is there any simple way to make IE 8 treat each instance as a new user, or should I switch to Chrome and use the Incognito feature? Roger Riordan AM http://www.corybas.com/ The Incognito feature wont give you the results you're looking for. From my experience, the incognito window(s) and tab(s) share the same memory/cookie/session space, which is different from the main window... which means you will run into the same issue. Once you close all your incognito windows/tabs, you will release those cookies/sessions/memory space and if you open a new one afterwards, then you will be fine, but if one tabs stays open, no go :( Have you looked at the http://ca3.php.net/session_name function, and putting that into your site just after your session_start() ? I believe that will fix your issues (as long as your session names are unique), but i am not 100% sure. Steve Thank you for this suggestion. This has solved the more serious half of my problems; I can easily generate a different session name for each website, so that the various websites don't interfere with each other, but I have not been able to devise a way to differentiate between multiple sessions of the same website. For example, if I open one copy of a website as a visitor I am shown as Visitor, but if I then open another window, and log in as Manager, then go back to the first window I am shown as Manager (with appropriate privileges) there also. The only way I can think of to overcome this would be to generate a new named session every time I log in, and then to pass the session name as a parameter every time I load a new page. Unfortunately my program is sufficiently complicated that this is effectively impractical, as it would involve tracking down and modifying every point in the program at which a new page can be launched. It also has a theoretical disadvantage that if someone bookmarks a page they will book mark the session name, but this can fairly readily be overcome. Is there any alternative way in which a different session name (or equivalent flag) can be attached to each instance of the browser? (Effectively these problems only affect the developer, as they only apply to multiple instances of the same browser on the same PC.) PS. At this stage I devised a really nasty kludge, which enables me to run multiple copies without them interfering. In my program new pages are always launched by a command of the general type: http://localhost/cypalda.com/index.php?level=1item=22 This loads the file index.php, which is a very brief file in the public directory (cypalda.com in this case). It sets a couple of constants and then transfers control to a file Begin.php, in a private directory. This in turn sets up a whole lot more constants, and then transfers control to the main program, which is common to 5 different websites. I realised that if I specify the session name in index.php, I can make several copies of this file, e.g. index.php, index1.php, index2.php, each of which specified a different session name. I thought this still left me the problem of modifying all the points at which a new page was launched, but then I found that by great good fortune (or foresight!) I had defined a constant $home_page = index.php, and always launched a new page with the basic command echo ('a href='.$home_page.'?ident=' ...'); So all I had to do to achieve the desired outcome was to specify a different $homepage in each copy of index.php. Then, once I had launched a particular copy of index.php, that instance of the browser would always load the session appropriate to that copy. Even better, if I upload the various versions of index.php, I can run multiple copies of the public website on the same PC without them interfering. Roger Riordan AM http://www.corybas.com/ Depending upon how your session persistence works, can you not just specify a different location to store session data for each possible mode of login? I have an application which does something similar,
[PHP] Re: Date validation
On 20/05/11 16:29, Geoff Lane wrote: On Friday, May 20, 2011, Peter Lind wrote: Try: $date = new DateTime($date_string_to_validate); echo $date-format('Y-m-d'); Many thanks. Unfortunately, as I mentioned in my OP, the DateTime class seems to be 'broken' for my purposes because it uses strtotime() to convert input strings to date/time. Rather than fail when presented with an invalid date, strtotime() returns the 'best fit' if possible. This can be seen from: $date = new DateTime('30 Feb 1999'); echo $date-format('Y-m-d'); which results in 1999-03-02 even though 30 Feb is an invalid date. If you could programmatically determine the format of the input, you could parse the date using DateTime and then rewrite it using the same format as the input, and compare those. Now that starts to work if you can *control* the format of the input, or at least limit it to some familiar options. So maybe: $userInput = '30 Feb 1999'; $dateTest = new DateTime($userInput); if ($userInput===$dateTest-format('Y-m-d') || $userInput===$dateTest-format('d M Y')) { echo 'Date is valid'; } else { echo 'Not valid'; } It starts to get logn-winded after a while, and doesn't rule out ambiguous cases... Or split the date input into pieces in the form (if possible) and then you can validate the date how you like $userInput = $_POST['year'].'-'.$_POST['month'].'-'.$_POST['day']; $dateTest = new DateTime($userInput); if ($userInput===$dateTest-format('Y-m-d')) { echo 'Date is valid'; } else { echo 'Not valid'; } Finally, for some applications I have made an AJAX (javascript + PHP) implementation which provides feedback to the user as they type in the date field: every time a character is typed in the box, the backend is asked to parse it and then format it in an unambiguous way and send it back to the client. That way the user can *see* if what they are typing is valid... Of course, you *still* have to validate it when it's posted (and the network overhead might be too much). -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Date validation
On 23/05/11 13:12, tedd wrote: At 9:47 AM +0100 5/23/11, Pete Ford wrote: Finally, for some applications I have made an AJAX (javascript + PHP) implementation which provides feedback to the user as they type in the date field: every time a character is typed in the box, the backend is asked to parse it and then format it in an unambiguous way and send it back to the client. That way the user can *see* if what they are typing is valid... Of course, you *still* have to validate it when it's posted (and the network overhead might be too much). That would be interesting to see. With a little work, I envision a way to alleviate the Europe/US date format difference. (i.e., day/month/year : Europe vs month/day/year : US). As the user typed in the date, the day/month problem could be shown via string-month (i.e., Jan... ). How does yours work? Cheers, tedd Ah, now you're asking. I'll have to try and extract the code into a sanitised form for public consumption: give me a little time... But yes, the string fed back to the user gives the month as a string, to avoid confusion with numeric months. -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Warning: session_start()
On 19/05/11 10:37, Tim Streater wrote: On 19 May 2011 at 10:20, Richard Quadlingrquadl...@gmail.com wrote: On 18 May 2011 19:15, Nazishnaz...@jhu.edu wrote: Hi everyone, !--- WHEN USER CLICKS 'ENTER' TO LOGIN ! ?php code, code, code. ? The session cookie must be sent prior to any output. Including, but not limited to, comments, whitespace, HTML code, etc. 2 - Remove all white space. Personally, this is the route I would use. For the sake of completeness, that is whitespace *outside* the?php ? tags. tim The comment should really be inside the php block: ?php /* WHEN USER CLICKS 'ENTER' TO LOGIN */ ... code ... ? otherwise (notwithstanding the session_start() problem) you'll get the comments in you HTML source - probably not what you wanted... -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: XML... Useful or another layer of complexity?
On 03/04/11 19:41, Jason Pruim wrote: So the subject says it all... And yes I know this isn't related to PHP but it's the weekend and I trust the opinions on this list more then any other list I have seen. I've been doing alot of reading on XML and honestly it looks pretty cool... BUT the question is... Is it truly useful or is it just another layer that we have to write? From what I can tell it looks like it could stabilize some of my programming in regards to databases, and possibly if I have to move information from one application to another. But is it worth the added coding or should I just interact with the pieces directly? Thoughts? Questions? Flames? :) Yes :) -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mysql_num_rows()
On 22/02/11 14:40, Gary wrote: Pete Fordp...@justcroft.com wrote in message news:76.48.39221.054c3...@pb1.pair.com... On 22/02/11 13:59, Gary wrote: Pete Fordp...@justcroft.com wrote in message news:a4.c0.39221.b3ca3...@pb1.pair.com... On 22/02/11 05:40, Gary wrote: Can someone tell me why this is not working? I do not get an error message, the results are called and echo'd to screen, the count does not work, I get a 0 for a result... $result = mysql_query(SELECT * FROM `counties` WHERE name = 'checked') or die(mysql_error()); if ( isset($_POST['submit']) ) { for($i=1; $i=$_POST['counties']; $i++) { if ( isset($_POST[county$i] ) ) { echo You have chosen . $_POST[county$i].br/; } } } $county_total=mysql_num_rows($result); while($row = mysql_fetch_array($result)) {$i++; echo $row['name']; } $county_total=mysql_num_rows($result); echo $county_total; echo 'You Have ' . $county_total . ' Counties '; ? The first thing I see is that you do $county_total=mysql_num_rows($result) twice. Now I'm not to sure, but it is possible that looping over mysql_fetch_array($result) moves an array pointer so the count is not valid after the operation... that's a long shot. But since you are looping over the database records anyway, why not just count them as you go? Isn't $i the number of counties after all the looping? -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS Peter Thank you for your reply. I did notice that I had the $county_total=mysql_num_rows($result) twice. I had moved and removed it, always getting either a 0 or 1 result. I put up another test page with $result = mysql_query(SELECT * FROM `counties` ) or die(mysql_error()); $tot=mysql_num_rows($result); echo $tot; ? And it worked fine. I have tried count() as well as mysql_num_rows() but am getting the same result. Could you explain what you mean by count them as I go? Again, Thank you for your reply. Gary __ Information from ESET Smart Security, version of virus signature database 5895 (20110222) __ The message was checked by ESET Smart Security. http://www.eset.com Well, Lets go back to your original code and cut out the decoration: $result = mysql_query(SELECT * FROM `counties` WHERE name = 'checked') $county_total=mysql_num_rows($result); while($row = mysql_fetch_array($result)) { echo $row['name']; } echo $county_total; That code should do pretty much what you want... But, because you only show the number of records AFTER the loop, you could do: $result = mysql_query(SELECT * FROM `counties` WHERE name = 'checked') $county_total = 0; while($row = mysql_fetch_array($result)) { echo $row['name']; $county_total++; } echo $county_total; Peter Thank you for your suggestion...btw cut out the decoration LOL I'm sorry to report it did not work. I tried various configurations of it but to no avail. Any other suggestions? Again, thank you for your help. Gary __ Information from ESET Smart Security, version of virus signature database 5895 (20110222) __ The message was checked by ESET Smart Security. http://www.eset.com Gary, I'd probably need a bit more detail on the it did not work to go much further! Actually, it looks like I missed a semicolon on the mysql_query line in *both* versions - maybe that was the problem... Do you have access to your server logs, to see if any errors are reported when you run this? Cheers Peter -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Dynamically Created Checkboxes
This bit? On 22/02/11 22:06, Gary wrote: for($i=1; $i=$_POST['counties']; $i++) { if ( isset($_POST[county{$i}] ) ) { You loop over $_POST['counties'] and look for $_POST[county$i] I suspect that there is no field 'counties' in your form, so the server is complaining about the missing index - seems likely that the production server is not showing the error, but instead just giving up on the page. I think the IE7/Firefox browser difference is a red herring: it wasn't actually working in any browser, or the code changed between tests. Remember, PHP is server side and generates HTML (or whatever). Unless you tell the PHP what browser you are using and write PHP code to take account of that (not generally recommended) then the server output is the same regardless of browser. -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mysql_num_rows()
On 22/02/11 05:40, Gary wrote: Can someone tell me why this is not working? I do not get an error message, the results are called and echo'd to screen, the count does not work, I get a 0 for a result... $result = mysql_query(SELECT * FROM `counties` WHERE name = 'checked') or die(mysql_error()); if ( isset($_POST['submit']) ) { for($i=1; $i=$_POST['counties']; $i++) { if ( isset($_POST[county$i] ) ) { echo You have chosen . $_POST[county$i].br/; } } } $county_total=mysql_num_rows($result); while($row = mysql_fetch_array($result)) {$i++; echo $row['name']; } $county_total=mysql_num_rows($result); echo $county_total; echo 'You Have ' . $county_total . ' Counties '; ? The first thing I see is that you do $county_total=mysql_num_rows($result) twice. Now I'm not to sure, but it is possible that looping over mysql_fetch_array($result) moves an array pointer so the count is not valid after the operation... that's a long shot. But since you are looping over the database records anyway, why not just count them as you go? Isn't $i the number of counties after all the looping? -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mysql_num_rows()
On 22/02/11 13:59, Gary wrote: Pete Fordp...@justcroft.com wrote in message news:a4.c0.39221.b3ca3...@pb1.pair.com... On 22/02/11 05:40, Gary wrote: Can someone tell me why this is not working? I do not get an error message, the results are called and echo'd to screen, the count does not work, I get a 0 for a result... $result = mysql_query(SELECT * FROM `counties` WHERE name = 'checked') or die(mysql_error()); if ( isset($_POST['submit']) ) { for($i=1; $i=$_POST['counties']; $i++) { if ( isset($_POST[county$i] ) ) { echo You have chosen . $_POST[county$i].br/; } } } $county_total=mysql_num_rows($result); while($row = mysql_fetch_array($result)) {$i++; echo $row['name']; } $county_total=mysql_num_rows($result); echo $county_total; echo 'You Have ' . $county_total . ' Counties '; ? The first thing I see is that you do $county_total=mysql_num_rows($result) twice. Now I'm not to sure, but it is possible that looping over mysql_fetch_array($result) moves an array pointer so the count is not valid after the operation... that's a long shot. But since you are looping over the database records anyway, why not just count them as you go? Isn't $i the number of counties after all the looping? -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS Peter Thank you for your reply. I did notice that I had the $county_total=mysql_num_rows($result) twice. I had moved and removed it, always getting either a 0 or 1 result. I put up another test page with $result = mysql_query(SELECT * FROM `counties` ) or die(mysql_error()); $tot=mysql_num_rows($result); echo $tot; ? And it worked fine. I have tried count() as well as mysql_num_rows() but am getting the same result. Could you explain what you mean by count them as I go? Again, Thank you for your reply. Gary __ Information from ESET Smart Security, version of virus signature database 5895 (20110222) __ The message was checked by ESET Smart Security. http://www.eset.com Well, Lets go back to your original code and cut out the decoration: $result = mysql_query(SELECT * FROM `counties` WHERE name = 'checked') $county_total=mysql_num_rows($result); while($row = mysql_fetch_array($result)) { echo $row['name']; } echo $county_total; That code should do pretty much what you want... But, because you only show the number of records AFTER the loop, you could do: $result = mysql_query(SELECT * FROM `counties` WHERE name = 'checked') $county_total = 0; while($row = mysql_fetch_array($result)) { echo $row['name']; $county_total++; } echo $county_total; -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to list and to PHP
On 2/20/2011 3:47 PM, tedd wrote: At 2:03 PM -0500 2/18/11, Pete Woodhead wrote: Hi I'm Pete Woodhead. I'm new to the list and to PHP. To be honest I very new to code writing. Thought this would be a good way to learn good habits as well as good code writing. Looking forward to learning and participating. Pete: Welcome to the gang. Minor points: 1. It's not code writing, it's coding. 2. You are not a code writer, but rather a coder. You can also be called a computer programmer or a programer for short -- not to mention some of the other names we are often called. :-) Cheers, tedd Hi Tod, Thanks for the welcome and the jargon corrections. So far the other help I've received is to show me, the new guy where the clean up broom and shovel are! We'll if you'll excuse me I've got some sweeping to do. :) Regards, Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to list and to PHP
On 2/20/2011 6:41 PM, Richard Quadling wrote: On 20 February 2011 23:34, Richard Quadlingrquadl...@gmail.com wrote: On 18 February 2011 19:03, Pete Woodheadpete.woodhea...@gmail.com wrote: Hi I'm Pete Woodhead. Â I'm new to the list and to PHP. Â To be honest I very new to code writing. Thought this would be a good way to learn good habits as well as good code writing. Looking forward to learning and participating. Assume that all the data you get from the user is out to get you. It probably isn't. Most of the time. But when it does, it'll be your fault. Unless you've left the company by then. Also, poka-yoke is a great concept to learn about (thanks to a great article in php|Architect all the way back when). Richard. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY http://www.phparch.com/magazine/2006-2/february/ in case anyone was wondering. Hi Richard, Thanks for the welcome, the advice and the link. I was not aware of PHP | Architect. Truth be told I'm still at the PHP for Dummies level. Regards, Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML errors
On 12/01/11 14:13, Richard Quadling wrote: On 12 January 2011 14:07, Steve Staplessstap...@mnsi.net wrote: On Wed, 2011-01-12 at 13:40 +, Richard Quadling wrote: On 12 January 2011 13:20, Steve Staplessstap...@mnsi.net wrote: Jim, Not to be a smart ass like Danial was (which was brilliantly written though), but you have your example formatted incorrectly. You are using commas instead of periods for concatenation, and it would have thrown an error trying to run your example. :) # corrected: echo lia href=\index.php?page={$category}\{$replace}/a/li; Steve Staples. Steve, The commas are not concatenation. They are separators for the echo construct. I don't know the internals well enough, but ... echo $a.$b.$c; vs echo $a, $b, $c; On the surface, the first instance has to create a temporary variable holding the results of the concatenation before passing it to the echo construct. In the second one, the string representations of each variable are added to the output buffer in order with no need to create a temp var first. So, I think for large strings, using commas should be more efficient. Richard. Well... I have been learned. I had no idea about doing it that way, I apologize to you, Jim. I guess my PHP-fu is not as strong as I had thought? Thank you Richard for pointing out this to me, I may end up using this method from now on. I have just always concatenated everything as a force of habit. Steve Staples. I was never taught by nuns. Eh? Oh I get it... (ugh!) Surely PHP-fu is taught by monks? -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: HTML errors
On 12/01/11 03:35, David McGlone wrote: Hi Everyone, I'm having a problem validating some links I have in a foreach. Here is my code: !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd; my PHP code: $categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us', 'testimonials'); foreach($categorys as $category){ $replace = str_replace(_, , $category); echo lia href='index.php?page=$category'$replace/a/li; } Validator Error: an attribute value must be a literal unless it contains only name characters …omehome/a/lilia href=index.php?page=servicesservices/a/lilia h… I have tried various combinatons and different doctypes. I'm beginning to wonder if this code is allowed at all. All the other replies are talking nonsense (especially Daniel ;) ! There's no reason why HTML with single-quoted attributes isn't valid, so in principle your expected output of a href='index.php?page=services'services/a should be OK. The real challenge is to understand why the code fragment you have presented is losing the single quotes: are you *sure* this is exactly what you have in your file (i.e. have you copied it to the posted message properly) ? -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Form Processing
On 29/11/10 23:54, Ron Piggott wrote: I am unable to retrieve the value of $referral_1 from: $new_email = mysql_escape_string ( $_POST['referral_$i'] ); why? PHP while lopp to check if any of the fields were populated: $i=1; while ( $i= 5 ) { $new_email = mysql_escape_string ( $_POST['referral_$i'] ); if ( strlen ( $new_email ) 0 ) { } } The form itself: form method=post action=”website” p style=margin: 10px 50px 10px 50px;input type=text name=email maxlength=60 class=referral_1 style=width: 400px;/p p style=margin: 10px 50px 10px 50px;input type=text name=email maxlength=60 class=referral_2 style=width: 400px;/p p style=margin: 10px 50px 10px 50px;input type=text name=email maxlength=60 class=referral_3 style=width: 400px;/p p style=margin: 10px 50px 10px 50px;input type=text name=email maxlength=60 class=referral_4 style=width: 400px;/p p style=margin: 10px 50px 10px 50px;input type=text name=email maxlength=60 class=referral_5 style=width: 400px;/p p style=margin: 10px 50px 10px 50px;input type=submit name=submit value=Add New Referrals/p /form What am I doing wrong? Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info The Daniels are on the right track, but not very clear: First, the input elements all have the 'name' attribute set to 'email' and the 'class' set to 'referral_1' etc. - I think you have that the wrong way round! Second, using single quotes in the $_POST['referral_$i'] bit will not work (DPB is right there) - use $_POST['referral_'.$i] or $_POST[referral_$i] -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Xpath arguments in variable
On 15/09/10 18:00, David Harkness wrote: And let's not forget $v = $row-xpath(//membernumber[. = \$MemberId\]); The \ inside the string turns into a double-quote and using to delimit the string allows for variable substitution. Oooh, I hate using backslashes - they always seem so untidy... I have a pathological fear of sed scripts, too. :( -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Xpath arguments in variable
If you needed the double-quotes in the Xpath expression when the constant is used , then you probably need them in the variable version. $v = $row-xpath('//membernumber[. = '.$MemberId.']'); That should put the double-quotes in for you... On 15/09/10 09:33, Sridhar Pandurangiah wrote: Original Message Subject: Re: Xpath arguments in variable From: php-gene...@garydjones.name (Gary) To: Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST) Whats wrong with $v = $row-xpath('//membernumber[. = ' . $MemberId . ']'); ? Am I not understanding what you are trying to ask? I tried this but doesn't work. I guess the above statement is concatenating the entire string and the substitution isn't happening What I am trying to do is as follows $MemberId = 'A192'; $v = $row-xpath('//membernumber[. = ' . $MemberId . ']'); The $MemberId should be substituted with A192 and then the xpath query should be executed. The result should be that I locate the membernumber XML element that has the value A912. Best regards Sridhar Sridhar Pandurangiah wrote: now I need to pass this value to XPath within a string variable say $v = $row-xpath('//membernumber[. = $MemberId]'); But this doesnt work due to the quotes. What I intend PHP to do is to substitute the value for $MemberId and then execute the XPath query. I have grappled with it for a few days before posting this. Whats wrong with $v = $row-xpath('//membernumber[. = ' . $MemberId . ']'); ? Am I not understanding what you are trying to ask? -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Standalone WebServer for PHP
On 12/09/10 18:33, tedd wrote: At 5:57 PM +0100 9/12/10, Ashley Sheridan wrote: On Sun, 2010-09-12 at 12:55 -0400, tedd wrote: Can a business have a server connected to the Internet but limit access to just their employees? I don't mean a password protected scheme, but rather the server being totally closed to the outside world other than to their internal employees? Or is this something that can only be provided by a LAN with no Internet connection? Not entirely sure what you're asking, but could you maybe achieve something like this with a WAN using a VPN? Thanks, Ash Ash: I'm sure this is an obvious question for many on this list, but I'm not above showing my ignorance. I guess what I am asking -- if a client wanted an application written (in web languages) so that their employees could link all their different computers together and share/use information using browsers, is that possible using a server that is not connected to the Internet? Look, I know that I can solve my clients problems by finding a host and writing scripts to do what they want -- that's not a problem. But everything I do is open to the world. Sure I can provide some level of security, but nothing like the security that can be provided behind closed and locked doors. So, can I do what I do (i.e., programming) without having a host? Can I install a local server at my clients location and interface all their computers to use the server without them ever being connected to the Internet? Maybe I should ask my grandson. :-) Cheers, tedd If the network is set up (as most business and home networks are these days) to use Network Address Translation (NAT) at the connection point to the world, then you shold be able to achieve this. NAT is where you have an internal network using private addresses (often in the 192.168.xxx.xxx range) but all outgoing traffic appears on the internet to come from one public address. So you configure your web server to accept requests from only the internal addresses. With Apache you could do this on a per-directory basis, even, so the web server could have public content (visible to all client addresses) and then have private content in subdirectories which only accept clients on the internal network addresses. There is a possible loophole due to IP address spoofing, but I suspect that your gateway device (firewall, ADSL or cable router that connects you to the world) will block those sort of clients. -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Trapping for PDF Type and file size in a UPLOAD form...
On 29/07/10 19:10, tedd wrote: At 9:50 AM -0700 7/29/10, Don Wieland wrote: I am trying to create an UPLOAD form and need to figure a way to only allow PDF files to be selected. The short answer is you can't -- not from php. You can create a standard form and upload it from there, but you don't have control over file type. So you can't stop people from uploading anything to your site via the form, but you can look at the document once it's there and inspect it. Using a HEX Editor, I see that most pdf file have the first four bytes as %PDF so you might check that before moving the file to somewhere important. But that doesn't stop spoofing. Other than that, I can't see any way to do it. Cheers, tedd Second what tedd says, with a bit more: on a Linux backend system I run uploaded files through the 'file' command with a decent magic file to detect the file type. I also run every upload through a virus scanner (clamscan, for example) before I accept it. If your PHP backend is windows then you might need to do some research to find a good file-type detection routine, although the virus scanning should be possible. You certainly cannot trust the client side to do any checking. In any case, JavaScript doesn't (shouldn't) have access to the file you are trying to upload, so there's not much you can do there. You might achieve something client-side with Flash, or a Java uploader applet, I suppose. Cheers Pete -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Do you have some standard for defined the variable in program language?
On 27/07/10 10:42, viraj wrote: $firstName is the most readable.. for variables. does anybody have negative thoughts on using the same naming format for method/function and for class names? i guess it's worth sharing! many thanks! ~viraj I like to use $firstName, and function firstName(), but I would use class FirstName. Somehow in my mind, classes are important enough to earn the initial capital letter. -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] storing files in database and retriving them
On 27/07/10 14:16, Peter Lind wrote: 2010/7/27 Nilesh Govindarajanli...@itech7.com: 2010/7/27 Dušan Novakovićndu...@gmail.com: Hello, so when I'm sending the array to model it's like this: $fp = fopen(INVOICE_PATH.date('Y-m-d').DS.$pdfName, r); $pdfContent = array( 'file' = base64_encode(fread($fp, filesize(INVOICE_PATH.date('Y-m-d').DS.$pdfName))), 'name' =$pdfName, 'size' = filesize(INVOICE_PATH.date('Y-m-d').DS.$pdfName), 'type' = mime_content_type(INVOICE_PATH.date('Y-m-d').DS.$pdfName) ); fclose($fp); so the data in db are ok, and this type is application/pdf. And when I'm getting data, I get the array like this: $file = Array ( [id] = 2 [file] =VBERi0xLjM...= here file is base64_encode() [file_size] = 2204 [file_type] = application/pdf [file_name] = 2_file.pdf ) Headers: header(Content-length: .$file['file_size']); header(Content-type: .$file['file_type']); header(Content-Disposition: attachment; filename= .$file['file_name']); echo base64_decode($file['file']); So, mime looks ok, but still... not working :-( -- mob: + 46 70 044 9432 web: http://novakovicdusan.com Please consider the environment before printing this email. Are you sure that you need Content-Disposition? Try removing that. I think that's used only in emails (Correct me if I'm wrong). You're wrong. Content-Disposition tells the browser how to handle the content - in this case, the browser will download the file instead of displaying it. Regards Peter I think you need to be careful about quoting the file name in the Content-Disposition header: something like header('Content-Disposition: attachment; filename='.$filename.'.xml'); seems to be the right quoting - the filename needs to be in double-quotes -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to alter the schema of a database to introduce newfeatures or change the current features
On 15/07/10 06:03, Paul M Foster wrote: On Wed, Jul 14, 2010 at 09:28:53PM -0700, Slith One wrote: I'm developing an app using Zend Framwork using Git for version control. What is the best approach for updating the schema and the database when one of us makes an update to the db structure? currently, we have to blow out the tables and recreate them manually to reflect the new updates. I'm probably being naive, but don't you have an ALTER TABLE sql statement available to you? Also, for what it's worth, I don't build tables manually (at the command line or whatever). I always create a script which will build the tables I need. If, for some crazy reason, I do have to restart from scratch, it's a simple matter to alter that script and re-run it. Paul Scripting is the way to go for database changes: every time I have to make a schema change I write an SQL script to do the job, including any manipulation of data required. Then I make a copy of the real data and test the hell out of the change script before going live with it. You can commit the database script to your source control at the time you commit the code changes, and then when you update the live system you run any new scripts at the same time. -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to alter the schema of a database to introducenewfeatures or change the current features
On 15/07/10 09:14, Ashley Sheridan wrote: ALTER TABLE is the way to go. If in doubt, look at the SQL phpMyAdmin produces when you make the changes in there. Thanks, Ash http://www.ashleysheridan.co.uk Yeah, scripting ALTER TABLE commands ... :) -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Inner join woes... and sweet tea!
On 05/07/10 14:38, Richard Quadling wrote: On 5 July 2010 14:02, Jason Pruimli...@pruimphotography.com wrote: Hi everyone, I'll admit right now that I'm still trying to wrestle with inner joins... It is all about set theory. Imagine two circles, which overlap (http://en.wikipedia.org/wiki/Venn_diagram#Example as an example). For that example, simplistically, A contains me and my emu. B contains my emu and the my deathwatch beetle. SELECT * FROM A,B WHERE A.id = B.id (My emu) SELECT * FROM A INNER JOIN B ON A.id = B.id (My emu) SELECT * FROM A LEFT OUTER JOIN B ON A.id = B.id (Me and My emu) SELECT * FROM A RIGHT OUTER JOIN B ON A.id = B.id (My emu and my deathwatch beetle) SELECT * FROM A FULL OUTER JOIN B ON A.id = B.id returns in interesting set (essentially all things but 1 column for each table). Me, null My emu, my emu null, My deathwatch beetle. If you were using ISNULL ... SELECT ISNULL(A.name, B.name) AS name FROM A FULL OUTER JOIN B ON A.id = B.id would return all things Me My emu My deathwatch beetle. And, (I think), finally, an inversion of the inner join. SELECT ISNULL(A.name, B.name) AS name FROM A FULL OUTER JOIN B ON A.id = B.id WHERE A.id IS NULL OR B.id IS NULL returns Me My deathwatch beetle. All things except those 2 legged things that can fly. I hope that helps. Regards, Richard. P.S. I don't have an emu. Clearly, or you'd know that they can't fly either... :) -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: combo box validation
On 07/06/10 18:49, David Mehler wrote: Hello, I've got a form with two combo boxes, one for the month one for the day. Both are required. I've got code that checks the post submission to ensure neither is empty. My problem is that if a user does not select anything in the combo boxes January first is sent, this i don't want. If they haven't selected anything i'd like that to show as an error. Thanks. Dave. It's not really php, but if you make the default option of each combo return an empty value then you can assume that the user didn't choose anything and flag the error: Like: select name='month' option selected='selected' value=''Select One/option option value='january'January/option ... /select You should find that if the empty option is selected the PHP will not receive a value in $_REQUEST['month'], or at least it will be something equivalent to NULL. -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Encoder like IonCube
On 12/05/10 01:06, Ashley Sheridan wrote: On Tue, 2010-05-11 at 16:50 -0700, Brian Dunning wrote: Hi Shiplu - I also have a product with similar requirements. I searched a LOT and was never able to find a free solution that I was satisfied with. Even a lot of the commercial solutions required some server-side runtime EXE or something be installed, and my customers are not tech savvy enough to get that going. I ultimately settled on PHP Lockit, which is $29. It's a Windows program that you run to create an obfuscated version of your script. I'm very satisfied with the obfuscation, and it does not require any external runtime files or anything. Works like a charm, and I recommend it. http://phplockit.com/ - Brian On May 9, 2010, at 1:36 PM, shiplu wrote: Is there any php encoder like IonCube ? Looking for an opensource solution. My main target is to deliver encoded php codes so that it can not be re-engineered. Does slightly limit you to the Windows platform though, which I always think is a shame when using a language as open as PHP. Thanks, Ash http://www.ashleysheridan.co.uk Maybe it'll run under Wine? I might just try that with a demo version... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Encoder like IonCube
On 12/05/10 10:48, Pete Ford wrote: On 12/05/10 01:06, Ashley Sheridan wrote: On Tue, 2010-05-11 at 16:50 -0700, Brian Dunning wrote: Hi Shiplu - I also have a product with similar requirements. I searched a LOT and was never able to find a free solution that I was satisfied with. Even a lot of the commercial solutions required some server-side runtime EXE or something be installed, and my customers are not tech savvy enough to get that going. I ultimately settled on PHP Lockit, which is $29. It's a Windows program that you run to create an obfuscated version of your script. I'm very satisfied with the obfuscation, and it does not require any external runtime files or anything. Works like a charm, and I recommend it. http://phplockit.com/ - Brian On May 9, 2010, at 1:36 PM, shiplu wrote: Is there any php encoder like IonCube ? Looking for an opensource solution. My main target is to deliver encoded php codes so that it can not be re-engineered. Does slightly limit you to the Windows platform though, which I always think is a shame when using a language as open as PHP. Thanks, Ash http://www.ashleysheridan.co.uk Maybe it'll run under Wine? I might just try that with a demo version... Looks like it works fine under Wine, at least the demo does... -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Encoder like IonCube
On 12/05/10 11:23, shiplu wrote: Can you paste a sample encoded version of a php file on pastie.org? Shiplu Mokadd.im My talks, http://talk.cmyweb.net Follow me, http://twitter.com/shiplu SUST Programmers, http://groups.google.com/group/p2psust Innovation distinguishes bet ... ... (ask Steve Jobs the rest) OK, I just did the phpPgAdmin index.php page (just something public-domain I had lying around): Here's the original: http://www.pastie.org/pastes/956801 and here's the encoded: http://www.pastie.org/pastes/956803 I haven't yet checked that the encoded version works! -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting floats to ints with intval
On 06/05/10 11:52, Paul Waring wrote: Ashley Sheridan wrote: Why don't you store them as integer values and add in the decimal point with something like sprintf() afterwards? Store the values as pence and then you won't have any rounding problems. If I was designing the system from scratch, that's what I'd do. Unfortunately this is an add-on to a legacy system where currency values are already stored as strings in the database (yes, not ideal I know, but you have to work with what you've got). Can you not just add up the floating point numbers and the round them with round() (http://www.php.net/manual/en/function.round.php) Certainlay for consistent calculations I'd always use the float values for as long as possible... Otherwise, why not multiply by 1000 before taking the intval, then at least you preserve the next decimal place. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Error handling strategies (db related)
On 27/04/10 16:37, tedd wrote: Error handling is almost an art form. More like a black art - voodoo perhaps... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Weird problem with is_file()
On 26/04/10 16:56, Michelle Konzack wrote: Hello Peter, Am 2010-04-26 09:28:28, hacktest Du folgendes herunter: var_dump($isfile); Don't make assumptions of what the value is, just check it. Yes and grmpf! The filename has a space at the end but it can not removed even using var_dump(str_replace(' ', '', $isfile); if I put a '1' as search parameter all '1' are removed, but WHY can I not remove a space at the end? Even if a do a mv the_file_not_recognized the_file_not_recognized\space it is not detected... even if the var_dump() show me something like string(29) /tmp/the_file_not_recognized Simple to test exec(touch /tmp/the_file_not_recognized); $FILE=shell_exec(ls /tmp/the_file_not_* |head -n1); var_dump($FILE); echo br; var_dump(str_replace(' ', '', $FILE); Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator Is it possible that the space is a new-line (or a carriage-return) ? What happens if you replace str_replace(' ', '', $FILE) with preg_replace('/\s+$/','',$FILE); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP GUI library/package
Hi All, I have a web project built in PHP which we want to break out part of into a stand-alone GUI program. The architecture is fine - display nicely separated from logic, so coding is not a problem. What I can't work out is what to use for the GUI part. I looked at phpqt but I can't (yet) get that to build on my Linux dev system, let alone code an interface with it. I was also looking a PHP-GTK2, but I'm not sure how cross-platform it would be - this should run on Windows and Macs as well as Linux... Anyone made a GUI PHP application like this, with one of the major toolkits? Cheers Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP GUI library/package
On 31/03/10 15:30, Ashley Sheridan wrote: On Wed, 2010-03-31 at 15:30 +0100, Pete Ford wrote: Hi All, I have a web project built in PHP which we want to break out part of into a stand-alone GUI program. The architecture is fine - display nicely separated from logic, so coding is not a problem. What I can't work out is what to use for the GUI part. I looked at phpqt but I can't (yet) get that to build on my Linux dev system, let alone code an interface with it. I was also looking a PHP-GTK2, but I'm not sure how cross-platform it would be - this should run on Windows and Macs as well as Linux... Anyone made a GUI PHP application like this, with one of the major toolkits? Cheers Pete I think as far as compatibility goes, QT is your best bet. What is preventing you from getting that build onto your dev system? Thanks, Ash http://www.ashleysheridan.co.uk Two pints at lunchtime, mainly :) I need to focus on it a bit better: I'll have another look and ask again if I still have trouble. Cheers Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP GUI library/package
On 31/03/10 15:30, Ashley Sheridan wrote: On Wed, 2010-03-31 at 15:30 +0100, Pete Ford wrote: Hi All, I have a web project built in PHP which we want to break out part of into a stand-alone GUI program. The architecture is fine - display nicely separated from logic, so coding is not a problem. What I can't work out is what to use for the GUI part. I looked at phpqt but I can't (yet) get that to build on my Linux dev system, let alone code an interface with it. I was also looking a PHP-GTK2, but I'm not sure how cross-platform it would be - this should run on Windows and Macs as well as Linux... Anyone made a GUI PHP application like this, with one of the major toolkits? Cheers Pete I think as far as compatibility goes, QT is your best bet. What is preventing you from getting that build onto your dev system? Thanks, Ash http://www.ashleysheridan.co.uk Not all down to the beer. I unpacked the php-qt-0.9.tar.gz and made a build directory in there, ran cmake (which seemed to go OK), but make fails at [ 8%] Building CXX object smoke/qt/CMakeFiles/smokeqt.dir/x_2.o with a bunch of errors like /home/pete/phpqt/build/smoke/qt/x_2.cpp: In static member function ‘static void x_QAccessibleBridgeFactoryInterface::x_0(Smoke::StackItem*)’: /home/pete/phpqt/build/smoke/qt/x_2.cpp:167: error: cannot allocate an object of abstract type ‘x_QAccessibleBridgeFactoryInterface’ /home/pete/phpqt/build/smoke/qt/x_2.cpp:163: note: because the following virtual functions are pure within ‘x_QAccessibleBridgeFactoryInterface’: /usr/include/QtCore/qfactoryinterface.h:53: note: virtual QStringList QFactoryInterface::keys() const I'm building on an OpenSuSE 11.1 system, but looking around it seems that Fedora 12 has a php-qt package, so I'm putting together a VM to try it on there... If you have any light to shed, then let me know. The php-qt mailing list seems a bit empty at the moment... Cheers Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP in HTML code
On 17/03/10 18:59, Tommy Pham wrote: On Wed, Mar 17, 2010 at 11:01 AM, Rene Veermanrene7...@gmail.com wrote: hmm.. seems easier to me to push a filetree of .php's with?= through the str_replace(), than it is to get all the?= writers to comply with your wishes, which may not apply to their situation ;-) On Wed, Mar 17, 2010 at 5:14 PM, teddtedd.sperl...@gmail.com wrote: At 8:55 PM -0400 3/16/10, Adam Richardson wrote: That said, I'm not taking exception with those who don't use the short tag, only with those who say I shouldn't. Exception or not, it's still your choice and using short tags can cause problems. My view, why create problems when there is a solution? Forcing the issue is a bit like I'm going to do it my way regardless! I've traveled that path too many times in my life. Sometimes it's easier to take the path most traveled. Cheers, ted -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php http://www.php.net/manual/en/language.basic-syntax.phpmode.php There are four different pairs of opening and closing tags which can be used in PHP. Two of those,?php ? andscript language=php /script, are always available. The other two are short tags and ASP style tags, and can be turned on and off from the php.ini configuration file. As such, while some people find short tags and ASP style tags convenient, they are less portable, and generally not recommended. But the implication there is that they are *only* non-portable *because* they can be switched off - there's no other strong reason. Before anyone jumps in with XML / XHTML arguments again, those issues are fairly rare and very easily worked around. My projects tend to use XHTML doctype because it makes IE7/8 behave more predictably without a ?xml ? block, and I always use short tags for ?= because the alternative is so ugly! In the rare cases where I generate XML from a PHP script, there are workarounds for the ? problem. I do tend to use ?php for blocks of code - so I guess I'm in the middle camp here. I also write code to be hosted on dedicated systems that I have full control over, so php.ini settings are always in my control (so far...) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Enforce a constant in a class.
Richard Quadling wrote: 2010/1/22 Pete Ford p...@justcroft.com: IMHO, a constant is not the correct beastie in this case - if you want it to be different depending on the implementation then it ain't a constant! You should probably have protected static variables in the interface, and use the implementation's constructor to set the implementation-specific value (or override the default) interface SetKillSwitch { protected static $isSet = TRUE; protected static $notes; protected static $date = '2010-01-22T11:23:32+'; } class KilledClass implements SetKillSwitch { public function __construct() { self::$isSet = FALSE; self::$date = '2010-01-21T09:30:00+'; self::$notes = Test; } } Cheers Pete Ford And of course, Fatal error: Interfaces may not include member variables. Ooops, sorry :) I tend to end up using abstract base classes rather than interfaces for that sort of reason... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Enforce a constant in a class.
Richard Quadling wrote: Hello, One of the aspects of an interface is to enforce a public view of a class (as I see it). Within PHP, interfaces are allowed to have constants, but you cannot override them in a class implementing that interface. This seems wrong. The interface shouldn't define the value, just like it doesn't define the content of the method, it only defines its existence and requires that a class implementing the interface accurately matches the interface. Is there a reason for this behaviour? _OR_ How do I enforce the presence of a constant in a class? ?php interface SetKillSwitch { const KILL_SWITCH_SET = True; // Produces an error as no definition exists. // const KILL_SWITCH_NOTES; // Cannot override in any class implementing this interface. const KILL_SWITCH_DATE = '2010-01-22T11:23:32+'; } class KilledClass implements SetKillSwitch { // Cannot override as defined in interface SetKillSwitch. // const KILL_SWITCH_DATE = '2010-01-22T11:23:32+'; } ? I want to enforce that any class implementing SetKillSwitch also has a const KILL_SWITCH_DATE and a const KILL_SWITCH_NOTES. I have to use reflection to see if the constant exists and throw an exception when it doesn't. The interface should only say that x, y and z must exist, not the values of x, y and z. Regards, Richard. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling IMHO, a constant is not the correct beastie in this case - if you want it to be different depending on the implementation then it ain't a constant! You should probably have protected static variables in the interface, and use the implementation's constructor to set the implementation-specific value (or override the default) interface SetKillSwitch { protected static $isSet = TRUE; protected static $notes; protected static $date = '2010-01-22T11:23:32+'; } class KilledClass implements SetKillSwitch { public function __construct() { self::$isSet = FALSE; self::$date = '2010-01-21T09:30:00+'; self::$notes = Test; } } Cheers Pete Ford -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to retrieve a dom from innerHTML......
I am on the top of the world! Borlange University wrote: hello, i can obnot retrieve a select ject from div innerHTML. what i want to do is that when a page is loaded, first selector,say #1, would be shown in the first div by sending a request.then i choose one option from #1, fire change event of #1, the second selector #2 will be shown in div two, then choose option from #2 .blabla.. but the problem is when selector #1 was loaded, the object #1 could not be obtained. codes: window.addEvent('domready', function() { var option=1; var result = new Request({ url:'getInfo_gx.php'https://mail.google.com/mail/html/compose/static_files/'getInfo_gx.php' , method:'get', onSuccess:function(response) { if(option==1) $('list_sch').innerHTML = response; //response = select id='sch_list...'; else if(option==2) $('list_gg').innerHTML = response; else $('list_gx').innerHTML = response; } }); result.send('type=1');// page loaded,sending a request. $('list_sch').innerHTML = select id='sch_list'option value='123'123312/option/select; if($('sch_list')) // heres the problem... object can not be obtained. { $('sch_list').addEvent('change',function(){ // events can not be fired option=2; result.send('type=2'+'sch='+$('sch_list').value.replace('+','%2B')); }); } }); You probably ought to ask a Javascript forum about javascript problems... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php/ruby drb adapter
Hi, I'll be honest: php is not my favorite programming language. That honor goes to ruby. And I don't mean ruby-on-rails; just straight, pure unfettered ruby. I use ruby to write web applications and just about everything else. However, there are obviously very many web applications and webapp frameworks written in php. I have recently taken an interest in eyeOS (http://eyeos.org/), with the intent to hack eyeOS to use a certain ruby back-end file service I've written instead of accessing the local file system directly. This ruby service communicates with clients via ruby's native distributed ruby (DRb) facility. DRb makes it marvelously easy to write distributed multi-threaded services, provided the clients are written in ruby as well. But what if the client is written in, say, php? Wouldn't it be nice if a php client could access DRb-driven ruby services just as simply as a ruby client can? Not finding any such existing facility, I've written a php object class, DRbClient. This class invokes object methods offered by the remote ruby service, passing strings, integers, floats, booleans, nulls, and/or arrays as arguments, and accepts a return value of any of those same types. All data translation and inter-process communication is transparent. It's just as if a local object instance is being messaged directly. If there's interest, I'd like to offer DRbClient to the php community, but I'm not sure how to go about that. -- Pete Yadlowsky ITC Unix Systems Support University of Virginia -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strtotime - assumptions about default formatting of dates
On 24/12/09 16:59, Bastien Koert wrote: On Thu, Dec 24, 2009 at 9:12 AM, teddtedd.sperl...@gmail.com wrote: At 10:20 PM +1000 12/24/09, Angus Mann wrote: Hi all. I need to allow users to enter dates and times, and for a while now I've been forcing them to use javascript date/time pickers so I can be absolutely sure the formatting is correct. Some users are requesting to be able to type the entries themselves so I've decided to allow this. I'm in Australia, and the standard formatting of dates here is DD/MM/ or DD-MM- I recognize this is different to what seems to happen in the US, where it is MM/DD/ or MM-DD- When I process an entered date using strtotime() it seems to work fine. But of course I am concerned when dates like January 2 come up. I find that 2/1/2009 is interpreted as January 2, 2009 on my installation, which is Windows 7 with location set to Australia. But can I be sure that all installations of PHP, perhaps in different countries and on different operating systems will interpret dates the same? I can't find much mention of this question online or in the manual. Any help much appreciated. Angus Angus: You are running into a problem that cannot be solved by allowing the user to do whatever they want. As you realize, if I enter 01-02-09 you don't know if I mean January 2, 2009 or February 1, 2009 and there is no way to figure out what I meant. The solution is simply to use the htmloption and give the user that way to enter month and day. I would set it to day-month-year and let US visitors live with it for I personally think that's a better format. Cheers and Merry Christmas. 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 I would agree with tedd. Use a JS calendar widget (requires js) or use three select boxes for mm , dd and year I developed my little text input AJAX (see earlier post) to work around the fact that a LOT of users I encountered were cheesed off by JS calendar widgets, especially when the date to be entered was a long way from the current date (such as a date of birth). I tried implementing some scroll-wheel events to speed up year selection on one of these but it was tricky to get cross-browser support. Drop-downs are a pain when you have to scroll back 40+ years to find the right one and are implicitly limited by how far back and forward the designer expects to need, and then you have the problem of validating the days and months (which, to be fair, is a pretty simple javascript task) I suspect that with a bit of thought I could put together a Javascript date validator that parsed most possible inputs and produced a sensible interpretation of them, but I was lazy and had AJAX machinery set up already in my project. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: strtotime - assumptions about default formatting of dates
On 24/12/09 12:20, Angus Mann wrote: Hi all. I need to allow users to enter dates and times, and for a while now I've been forcing them to use javascript date/time pickers so I can be absolutely sure the formatting is correct. Some users are requesting to be able to type the entries themselves so I've decided to allow this. I'm in Australia, and the standard formatting of dates here is DD/MM/ or DD-MM- I recognize this is different to what seems to happen in the US, where it is MM/DD/ or MM-DD- When I process an entered date using strtotime() it seems to work fine. But of course I am concerned when dates like January 2 come up. I find that 2/1/2009 is interpreted as January 2, 2009 on my installation, which is Windows 7 with location set to Australia. But can I be sure that all installations of PHP, perhaps in different countries and on different operating systems will interpret dates the same? I can't find much mention of this question online or in the manual. Any help much appreciated. Angus I wrote a little AJAX gadget which sent the string typed to a PHP backend which parsed it using strtotime and then formatting it out again as something unamiguous (like 2 January 2009). Then every time the date entry field is changed by the user (with an onKeyUp event), this AJAX call is triggered and displays the unambiguous form next to the input box, so users can see how their entry is being interpreted. Of course, there's some overhead in the AJAX calls, and it requires JavaScript. If you wanted to do without JavaScript you could do a similar parse-format sequence when the form is submitted and show a confirmation page with your server's interpretation of the date. Cheers Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Lookimg for a script....
Can anyone point me to a (free) script that will ask for a person's email address and username, and then look up the password that's in a plain text file? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about sending email
Daniel Brown has written on 4/16/2008 5:20 PM: On Wed, Apr 16, 2008 at 5:14 PM, Pete Holsberg [EMAIL PROTECTED] wrote: Why do I need both from_addr and field_4 (Email Address)? Could I just use $from = $_POST['field_4']? Sorry, I noticed it after I started rewriting the form processor, and then forgot to edit the email accordingly. That's correct. Where I placed the $_POST['from_addr'] stuff, just replace it with $_POST['field_4']. And then, of course, you can ignore the HTML field-adding section of my previous email OK. Here's what I have now for processor.php: ?php // $where_form_is=http://.$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),/)); $where_form_is = http://.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF'])./; if (mail($to, $from, $subject, $body)) { echo(pMessage successfully sent!/p); } else { echo(pMessage delivery failed.../p); } $to = [EMAIL PROTECTED],[EMAIL PROTECTED]; $subject = SUBSCRIBE; $from = $_POST['field_4']; $body = Form data: Name: .$_POST['field_1']. Street Address: .$_POST['field_2']. Phone Number: .$_POST['field_3']. Email Address: .$_POST['field_4']. powered by phpFormGenerator, but fixed by PHP-General!; $headers = From: \.$_POST['field_1'].\ .$_POST['from_addr'].\r\n; $headers .= X-Mailer: PHP/.phpversion().\r\n; include(confirm.html); ? I don't get either of the echo statements, and the emails are not being delivered. What did I omit? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about sending email
Daniel Brown has written on 4/17/2008 12:29 PM: I'll reiterate: Note the mail() parameters. There's no header information there. RTFM: http://php.net/mail You just have your mail() function wrong. Reiterating my code as well (with updated field_4 data): ?php $where_form_is = http://.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF'])./; $to = [EMAIL PROTECTED],[EMAIL PROTECTED]; $subject = SUBSCRIBE; $from = $_POST['field_4']; $body = Form data: Name: .$_POST['field_1']. Street Address: .$_POST['field_2']. Phone Number: .$_POST['field_3']. Email Address: .$_POST['field_4']. powered by phpFormGenerator, but fixed by PHP-General!; $headers = From: \.$_POST['field_1'].\ .$_POST['field_4'].\r\n; $headers .= X-Mailer: PHP/.phpversion().\r\n; include(confirm.html); ? OK. I don't see a mail() in your code. Would it be mail($to, $subject, $body, $headers); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about sending email
Ooops! processor.php is now: ?php $where_form_is = http://.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF'])./; $to = [EMAIL PROTECTED],[EMAIL PROTECTED]; $subject = SUBSCRIBE; //$from = $_POST['field_4']; == this was the culprit $body = Form data: Name: .$_POST['field_1']. Street Address: .$_POST['field_2']. Phone Number: .$_POST['field_3']. Email Address: .$_POST['field_4']. powered by phpFormGenerator, but fixed by PHP-General!; $headers = From: \.$_POST['field_1'].\ .$_POST['field_4'].\r\n; $headers .= X-Mailer: PHP/.phpversion().\r\n; mail($to, $from, $subject, $body); include(confirm.html); ? AND IT WORKS!! 1E6 thank yous!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Newbie question about sending email
I wanted a form for people in my community to use to subscribe to a yahoo group that I run. Not being a PHP programmer, I created the form with phpFormGenerator from SourceForge. It works fine except that the email that gets sent to yahoo appears to come from my web host's domain! How can I change things so that the email appears to come from the email address that is entered in the form? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about sending email
Daniel Brown has written on 4/16/2008 4:04 PM: On Wed, Apr 16, 2008 at 3:53 PM, Pete Holsberg [EMAIL PROTECTED] wrote: I wanted a form for people in my community to use to subscribe to a yahoo group that I run. Not being a PHP programmer, I created the form with phpFormGenerator from SourceForge. It works fine except that the email that gets sent to yahoo appears to come from my web host's domain! How can I change things so that the email appears to come from the email address that is entered in the form? Make sure that the From:, Reply-To:, and Return-Path: headers are correctly set in the form processing code, that the headers in general are properly constructed, and that your host allows aliased sending by configuration (some MTA configurations only allow a single address, to reduce SPAM and such). The entire processor.php file is: ?php $where_form_is=http://.$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),/)); mail([EMAIL PROTECTED],[EMAIL PROTECTED],SUBSCRIBE,Form data: Name: . $_POST['field_1'] . Street Address: . $_POST['field_2'] . Phone Number: . $_POST['field_3'] . Email Address: . $_POST['field_4'] . powered by phpFormGenerator. ); include(confirm.html); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about sending email
Daniel Brown has written on 4/16/2008 4:56 PM: On Wed, Apr 16, 2008 at 4:39 PM, Pete Holsberg [EMAIL PROTECTED] wrote: The entire processor.php file is: ?php $where_form_is=http://.$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),/)); mail([EMAIL PROTECTED],[EMAIL PROTECTED],SUBSCRIBE,Form data: Name: . $_POST['field_1'] . Street Address: . $_POST['field_2'] . Phone Number: . $_POST['field_3'] . Email Address: . $_POST['field_4'] . powered by phpFormGenerator. ); include(confirm.html); ? Note the mail() parameters. There's no header information there. In your HTML form, add the following field (dress up the HTML as needed to fit with your form): input type=text name=from_addr Then, change the email processing code to the following: ?php $where_form_is = http://.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF'])./; $to = [EMAIL PROTECTED],[EMAIL PROTECTED]; $subject = SUBSCRIBE; $from = $_POST['from_addr']; $body = Form data: Name: .$_POST['field_1']. Email: .$_POST['from_addr']. Street Address: .$_POST['field_2']. Phone Number: .$_POST['field_3']. Email Address: .$_POST['field_4']. Why do I need both from_addr and field_4 (Email Address)? Could I just use $from = $_POST['field_4']? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php ajax
ello all, Im a beginner at php. but I was able to get this script to work. Now I am looking to have it automatically refresh itself using ajax every 10 seconds. Can somebody explain or show me how to do this. Thank you. PHP Code: | | |?php $httpfile = file_get_contents('http://www.game-monitor.com/client/buddyList.php?uid=8654listid=0xml=1'); $doc = DOMDocument::loadXML($httpfile); $myBuddyNodes = $doc-getElementsByTagName('buddy'); /not neccessary, but im using it $nameStatusDoc = new DOMDocument('1.0', 'iso-8859-1'); $rootElement = $nameStatusDoc-createElement('PetesList'); $rootElement = $nameStatusDoc-appendChild($rootElement); / echo table border = '0' cellpadding= '2' bgcolor='#616042'\ntheadtrth/thth/thtr/thead\n; foreach ($myBuddyNodes as $node) { echo tr; echo tdfont size='-1'.$node-firstChild-nextSibling-nodeValue./font/td; if($node-firstChild-nextSibling-nextSibling-nextSibling-nodeValue == Online) | -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Devenix Live CD PHP4 and PHP5 project needs help
Hi, This seemed like the most sensible place to start to ask for help. I'm currently working on Devenix, a project based on the knoppix live cd. It will eventually be a complete php design and test studio on a live cd, carry around a memory stick and save everything onto it, basically enabling you to work on any computer anywhere and get straight back to work. My PROBLEM is this. I need to install php4 and php5, my reasons? I want to make it a studio capable of assisting with code migration and testing from 4 to 5. php4 is already installed via the debian apt source. I initially tried installing php5 by compiling from clean source, but only ran into problems. I am now working on modifying the php5 source tar from the apt-sources to install into a different dir to avoid conflict with php4. I added teh prefix line to the common configure line in the debian/rules file, but this screwed up the libapachemodule rebuild when i tried to rebuild the pacakge. Please any advice here would be greatly appreciated. And any people wishing to help on the project would be fantastic. There is no website yet, once this stumbling block is overcome, the ball will start rolling. Thanx Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: array diff with both values returned
http://uk2.php.net/manual/en/function.array-diff.php http://uk2.php.net/manual/en/function.array-diff-assoc.php Blackwater Dev wrote: Hello, Is there a good way to get the difference in two arrays and have both values returned? I know I can use array_dif to see what is in one and not the other but...I need it to work a bit differently. I have: $array1=array(name=fred,gender=m,phone==555-); $array2=array(name=fred,gender=f,phone==555-); I want to compare these two and have it return: array(gender=array(m,f)); I want it to return all of the differences with the key and then the value from array 1 and 2. How? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] is_numeric
not a php expert but have filed this bug report re validating is_numeric('3e0'); http://bugs.php.net/bug.php?id=32943 Now tried function isnumeric($n) { if (ereg(^[0-9]{1,50}.?[0-9]{0,50}$, $n)) { return true; } else { return false; } } and that doent seem to work either.. any ideas.. need to validate anything without 0-9 and a dot within tia Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Check for doubleposts
set a $_SESSION['var'] at the end of the first post and check for this the second time around pete Fredrik Arild Takle wrote: Hi, what is the easiest way to check if a person i registered twice in a mysql-table. Lets assume that I only check if the last name is in the table more than once. This is in mysql 4.0 (subquery not an option). Do I have to use arrays and in_array. Or is there a more elegant solution? Best regards Fredrik A. Takle -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Templating engines
Hi clive I tried all of them and I must admit smarty comes out on top by a mile I use it on a very busy virtual host and have had NO problems with slow script etc, highly recommended http://smarty.php.net pete Clive Zagno wrote: Hi all, What templating engines do you use with php and why? Ive been using smarty (http://smarty.php.net) Clive. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: POP access to gmail
http://phpmailer.sourceforge.net/ excellent and easy to use class Malcolm Mill wrote: Does anyone know of a PHP script to access gmail's POP services? Thanks, Malcolm. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] .htaccess
I'm trying to figure out out to put a directive in .htaccess to make the session timeout in 4 hours .. tried php_flag session.cookie_lifetime 240 and a few others can someone help ! tia -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] email through PHP
check out phpmailer http://phpmailer.sourceforge.net/ use it all the time - its brilliant !!! Balwant Singh wrote: hi, I am using FEDORA 3 and PHP. I want to send email to outside by my above mentioned linux machine through PHP. For this i want to use my SMTP sever, which is on a WINDOWS machine Please inform what setting to be done in php.ini or any other file to send the email. with best wishes balwant -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] email through PHP
http://phpmailer.sourceforge.net/extending.html Balwant Singh wrote: hi, I am using FEDORA 3 and PHP. I want to send email to outside by my above mentioned linux machine through PHP. For this i want to use my SMTP sever, which is on a WINDOWS machine Please inform what setting to be done in php.ini or any other file to send the email. with best wishes balwant -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mailing lists
check out hotscripts.com Clive Zagno wrote: Hi does anyone use any cool php mailing list software. clive -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] reducing array size
Is there an easy way to trim an array ? I'm using array_unshift to push elemnts onto the front of an array but I want to limit the size to 20 ?? Is there an easy way to do this without looping and unsetting the elements ?? tia Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] query error
I've got a database table with a whole list of windows file paths. eg Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Binder.lnk Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Excel.lnk Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Office Setup.lnk Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Outlook.lnk Advent Tower PC\C\Program Files\Microsoft Office\Microsoft PowerPoint.lnk Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Word.lnk Advent Tower PC\C\Program Files\Microsoft Office\MS Access Workgroup Administrator.lnk Advent Tower PC\C\Program Files\Microsoft Office\MSCREATE.DIR Advent Tower PC\C\Program Files\Microsoft Office\OF97SPEC.INI Advent Tower PC\C\Program Files\Microsoft Office\Office Advent Tower PC\C\Program Files\Microsoft Office\Office\1033 Now I want my DB query to search for directories .. here's a sample query select * from ff_files where full_path like 'Advent Tower PC\C\freeserve\help\images\%' doesnt work as the % is taken as a literal '%' I've aslso tried like 'Advent Tower PC\\C\\freeserve\\help\\images\%' I'm completely lost .. all I want is to return all rows that start with 'Advent Tower PC\C\freeserve\help\images\' tia Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] regular expressions
I've been messing about with this for a while to no avail.. so help would be appreciates I'm new to regular expressions and tried this with preg_replace, now I'm using eregi_replace ! here's the text $txt = 'span style=font-size: 10pt; font-family: Times New Roman;Itbr / blahh blahhh blahhh ofbr / /span'; what I want to do it take the font-size and font-family attributes out so style=font-size: 10pt; font-family: Times New Roman; beomes style= and the php $pattern = 'font-size:*\;'; $txt = eregi_replace($replace,'',$txt); $pattern = 'font-family:*\;'; $txt = eregi_replace($replace,'',$txt); What I'm trying to do is match the font-size: and replace everything up to the ; with '' ie nothing dont work Feel I'm so close ;-( tia Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regular expressions
The pattern $pattern = 'font\-size:.*?\;'; throwns the error eregi_replace(): REG_BADRPT Erwin Kerk wrote: pete M wrote: I've been messing about with this for a while to no avail.. so help would be appreciates I'm new to regular expressions and tried this with preg_replace, now I'm using eregi_replace ! here's the text $txt = 'span style=font-size: 10pt; font-family: Times New Roman;Itbr / blahh blahhh blahhh ofbr / /span'; what I want to do it take the font-size and font-family attributes out so style=font-size: 10pt; font-family: Times New Roman; beomes style= and the php $pattern = 'font-size:*\;'; $txt = eregi_replace($replace,'',$txt); $pattern = 'font-family:*\;'; $txt = eregi_replace($replace,'',$txt); What I'm trying to do is match the font-size: and replace everything up to the ; with '' ie nothing dont work Feel I'm so close ;-( tia Pete Try this: $pattern = 'font\-size:.*?\;'; Erwin Kerk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regular expressions
Thankyou Diolch danka There seems to be a big difference between eregi_replace() and preg_replace Am reding teh Sams - Regular Expressions in 10 mins bu the syntax seems ot be different. !! regards pete Erwin Kerk wrote: pete M wrote: The pattern $pattern = 'font\-size:.*?\;'; throwns the error eregi_replace(): REG_BADRPT Well, this should work (tested and all ) $pattern=|font\-size:.*?;|si; $txt = preg_replace( $pattern, , $txt ); Erwin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Ad software
check www.hotscripts.com Ryan A wrote: Hey, I am looking for a software that just lists adverts... eg: Like ebay but without the bidding Requirements are simple, so simple that i am sure something like this exists and i dont have to write it myself: 0.They must register first then... 1.offer the person to put in his ad details, a few other details like his telephone number, asking price etc 2.(optional) add a photo 3. They can delete their ad if they want to later 4.normal visitors can search or browse by category or latest additions etc I can give you an example in the form of a swedish site: http://www.blocket.se I have found something very close in ASP but i dont trust MS products and would rather it be in PHP as i can tinker with it (i dont know ASP and my server does not support it) As you can see, it wouldnt take too long to build but i have little time so i would rather finish my lingering old projects than start on something new from scratchits for a pet site where people can sell (or barter/exchange) aquarium fish, fish food, aquariums, filters, stands etc Checking google and hot scripts just sends me to ad management software like banner rotators and bidding systems etc. Any help appreciated and thanks in advance. -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP and Access
Check this out http://adodb.sourceforge.net/ http://phplens.com/adodb/code.initialization.html#init have fun Pete Bruno Santos wrote: Hello. I need to to an application in PHP with graphics creation. The database where i need to go and fetch the values is access. is possible for PHP to fecth values from an access database ?? cheers Bruno Santos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help with adding
Jay Fitzgerald wrote: I have messed with this for a couple of days and cant get it right. Maybe I need sleep :-) The code below is echoing the qty correctly (10, 5, 25) $total = 0; for ($i = 1; $i = $sendnum; $i++) { $qty = $_POST['qty'.$i]; echo $qty . 'br /'; $total += $qty; } The question is, how would I take add each of these numbers (10+5+25)? Any help is appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Destroying the Session Object
here's the way I do it logout.php ?php session_start(); $_SESSION = array(); session_destroy(); header('Location: login.php'); ? Jacques wrote: I am developing an application. When the user signs in a Session ID is created (for argument sake: 123). I have a sign out page that has the script session_destroy() on it. This page directs me to the sign in page. When I sign the same or any other user in again I get the same session id (123). However, when I close the browser window and sign in again as any member, the session id changes. How does this work and how can I ensure that a unique session id is allocated to every new user that signs in? Jacques -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Missing $GLOBALS SCRIPT_URI
try $_SERVER['SCRIPT_URI']; Gary C. New wrote: I am writing some php code that requires the $GLOBALS['SCRIPT_URI'] variable. When I access the code under its encrypted (https) location it is available without issue. However, when I try to access the code under its unencrypted (http) location it is not available. In fact, phpinfo() shows that there are a lot less $GLOBALS available under the http location than there are under the https location. I am using Apache 1.39 with Php 4.2.3. Your comments are greatly appreciated. Respectfully, Gary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: retrieve single field from database without while loop
Check out abstraction layers I use adodb http://adodb.sourceforge.net/ makes coding much much easier ;-)) eg - mysql example $sql = insert into table (col, col2)values('$this','$that'); $db-execute $sql; // get last id $new_id = $db-getOne('select last_insert_id()'); have fun Pete [EMAIL PROTECTED] wrote: Is there a way to retrieve and display a single value (customer number) from a database and display it without using while ($row = mysql_fetch_array) ($result)){ I have a value I know the query will only ever return a single value. I want to get it from the database and convert it to a variable so I can use it on my php page. Thanks in advance, Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fsockopen
am not having a lot of success with opening a socket to a secure domain (php 4.3.8 - apache - openSSL) $fp = fsockopen($url , 443 ,$errno, $errstr, 30); have tried the following $urls --- $url = 'domain.net'; Bad Request Your browser sent a request that this server could not understand. Reason: You're speaking plain HTTP to an SSL-enabled server port. Instead use the HTTPS scheme to access this URL, please. -- $url = 'https://domain.net'; Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known -- $url = 'ssl://domain.net'; Bad Request Your browser sent a request that this server could not understand. Client sent malformed Host header --- $url = 'tls://domain.net'; Bad Request Your browser sent a request that this server could not understand. Client sent malformed Host header Am I missing the obvious as I cannot thing of any other options ;-(( tia pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: sending attachment by email - can't find a bug?
You need to post some code #are you using phpMailer - makes emails a doddle http://phpmailer.sourceforge.net/ Afan Pasalic wrote: I have a form and once the form is submitted, php code build csv file with entered information and store it on server in temp file. Then send this file as an attachment to me. Code to send an attachment is included in main code. The code to store csv file works fine. I'm getting the attachment in email but can't open the file: Alert: Unable to read the file. Then I tried to create txt file and got the same result. Actually, I was able to open attached file but the file was empty?!? Then accidentally, I changed the code back to create csv file but didn't change in code to send an attachment. after submitting the csv file was created but got by email earlier created txt file - and it works fine. I was able to open it?!? My conclusion: I can't send just created file, but later, as a second process - it works just fine. And that means, code to send an attachment works as well. Any ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with html through php
In message [EMAIL PROTECTED], Raditha Dissanayake [EMAIL PROTECTED] writes Todd Alexander wrote: Hello all, I am a complete newbie to php so apologies for what I'm sure is a simple/dumb question. I want to use php to include another html doc in an existing set of documents. In other words 123.html will use php to call on abc.html so I can make changes to abc.html and have it update on all my pages. You have struck upon a pretty standard technique you will need to look at the include() or require() functions to persue this further. There is a subtle difference between the two but when you are getting started the difference does not really matter all that much. On most webservers you will need to name your 123 file not as 123.html but as 123.php or 123.phtml abc.html can continue to be abc.html Again I realize this is a complete newbie question but I appreciate any help you have. Todd A further point (since you are newbie G) is to remember that abc.html will not normally be a complete page on it's own - it will only have the parts of the final page that you actually want to include, not all the HEAD... BODY stuff... -- Pete Clark http://www.hotcosta.com http://www.spanishholidaybookings.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Unsetting vars when not needed?
Unsetting class objects does take time and is really of no benefit unless there are memory problems as for freeing resuslts - the same applies pete Jordi Canals wrote: Hi all, I was working now in a new site developed with PHP 5.0.2 and a wonder came to me: Is usefull and recommended to unset a class instance when not needed? Specially when the class was instantiated inside a function and the function ends. In this case, the system should automatically destroy the instance (as it is a local var inside a function). If we manually unset the instance at the end of the function, does this affect the PHP performance? I mean, will PHP have to do an extra job unsetting the var? Also, the same question arises with database results. Is it worth to call mysql_free_result at the end of a function that uses it? Must take into consideration that there are lots of functions that use lots of MySQL results. Thanks for any comment Jordi. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Current URL?
$_SERVER['REQUEST_URI']; Matthew Weier O'Phinney wrote: * Jason Paschal [EMAIL PROTECTED]: Trying to get the current viewed page's URL (query string intact). this works, but infrequently: $url = $_SERVER['URI']; and this ignores the query string: $url = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; I'm certain there's a way, that is browser-independent, to get your script to grab the current URL (even if the script is an include). i'm just trying to get a log of users currently online, and which page they are viewing, and while the $_SERVER['REMOTE_ADDR'] will invariably grab the IP, $_SERVER['URI'] is often empty. Try: $url = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with mail function
I have a problem with a standard mail() function. If I put a short message ( test ) into it, then the email is sent. If I put a longer message in (Visitors name and address collected from webpage), then the mail is not sent. No error message is generated, the mail just doesn't arrive. The client has PHP Version 4.3.1 on Windows NT localhost 5.2 build 3790 -- Pete Clark http://www.hotcosta.com http://www.spanishholidaybookings.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php sessions question
In message [EMAIL PROTECTED], raditha dissanayake [EMAIL PROTECTED] writes Reinhart Viane wrote: in a page checkuser i do this after the user is logged in: PHP Code // Register some session variables! session_register('userid'); $_SESSION['userid'] = $userid; session_register('first_name'); $_SESSION['first_name'] = $first_name; session_register('last_name'); $_SESSION['last_name'] = $last_name; session_register('email_address'); $_SESSION['email_address'] = $email_address; session_register('user_level'); $_SESSION['user_level'] = $user_level; You should only save the userId in the session, everything else should be retrieved from your database using that id. I normally do as you have suggested here - but why do you suggest that this method is better? -- Pete Clark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Send variable in include()
I'm trying to send a variable an include that is recieve from another page: - navi.php- a href =\'http://www.example.com/view.php?offset=0\;Test/a - view.php - I recieve $offset with avalue of 0 nicely, echo ($offset); will show a value. Now a do this: include 'http://www.example.com/guestbook.php?option=viewoffset=$offset'; - guestbook.php - $offset gets value $offset instead of 0 $option has correct value, view How do I write my include so it works? Would appriciate som help. Regards, Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mod-rewrite
I have just started using mod-rewrite, and have two questions... I see everywhere on the net that I can change file names to lower case - at present they are an ex-Windows based mess of upper and lower. But I can't see anywhere how to actually do it, just that it is possible. Also, I use RewriteRule ^comm/(.*).php /comm.php?C=$1 to change comm.php?C=abc to a more search engine friendly comm/abc.php. But this leaves gives the effect of being in a different folder, and relative URLS within that page no longer work correctly. Is there a Clever Fix? Or do I have to change to absolute URLS? And if absolute is absolutely necessary, should I include the domain name? -- Pete Clark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mod-rewrite
Wow - this is *really* spooky! When I wrote that, with RewriteRule relative URLS within that page no longer work correctly, I had not realised that those within PHP worked ok, whereas those in raw HTML didn't... -- Pete Clark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Knowledgebase/Troubleshooter
goto sourceforge.net there's tons of stuff there.. No need to reinvent the wheel ;-))) pete Lee Standen wrote: Hi Guys, I was wondering if anyone knows of a project for creating a troubleshooting wizard, much like in the Microsoft help. I've managed to make something which kind of works myself, but the problem is writing an interface to add/remove/add/manage the questions and steps. Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Generating MySQL Tables
Is MySQL off topic for this list? If so, I apologise. I am supplied with various text (CSV, etc) data files, which I need to manually massage before I import into the main database. I feel that I can deal with them better by turning them into SQL tables first. I know about LOAD DATA INFILE, but this requires a table to exist, and I don't know the format of the table until I receive the text file. Is there any simple way of automatically creating a table and then importing the data? If not, I think that I will have to create a dummy table, with, say, 50 blob fields (some text fields are 'a paragraph full'), and work from there. Of course, it doesn't need to be fast to run. -- Pete Clark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Setcookie doenn't work
I've got this function in a class object, however the cookie does not set even though £ok returns true !!! I've got cookies enables on all my borswers (firefox, mozilla, opera , IE).. any ideas !! function updateClient($arr){ extract($arr); //print_r($arr); $sql = update clients set name= '$name',pos = '$pos',company= '$company', address='$address',postcode ='$postcode',email='$email',tel='$tel',affiliate=$affiliate,aff_stat_id = $aff_stat_id , date_updated = now() , ip='$ip' where client_id = $client_id ; $this-query($sql); $ok = setcookie(client_id, argh, 259300); //* expire in a month ish //echo $sql.=$client_id.=$ok; $_SESSION['client'] = $this-getClient($client_id); return $client_id; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Setcookie doenn't work
doh!! ta ;-) S ilvio Porcellana wrote: $ok = setcookie(client_id, argh, 259300); //* expire in a month ish Nope, it expired a long time ago... :-) Read the manual for setcookie: http://php.libero.it/manual/en/function.setcookie.php (mainly the part about the expire parameter) HTH, cheers Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Assign null value using php
T Umashankari wrote: Hello, Can any one tell me how to assign a null value to a php string?. I tried assigning empty single quote,backslash with zero,double quotes also. but nothing works.. Regards, Uma $str = NULL; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Error message
Hi List, I am getting a strange error notice for the following config file: ?php /** * Database */ $dsn = array( 'phptype' = 'mysql', 'username' = 'root', 'password' = 'secretpass', 'hostspec' = 'localhost', 'database' = 'mydb', ); $options = array( 'debug' = 2, 'portability' = DB_PORTABILITY_ALL, ); /** * Language options */ $languages = array('de', 'en', 'it', 'fr', 'es', 'el', 'nl'); ? Notice: Use of undefined constant DB_PORTABILITY_ALL - assumed 'DB_PORTABILITY_ALL' in D:\utf8php5\config.php on line 16 What can I do about this? Thank you very much.
[PHP] Re: SQL Functions
This might be slightly off the topic but I would recommend you use a database abstraction layer which will do what you want to achieve Check out Pear DB http://pear.php.net/manual/en/package.database.db.php and adodb http://adodb.sourceforge.net/ pete Dan Joseph wrote: Hi Everyone, I'm trying to build a class to handle various SQL functions. One of them is to take a query, and return all rows. Here's what I have so far: function selectRows( $sql ) { $count = 0; $results = mysql_query( $sql, DB::connect() ); $data = mysql_fetch_array( $results ); return $data; } Right now it only returns 1 row. I'm guessing this is how it should be, considering I haven't looped thru any other rows. What I want to do is return something that holds all the rows, however, I cannot see a decent way of doing this. I've played with putting it into a new array, but I can't decide if that's the best way to do it. Wondering if I could get some opinions on how you all would handle this? -Dan Joseph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: sessions not working when page redirects
u need to start the session at the top of each page sesion_start(); Angelo Zanetti wrote: Hi all, Im having a slightly weird problem with my session variables. when on a certain page call it A, I register a session variable and assign it a value. I then test if it is registered successfully and has the correct value on the same page, that works no problem. After that page A redirects to page B: header(Location: ../admin/include/B.php); After this I do the exact same test on page B to test for successful registration and value and I get that the session variable is not registered. on page B I do have session_start(); at the top. I even do 2 tests to on the session variable: if (session_is_registered(myvar)) and if (isset($_SESSION[myvar])) and they both tell me that the session variable is not registered. what could be causing the sesssion variable not to be remembered from page to page. I am using register_globals=on; any ideas/comments? Thanks Angelo Disclaimer This e-mail transmission contains confidential information, which is the property of the sender. The information in this e-mail or attachments thereto is intended for the attention and use only of the addressee. Should you have received this e-mail in error, please delete and destroy it and any attachments thereto immediately. Under no circumstances will the Cape Technikon or the sender of this e-mail be liable to any party for any direct, indirect, special or other consequential damages for any use of this e-mail. For the detailed e-mail disclaimer please refer to http://www.ctech.ac.za/polic or call +27 (0)21 460 3911 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Image and variable
$myimage = 'hi.gif'; echo img src='$myimage'; Henri marc wrote: Hello, I would like to use a variable instead of an image file name in a html page with this instruction: ?php echo 'img src=$myimage'; ? I tried but the image doesn't show up. Is it impossible or do I do something wrong? My goal is to have a random image print in the page, that's why I want to use a variable. Thank you for your good advices. Vous manquez despace pour stocker vos mails ? Yahoo! Mail vous offre GRATUITEMENT 100 Mo ! Crez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/ Le nouveau Yahoo! Messenger est arriv ! Dcouvrez toutes les nouveauts pour dialoguer instantanment avec vos amis. A tlcharger gratuitement sur http://fr.messenger.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] phpmyadmin and UTF
Guten Morgen habe gerade im Apache den Default Zeichensatz auf UTF-8 gesetzt und in der phpmyadmin ebenfalls. In der phpadmin GUI habe ich de-utf-8 ausgewählt. Nun kommt folgende Fehlermeldung von phpmyadmin: Die PHP-Erweiterungen iconv und recode, welche für die Zeichensatzkonvertierung benötigt werden, konnten nicht geladen werden. Bitte ändern Sie Ihre PHP-Konfiguration und aktivieren Sie diese Erweiterungen oder deaktivieren Sie die Zeichensatzkonvertierung in phpMyAdmin. Wie kann man das beheben ? Danke
[PHP] Re: phpmyadmin and UTF
Sorry, here is the English version: I have just set the Apache Default Char Set to UTF-8. Same thing in the phpmyadmin config file. I chose de-utf-8 in the phpmyadmin GUI. When I try to look at a particular database the following error comes up. Can not load iconv or recode extension needed for charset conversion, configure php to allow using these extensions or disable charset conversion in phpMyAdmin. How can that be fixed ? Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mod_rewrite
Know this is off topic bu can anyone help with a tuotial of something - been looking everywhere All I want is a rule to rewrite www.example.com?page=mypageid=20this=that to www.example.com/mypage/20/this tia Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Best external app from php
I had a similar scenario recently the way I tackled the problem was to set a cron to trigger a cli script every minute the script first checked a database to see if there was any jobs queued then processed in the background works a treat pete C.F. Scheidecker Antunes wrote: Hello all, I need to have a web application to call an external app that needs to execute on the background. (It is an *NIX server) The app that is being called will do a lenghty work but will be called by a php script through the web server. An user will log in, request a computation, the script will call an external app which will run on the background. Once the job is completed, a notification will be sent to the user which will log in again and check the results. The external app performs a data mining computation on the SQL server to produce results which will then be written to an SQL table. My question is this: Is it better to write the external app in PHP or Java? If I write in PHP then I have to have a way to make the PHP not bound to time limitations as the operation might take a while. If I write it in Java I won't have this concern. However, I am concerned with speed and overhead. Which one would put a higher load to the processor, a PHP app or a Java one? Which one will take longer? Also, there might be more than 20 of these threads running on the server at the same time, hence my concern on which language the app should be writen. Does anyone has experience with such a scenario? The input is much apreciated. Thanks in advance, C.F. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php