Re: [PHP] Poll of sorts: Javascript Form validation or PHP
On Sun, 2008-12-07 at 17:36 +1030, Michael Kubler wrote: I agree with Nathan. Always do server side validation, and if you have the skills, time, or are being paid then add javascript validation to make the user experience better. I have a general contact form which checks the input server side (PHP) and if there's something wrong then it indicates as such, and shows the user their input, with the errors and why (e.g not a valid email address, etc..). If it was for anything larger than about 10 fields per page, then javascript validation can be useful. Slightly off topic, but does anyone know of an easy way of checking user input like the PHP filter_var() function? I've seen plenty of libraries for AJAX, and the like (Prototype, jquery, etc), but haven't run across any for standard form input validation. Thanks. Michael Kubler* * http://www.greyphoenix.biz Nathan Rixham wrote: where as I think validation always needs to happen at the server side; each application or script should be self contained, it needs to check that the data it recieves is valid before working with it; if it is not valid it needs to inform the system that sent it the data is not valid. The system that sent it in this case is the html output; so you need a method of displaying errors in the html. That is the bare minimum and always needed. As for making the experience nicer; javascript is good for this; it can be used to pre-validate input on the way in to the system; but should not be relied upon as it can be turned off, stop functioning due to another faulty javascript on the page or simply not be supported by the client. You still need the server side validation though. So.. more of a case of always validate server side; and should / do you want to use javascript validation in addition. IMHO :p I put a small one together using regular expressions, http://www.ashleysheridan.co.uk/coding_php_validation.php I tend to use it for all my projects where I need to validate the user input. It uses a whitelist-style approach rather than a blacklist style (i.e. it has an allowable entry format rather than checking to see if certain characters don't exist in it) which has had the added benefit of preventing an SQL injection attack that I've seen as well. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
I put a small one together using regular expressions, http://www.ashleysheridan.co.uk/coding_php_validation.php So we are regexing emails again? #OUT OF coding_php_validation.php COPY case 'email': { $expression = /^([a-z0-9_\-\.]+)@([a-z0-9_\-\.]+)\.([a-z]{2,5})$/i; $errorText = The email does not appear to be a valid type.; break; } #END COPY What should be valid email addresses according to RFC 2822 [1]: !#$%*+-/=?^_`{|[EMAIL PROTECTED] @@example.com Not valid email addresses: \@example.com @@example.com - [EMAIL PROTECTED] Valid email addresses according to the Multipurpose Internet Mail Extension (MIME) [2]: [EMAIL PROTECTED] Ã(c)@℞.com
[PHP] array_reverse() and garbage collection
Hi,] So I've been thinking, because occassionally I do, about array_reverse() and how to implement it. Of course, it's entirely theoretical, because it would a total waste of time. But I'm wondering which of two methods would be best. 1. Do it correctly and in place. ie, loop through the the first half of the array once swapping element 0 with the end one, element 1 with the next to last one and so on. 2. Loop thru the array once creating a new one. Normally this would take up a little more memory because you end up with two copies of the array in memory just before the end of the function. But what if you set the original element to null once you've assigned it to the new array? The most memory I can see it using is two copies of one element. But only if garbage collection kicks in before you start on the next element. Does garbage collection kick in that often? From what I remember from an article by Derick Rethans, if the refcount is zero, then it gets cleaned up. Cheers. -- Richard Heyes HTML5 Graphing for FF, Chrome, Opera and Safari: http://www.rgraph.org (Updated December 5th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array_reverse() and garbage collection
What about using array_pop to take the bottom array element from the first one and add it to the second? So basically you are feeding the 2nd array from the bottom of the 1st one, and assuming garbage collection is done for each call of array_pop, then you'd only need the memory usage of one copy of the array, not two. The downside is that it's not going to be as fast as just looping through, and making two copies, but the upside is less memory usage. I can see it being particularly useful for processing large arrays on memory restricted webservers which would possibly not have the ram for two copies of the array in memory at the same time. Not sure if that actually helps, seeing as array_reverse() is already a function that's probably written in C which could just make a copy with re-arrange the pointers or something. Michael Kubler *G*rey *P*hoenix *P*roductions http://www.greyphoenix.biz Richard Heyes wrote: Hi, So I've been thinking, because occassionally I do, about array_reverse() and how to implement it. Of course, it's entirely theoretical, because it would a total waste of time. But I'm wondering which of two methods would be best. 1. Do it correctly and in place. ie, loop through the the first half of the array once swapping element 0 with the end one, element 1 with the next to last one and so on. 2. Loop thru the array once creating a new one. Normally this would take up a little more memory because you end up with two copies of the array in memory just before the end of the function. But what if you set the original element to null once you've assigned it to the new array? The most memory I can see it using is two copies of one element. But only if garbage collection kicks in before you start on the next element. Does garbage collection kick in that often? From what I remember from an article by Derick Rethans, if the refcount is zero, then it gets cleaned up. Cheers.
[PHP] Re: PEAR Help
Jason Todd Slack-Moehrle wrote: How I need to install OLE and Spreadsheet_Excel_Writer and I dont see how pear install . fails every time with channel errors and not found errors. I have downloaded the .tgz files, but I dont know where to put the contents. You can install them by using local filename instead of the package name, e.g.: pear install OLE.tgz Regards, Mark -- http://www.markwiesemann.eu -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
On Sun, 2008-12-07 at 02:27 -0800, Yeti wrote: I put a small one together using regular expressions, http://www.ashleysheridan.co.uk/coding_php_validation.php So we are regexing emails again? #OUT OF coding_php_validation.php COPY case 'email': { $expression = /^([a-z0-9_\-\.]+)@([a-z0-9_\-\.]+)\.([a-z]{2,5})$/i; $errorText = The email does not appear to be a valid type.; break; } #END COPY What should be valid email addresses according to RFC 2822 [1]: !#$%*+-/=?^_`{|[EMAIL PROTECTED] @@example.com Not valid email addresses: \@example.com @@example.com - [EMAIL PROTECTED] Valid email addresses according to the Multipurpose Internet Mail Extension (MIME) [2]: [EMAIL PROTECTED] Ã(c)@℞.com Yes, I know I'm going to hell, but it serves well for most purposes. In the future when I actually see people use those kind of email addresses then I'll update it. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
Ashley Sheridan wrote: On Sun, 2008-12-07 at 02:27 -0800, Yeti wrote: I put a small one together using regular expressions, http://www.ashleysheridan.co.uk/coding_php_validation.php So we are regexing emails again? #OUT OF coding_php_validation.php COPY case 'email': { $expression = /^([a-z0-9_\-\.]+)@([a-z0-9_\-\.]+)\.([a-z]{2,5})$/i; $errorText = The email does not appear to be a valid type.; break; } #END COPY What should be valid email addresses according to RFC 2822 [1]: !#$%*+-/=?^_`{|[EMAIL PROTECTED] @@example.com Not valid email addresses: \@example.com @@example.com - [EMAIL PROTECTED] Valid email addresses according to the Multipurpose Internet Mail Extension (MIME) [2]: [EMAIL PROTECTED] Ã(c)@℞.com Yes, I know I'm going to hell, but it serves well for most purposes. In the future when I actually see people use those kind of email addresses then I'll update it. Ash www.ashleysheridan.co.uk basically if it has 1 or more printable chars followed by an @ followed by 1 - 63 printable chars followed by a period followed by a valid domain extension it's good; that's simple regex :p -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
/** Validate an email address. Provide email address (raw input) Returns true if the email address has the email address format and the domain exists. Not following the usual coding style I know but I can't bring myself to touch it... You'd better not touch it either, Rob: That means you. Author: Humblehope Modified: 06/06/2007 **/ function validEmail($email) { $isValid = true; $atIndex = strrpos($email, @); if (is_bool($atIndex) !$atIndex) { $isValid = false; } else { $domain = substr($email, $atIndex+1); $local = substr($email, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen 1 || $localLen 64) { // local part length exceeded $isValid = false; } else if ($domainLen 1 || $domainLen 255) { // domain part length exceeded $isValid = false; } else if ($local[0] == '.' || $local[$localLen-1] == '.') { // local part starts or ends with '.' $isValid = false; } else if (preg_match('/\\.\\./', $local)) { // local part has two consecutive dots $isValid = false; } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { // character not valid in domain part $isValid = false; } else if (preg_match('/\\.\\./', $domain)) { // domain part has two consecutive dots $isValid = false; } else if (!preg_match('/^(.|[A-Za-z0-9!#%`_=\\/$\'*+?^{}|~.-])+$/', str_replace(,,$local))) { // character not valid in local part unless // local part is quoted if (!preg_match('/^(|[^])+$/', str_replace(,,$local))) { $isValid = false; } } if ($isValid !(checkdnsrr($domain,MX) || checkdnsrr($domain,A))) { // domain not found in DNS $isValid = false; } } return $isValid; } On Sun, 7 Dec 2008, Nathan Rixham wrote: Ashley Sheridan wrote: On Sun, 2008-12-07 at 02:27 -0800, Yeti wrote: I put a small one together using regular expressions, http://www.ashleysheridan.co.uk/coding_php_validation.php So we are regexing emails again? #OUT OF coding_php_validation.php COPY case 'email': { $expression = /^([a-z0-9_\-\.]+)@([a-z0-9_\-\.]+)\.([a-z]{2,5})$/i; $errorText = The email does not appear to be a valid type.; break; } #END COPY What should be valid email addresses according to RFC 2822 [1]: !#$%*+-/=?^_`{|[EMAIL PROTECTED] @@example.com Not valid email addresses: \@example.com @@example.com - [EMAIL PROTECTED] Valid email addresses according to the Multipurpose Internet Mail Extension (MIME) [2]: [EMAIL PROTECTED] Ã(c)@℞.com Yes, I know I'm going to hell, but it serves well for most purposes. In the future when I actually see people use those kind of email addresses then I'll update it. Ash www.ashleysheridan.co.uk basically if it has 1 or more printable chars followed by an @ followed by 1 - 63 printable chars followed by a period followed by a valid domain extension it's good; that's simple regex :p -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Curl with asp pages....
On Sun, Dec 7, 2008 at 8:22 AM, ioannes [EMAIL PROTECTED] wrote: shiplu wrote: When you are dealing with curl, anything can be done as long as its a HTTP request.Its all about sending HTTP headers and content. To parse HTML content you can use HTML parser. Regular expression may not work each time. Pattern changes over time. Download Wireshark. Collect 2 sample request and response packet from there. Make a format and use it with CURL. Thats it. So Simple. You never gonna need to know who is generating the site, PHP or ASP.NET. I downloaded Wireshark onto Windows XP, got as far as Capture Options from Ethernet, Capture Filter is host IP address of target page, click Start, go to browser and access page, Stop Wireshark, Save captured file or Export as HTTP object which gives me the source of the page again. Is this what you mean? What do you mean by make a format - do you mean for instance parse the page with string finder functions etc. How is this helping over identifying the correct POST variables (using LiveHTTP etc) of the request and feeding into a curl function? What do you mean by 'make a format' versus 'pattern changes over time' - is format a Wireshark function, if so where do I find it. Thanks, John make a format is not like a button in wireshirk that has label make a format and it will do everything for you. You have to do it yourself. By wireshirk you'll see every type of headers and contents for almost every type of protocols. So you'll use this soft for analyzing the http conversation. Data will not only be in content but also in headers. so parse both if needed. then use the same data and make successive requests. If you are using regular expression it will fail to match if pattern changes. Your pattern '/input type=hidden name=__VIEWSTATE id=__VIEWSTATE value=([^]*?) \// will match input type=hidden name=__VIEWSTATE id=__VIEWSTATE value=ABC7D5ACSE / but wont match input type=hidden name=__VIEWSTATE id=__VIEWSTATE value=ABC7D5ACSE. Do you see the difference?? It wont mach input type=hidden id=__VIEWSTATE name=__VIEWSTATE value=ABC7D5ACSE / too. Because the attributes order is changed. Your regex will not work but their website will render very well. to overcome this, you have to use html/xml parser. So you can go to input element. then look for name attribute and if the name attribute is __VIEWSTATE then fetch the value attributes content. To make any input element name, value attribute must be present. So your code will match every time. It wont fail in 99.99% case. Hope that make sense -- A K M Mokaddim http://talk.cmyweb.net http://twitter.com/shiplu Stop Top Posting !! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] A MySQL Question
Hi gang: I just interviewed for a job teaching at the local college (imagine me taking minds of mush and molding them to the world according to tedd -- frightening huh?) In any event, the interviewer asked me how long I've been using MySQL and I replied several years. After which she asked a single question, which was What does EXIST mean? Now without running to the manuals, please be honest and tell me how many of you know off the top of your head what EXIST means? I would be curious to know. I answered the question correctly, (I'm one of those weird types who read manuals for fun) but I have never used EXIST in a query. Have any of you? And while we're on the subject of MySQL -- while we all know how to write it, how do you say it? I've read that the common way is to say My Squell, or something like that. But I always sounded out each letter, such as My S-Q-L. The interviewer pronounced it the same as I, but I have heard others say it differently. What say you? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
I believe I've seen EXIST used when creating backups of tables to test for the existence of a table and DROP it if it exists (if you select the option to add such code in phpMyAdmin). So that would have been my answer (give or take more specific wording for an interview). As for pronounciation... I used to say S-Q-L for all such references and still use it when talking about the language most of the time, but some of my coworkers sequel has rubbed off on me, especially with MySQL. I used to cringe heartily at such wordification of acronyms that didn't actually spell a word, or something similar that at least contained some vowels, but it's kind of nice to reduce a mouthful a little bit. I've never heard squell, though. Not sure I like that very much. -TG - Original Message - From: tedd [EMAIL PROTECTED] To: PHP General Mailing List php-general@lists.php.net Date: Sun, 7 Dec 2008 10:03:26 -0500 Subject: [PHP] A MySQL Question Hi gang: I just interviewed for a job teaching at the local college (imagine me taking minds of mush and molding them to the world according to tedd -- frightening huh?) In any event, the interviewer asked me how long I've been using MySQL and I replied several years. After which she asked a single question, which was What does EXIST mean? Now without running to the manuals, please be honest and tell me how many of you know off the top of your head what EXIST means? I would be curious to know. I answered the question correctly, (I'm one of those weird types who read manuals for fun) but I have never used EXIST in a query. Have any of you? And while we're on the subject of MySQL -- while we all know how to write it, how do you say it? I've read that the common way is to say My Squell, or something like that. But I always sounded out each letter, such as My S-Q-L. The interviewer pronounced it the same as I, but I have heard others say it differently. What say you? Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: A MySQL Question
tedd wrote: Hi gang: I just interviewed for a job teaching at the local college (imagine me taking minds of mush and molding them to the world according to tedd -- frightening huh?) In any event, the interviewer asked me how long I've been using MySQL and I replied several years. After which she asked a single question, which was What does EXIST mean? Now without running to the manuals, please be honest and tell me how many of you know off the top of your head what EXIST means? I would be curious to know. I answered the question correctly, (I'm one of those weird types who read manuals for fun) but I have never used EXIST in a query. Have any of you? I knew it existed but have never felt the need to use it; and upon refreshing my knowledge from the manual can safely say I'll continue not to use it. On the same not does anybody else frequently use (or even know about) the awesome spatial extension for mysql? or use the information_schema tables? And while we're on the subject of MySQL -- while we all know how to write it, how do you say it? I've read that the common way is to say My Squell, or something like that. But I always sounded out each letter, such as My S-Q-L. The interviewer pronounced it the same as I, but I have heard others say it differently. What say you? I'm in the My-S-Q-L boat as well; also Post-gres and S-Q-L Server for ms.. none of this sequele malarky -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
On Sun, Dec 7, 2008 at 10:03 AM, tedd [EMAIL PROTECTED] wrote: Hi gang: I just interviewed for a job teaching at the local college (imagine me taking minds of mush and molding them to the world according to tedd -- frightening huh?) In any event, the interviewer asked me how long I've been using MySQL and I replied several years. After which she asked a single question, which was What does EXIST mean? Now without running to the manuals, please be honest and tell me how many of you know off the top of your head what EXIST means? I would be curious to know. I answered the question correctly, (I'm one of those weird types who read manuals for fun) but I have never used EXIST in a query. Have any of you? And while we're on the subject of MySQL -- while we all know how to write it, how do you say it? I've read that the common way is to say My Squell, or something like that. But I always sounded out each letter, such as My S-Q-L. The interviewer pronounced it the same as I, but I have heard others say it differently. What say you? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Sounds like someone thinks they're pretty clever. I'll never understand why interviewers want to ask really odd edge case questions instead of ones that really show practical knowledge. I know that I don't know the syntax to everything. What I do know is where to find it in seconds if I need it. There's better ways of weeding out resume fibbers. :) I've never actually used EXIST before, but maybe now that I've looked at it I'll find a use. I'm more used to using joins, but this might be a little more readable in cases. On their site I saw once they said they call it My-S-Q-L, but the other way works too. I prefer My-SQL. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
Nathan Rixham wrote: Valid email addresses according to the Multipurpose Internet Mail Extension (MIME) [2]: [EMAIL PROTECTED] Ã(c)@℞.com Uh, no, those aren't valid email address according to any standard. You cannot have 8bit characters to the left of the @ in the email address. The same really goes for the same on the right hand side of the @, but some people have difficulties distinguishing between the _actual_ email address and it may be rendered when the domain part is converted from punycode. The actual email address might be [EMAIL PROTECTED] which mail-agents with IDN support should display and accept like this: [EMAIL PROTECTED] /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
Per Jessen wrote: address. The same really goes for the same on the right hand side of the @, but some people have difficulties distinguishing between the _actual_ email address and it may be rendered when the domain part is converted from punycode. That should have read and THE WAY it may be rendered when the domain part is converted from punycode. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
At 1:59 PM + 12/7/08, Luke Slater wrote: /** Validate an email address. Provide email address (raw input) Returns true if the email address has the email address format and the domain exists. Not following the usual coding style I know but I can't bring myself to touch it... You'd better not touch it either, Rob: That means you. Author: Humblehope Modified: 06/06/2007 **/ -snip- I'm impressed. The php routine passed [EMAIL PROTECTED] (which is real), but failed [EMAIL PROTECTED] (which is not real). What's needed is a javascript routine to do the same thing, but it would require a trip to the server to check the domain. As such, I would use AJAX to trigger this php routine to provide validation -- that might prove interesting, huh? Apparent real-time validation -- hmmm, I'm going to think about that. The php routine also passed [EMAIL PROTECTED], which is real -- but it's interesting that most email (if not all) programs cannot show the domain name correctly, which is [EMAIL PROTECTED] I have yet to find an email program that can show IDNS correctly. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
Well to reproduce most of that would perhaps be fairly easy, most of it is regex stuff. There may be trouble with the checkdnsrr() stuff though, which is for checking that the domain exists. I wouldn't imagine there would be anything like that for JS... Perhaps there is... You could always do an AJAX request :) On Sun, 7 Dec 2008, tedd wrote: At 1:59 PM + 12/7/08, Luke Slater wrote: /** Validate an email address. Provide email address (raw input) Returns true if the email address has the email address format and the domain exists. Not following the usual coding style I know but I can't bring myself to touch it... You'd better not touch it either, Rob: That means you. Author: Humblehope Modified: 06/06/2007 **/ -snip- I'm impressed. The php routine passed [EMAIL PROTECTED] (which is real), but failed [EMAIL PROTECTED] (which is not real). What's needed is a javascript routine to do the same thing, but it would require a trip to the server to check the domain. As such, I would use AJAX to trigger this php routine to provide validation -- that might prove interesting, huh? Apparent real-time validation -- hmmm, I'm going to think about that. The php routine also passed [EMAIL PROTECTED], which is real -- but it's interesting that most email (if not all) programs cannot show the domain name correctly, which is [EMAIL PROTECTED] I have yet to find an email program that can show IDNS correctly. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: A MySQL Question
At 3:24 PM + 12/7/08, Nathan Rixham wrote: On the same not does anybody else frequently use (or even know about) the awesome spatial extension for mysql? or use the information_schema tables? I've certainly never used them, but I can imagine information_schema tables that are similar to DOCTYPE as found in xml for defining fields -- is that it? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Refresh (F5) adds another SQL record.
I've found a way that works for me. Using the START SESSION on the initial form, e.g. ?php session_start(); // store session data $_SESSION['form'] = 1; ? and the using the code below in the processing form. You can do a check if the user has already submitted the from by the initial session that starts then he/she is on the submitting form. If it is already set it can continue, else stop and redirect. MAKE SURE to put the unset session at the end of the form. html head titleAdd Publication/title /head body h1Add/h1 ?php // Check session session_start(); if ($_SESSION['form'] == 1) { // create short variable names $producttype=$_POST['producttype']; $producttitle=$_POST['producttitle']; $productdescription=$_POST['productdescription']; $productauthor=$_POST['productauthor']; $productlang=$_POST['productlang']; $productprice=$_POST['productprice']; $productstatus=$_POST['productstatus']; $productimg=$_POST['productimg']; } else { echo 'Go back and complete the form'; echo header('Location: insertpublication.php'); exit; } // End session checking if (!$producttype || !$producttitle || !$productauthor || !$productlang || !$productprice || !$productstatus) { echo 'You have not entered all the required details.br /' .'Please go back and try again.'; unset($_SESSION['form']); exit; } @ $prodb = new mysqli('I DONT THINK SO!!!'); if (mysqli_connect_errno()) { echo 'Error: Could not connect to database. Please try again later.'; exit; } $query = INSERT into tblproductinfo (ProductType, ProductTitle, ProductDesc, ProdAuthor, ProductLang, ProductPrice, ProductStatus, ProductImg) VALUES ('.$producttype.', '.$producttitle.', '.$productdescription.', '.$productauthor.', '.$productlang.', '.$productprice.', '.$productstatus.', '.$productimg.'); $result = $prodb-query($query); if ($result) echo $prodb-affected_rows.' book inserted into database.'; $queryshow = SELECT tblproductinfo.ProductID, tblproductinfo.ProductTitle, tblproductinfo.ProductDesc, tblproductinfo.ProductPrice, tblproductinfo.ProductTQty, tblproductinfo.ProductImg, tblauthor.AuthorName, tblproductlang.ProductLang, tblproducttype.ProductType, tblproductstatus.ProductStatus FROM tblproductinfo Inner Join tblproductstatus ON tblproductinfo.ProductStatus = tblproductstatus.ProductStatusID Inner Join tblproductlang ON tblproductinfo.ProductLang = tblproductlang.ProductLangID Inner Join tblauthor ON tblproductinfo.ProdAuthor = tblauthor.AuthorID Inner Join tblproducttype ON tblproductinfo.ProductType = tblproducttype.ProductTypeID; $resultshow = $prodb-query($queryshow); $num_results = $resultshow-num_rows; echo ' table width=700 border=1 tr td Book ID /td td Type /td td Title /td td Description /td td Author /td td Language /td td Price /td td Status /td td Image /td /tr'; for ($i=0; $i $num_results; $i++) { $row = $resultshow-fetch_assoc(); echo 'tr'; echo 'td'.($row['ProductID']).'/td'; echo 'td'.($row['ProductType']).'/td'; echo 'td'.($row['ProductTitle']).'/td'; echo 'td'.($row['ProductDesc']).'/td'; echo 'td'.($row['AuthorName']).'/td'; echo 'td'.($row['ProductLang']).'/td'; echo 'td£'.($row['ProductPrice']).'/td'; echo 'td'.($row['ProductStatus']).'/td'; echo 'tda href=images/'.($row['ProductImg']).'Preview image /a/td'; echo '/tr'; }; echo '/table'; unset($_SESSION['form']); $prodb-close(); ? /body /html
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
At 5:10 PM +0100 12/7/08, Per Jessen wrote: You cannot have 8bit characters to the left of the @ in the email address. I'm not sure that's correct. I distinctly remember Paul Hoffman, the director of the Internet Mail Consortium (http://www.imc.org/) saying that the left side of the @ has always been open to whatever characters you want to use. I was attending the IDNS WG as they created PUNYCODE when he made that statement. Now maybe you can use anything you want, but it doesn't mean that it will be translated correctly. The same really goes for the same on the right hand side of the @, but some people have difficulties distinguishing between the _actual_ email address and it may be rendered when the domain part is converted from punycode. The actual email address might be [EMAIL PROTECTED] That's correct. The xn-- is the prefix for PUNYCODE. Previous algorithms (AMC, RACE, etc.) used other prefixes. After all is said and done, these were just ways to use 7 bit characters (unfortunately, the default for the Internet) to assemble/represent 8 bit characters. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
On Sun, 2008-12-07 at 13:59 +, Luke Slater wrote: /** Validate an email address. Provide email address (raw input) Returns true if the email address has the email address format and the domain exists. Not following the usual coding style I know but I can't bring myself to touch it... You'd better not touch it either, Rob: That means you. Presumably you mean me... I must have developed a reputation amongst the lurkers ;) Cheers, Rob. Ps... return $isValid; This line isn't indented properly :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
On Sun, 2008-12-07 at 10:03 -0500, tedd wrote: Hi gang: I just interviewed for a job teaching at the local college (imagine me taking minds of mush and molding them to the world according to tedd -- frightening huh?) In any event, the interviewer asked me how long I've been using MySQL and I replied several years. After which she asked a single question, which was What does EXIST mean? Not sure about EXIST, but definitely see EXISTS when creating table dumps. DROP TABLE IF EXISTS foo; I usually do dumps via command-line so to get the DROP TABLE line you add the --add-drop-table flag. Now without running to the manuals, please be honest and tell me how many of you know off the top of your head what EXIST means? I would be curious to know. I answered the question correctly, (I'm one of those weird types who read manuals for fun) but I have never used EXIST in a query. Have any of you? And while we're on the subject of MySQL -- while we all know how to write it, how do you say it? I've read that the common way is to say My Squell, or something like that. But I always sounded out each letter, such as My S-Q-L. The interviewer pronounced it the same as I, but I have heard others say it differently. What say you? I say as you do... My S. Q. L. Although, I recall hearing a long time ago that the My part was named after a person's name and is supposed to be pronounced as Me. People who say My Sequel are confusing the old database language SEQUEL with SQL. While SEQUEL was a precursor to SQL, SQL actually stands for Standard Query Language, and is not a shortening of SEQUEL. Wikipedia states that the official pronunciation is My S. Q. L. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
On Sun, 2008-12-07 at 11:01 -0500, Eric Butera wrote: Sounds like someone thinks they're pretty clever. I'll never understand why interviewers want to ask really odd edge case questions instead of ones that really show practical knowledge. I know that I don't know the syntax to everything. What I do know is where to find it in seconds if I need it. There's better ways of weeding out resume fibbers. :) I've never actually used EXIST before, but maybe now that I've looked at it I'll find a use. Oh you'll find a use alright... on stupid esoteric interview questions :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
Ooh I didn't mean you actually, was taken out of a collab project I'm working on with a.. Not so considerate... Co-worker on there called Rob. Forgot to remove the comment =) Ah yes didn't notice that, sorry for the labourous extra TABs and backspaces I've put you through ;) On Sun, 7 Dec 2008, Robert Cummings wrote: On Sun, 2008-12-07 at 13:59 +, Luke Slater wrote: /** Validate an email address. Provide email address (raw input) Returns true if the email address has the email address format and the domain exists. Not following the usual coding style I know but I can't bring myself to touch it... You'd better not touch it either, Rob: That means you. Presumably you mean me... I must have developed a reputation amongst the lurkers ;) Cheers, Rob. Ps... return $isValid; This line isn't indented properly :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: A MySQL Question
tedd wrote: At 3:24 PM + 12/7/08, Nathan Rixham wrote: On the same not does anybody else frequently use (or even know about) the awesome spatial extension for mysql? or use the information_schema tables? I've certainly never used them, but I can imagine information_schema tables that are similar to DOCTYPE as found in xml for defining fields -- is that it? Cheers, tedd not many have :p but there's so much more power and speed can be opened up by using them.. to get you started ( I highly recommend this ) try: SELECT * FROM `information_schema`.`TABLES`; then: SELECT * FROM `information_schema`.`COLUMNS` then cunning way's to combine the two.. for instance you could query these two tables to return back a list of all columns in database X which are of type text and use them to search you're entire database in one go like: select table_name, column_name from information_schema.columns WHERE table_schema='DB_NAME' AND data_type IN ('char','varchar','text') AND CHARACTER_MAXIMUM_LENGTH 3;select table_name, column_name from information_schema.columns WHERE table_schema='DB_NAME' AND data_type IN ('char','varchar','text') AND CHARACTER_MAXIMUM_LENGTH 3; replace DB_NAME for the database you want to search, you may want to include type's like mediumtext etc.. point is, the information_schema tables reside in memory so are ultra quick to query; and they are always up to date; and they give you far more information than normally available. so many options.. rows in a database (not table) SELECT SUM(TABLE_ROWS) FROM `information_schema`.`TABLES` WHERE TABLE_SCHEMA='DB_NAME'; etc etc.. regards! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
On Sun, 2008-12-07 at 13:59 +, Luke Slater wrote: /** Validate an email address. Provide email address (raw input) Returns true if the email address has the email address format and the domain exists. Not following the usual coding style I know but I can't bring myself to touch it... You'd better not touch it either, Rob: That means you. Presumably you mean me... I must have developed a reputation amongst the lurkers ;) Cheers, Rob. Luke Slater wrote: Ooh I didn't mean you actually that is an absolute classic - gutting rob, gutting [lololol] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
On Sun, Dec 07, 2008 at 10:03:26AM -0500, tedd wrote: Hi gang: I just interviewed for a job teaching at the local college (imagine me taking minds of mush and molding them to the world according to tedd -- frightening huh?) In any event, the interviewer asked me how long I've been using MySQL and I replied several years. After which she asked a single question, which was What does EXIST mean? Now without running to the manuals, please be honest and tell me how many of you know off the top of your head what EXIST means? I would be curious to know. I answered the question correctly, (I'm one of those weird types who read manuals for fun) but I have never used EXIST in a query. Have any of you? Really? What *does* it mean? It's not in the manual index. Perhaps you're confusing it with EXISTS. And while we're on the subject of MySQL -- while we all know how to write it, how do you say it? I've read that the common way is to say My Squell, or something like that. But I always sounded out each letter, such as My S-Q-L. The interviewer pronounced it the same as I, but I have heard others say it differently. My-S-Q-L. Few people realize that 'sequel' was the language used by Ingres for their database and it was different from S-Q-L. -- You are the only one who can use your ability. It is an awesome responsibility. -- Zig Zigler Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
On Sun, 2008-12-07 at 18:01 +, Nathan Rixham wrote: On Sun, 2008-12-07 at 13:59 +, Luke Slater wrote: /** Validate an email address. Provide email address (raw input) Returns true if the email address has the email address format and the domain exists. Not following the usual coding style I know but I can't bring myself to touch it... You'd better not touch it either, Rob: That means you. Presumably you mean me... I must have developed a reputation amongst the lurkers ;) Cheers, Rob. Luke Slater wrote: Ooh I didn't mean you actually that is an absolute classic - gutting rob, gutting [lololol] *haha* Well I thought maybe it was a comment/observation on my occasional somewhat perfectionist tendencies towards code :) Naturally, the world doesn't revolve anywhere close to around me... now the universe, that's another matter ;) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
Well the guy who wrote that piece of code passed away fairly recently =( I bet he's sitting somewhere right now cursing you for pointing out that indentation error though, haha On Sun, 7 Dec 2008, Robert Cummings wrote: On Sun, 2008-12-07 at 18:01 +, Nathan Rixham wrote: On Sun, 2008-12-07 at 13:59 +, Luke Slater wrote: /** Validate an email address. Provide email address (raw input) Returns true if the email address has the email address format and the domain exists. Not following the usual coding style I know but I can't bring myself to touch it... You'd better not touch it either, Rob: That means you. Presumably you mean me... I must have developed a reputation amongst the lurkers ;) Cheers, Rob. Luke Slater wrote: Ooh I didn't mean you actually that is an absolute classic - gutting rob, gutting [lololol] *haha* Well I thought maybe it was a comment/observation on my occasional somewhat perfectionist tendencies towards code :) Naturally, the world doesn't revolve anywhere close to around me... now the universe, that's another matter ;) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
On Sun, 2008-12-07 at 10:03 -0500, tedd wrote: Hi gang: I just interviewed for a job teaching at the local college (imagine me taking minds of mush and molding them to the world according to tedd -- frightening huh?) In any event, the interviewer asked me how long I've been using MySQL and I replied several years. After which she asked a single question, which was What does EXIST mean? Now without running to the manuals, please be honest and tell me how many of you know off the top of your head what EXIST means? I would be curious to know. I answered the question correctly, (I'm one of those weird types who read manuals for fun) but I have never used EXIST in a query. Have any of you? And while we're on the subject of MySQL -- while we all know how to write it, how do you say it? I've read that the common way is to say My Squell, or something like that. But I always sounded out each letter, such as My S-Q-L. The interviewer pronounced it the same as I, but I have heard others say it differently. What say you? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com I've heard several pronunciations, 'sequel', 's.q.l', 'squeal' but I tend to always refer to it as My-S.Q.L, and likewise the M$ version is M.S-S.Q.L, despite M$ insisting it's just SQL running on a product that affectionately like to call simply SQL Server ;) Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
On Sun, 2008-12-07 at 12:38 -0500, Robert Cummings wrote: On Sun, 2008-12-07 at 11:01 -0500, Eric Butera wrote: Sounds like someone thinks they're pretty clever. I'll never understand why interviewers want to ask really odd edge case questions instead of ones that really show practical knowledge. I know that I don't know the syntax to everything. What I do know is where to find it in seconds if I need it. There's better ways of weeding out resume fibbers. :) I've never actually used EXIST before, but maybe now that I've looked at it I'll find a use. Oh you'll find a use alright... on stupid esoteric interview questions :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP I know. I had to take a similar test one time. I actually ended up pointing out the errors in the questions and the fact that one question featured twice with exactly the same wording! Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Refresh (F5) adds another SQL record.
On Sun, 2008-12-07 at 16:44 +, Bhupendra Patel wrote: I've found a way that works for me. Using the START SESSION on the initial form, e.g. ?php session_start(); // store session data $_SESSION['form'] = 1; ? and the using the code below in the processing form. You can do a check if the user has already submitted the from by the initial session that starts then he/she is on the submitting form. If it is already set it can continue, else stop and redirect. MAKE SURE to put the unset session at the end of the form. html head titleAdd Publication/title /head body h1Add/h1 ?php // Check session session_start(); if ($_SESSION['form'] == 1) { // create short variable names $producttype=$_POST['producttype']; $producttitle=$_POST['producttitle']; $productdescription=$_POST['productdescription']; $productauthor=$_POST['productauthor']; $productlang=$_POST['productlang']; $productprice=$_POST['productprice']; $productstatus=$_POST['productstatus']; $productimg=$_POST['productimg']; } else { echo 'Go back and complete the form'; echo header('Location: insertpublication.php'); exit; } // End session checking if (!$producttype || !$producttitle || !$productauthor || !$productlang || !$productprice || !$productstatus) { echo 'You have not entered all the required details.br /' .'Please go back and try again.'; unset($_SESSION['form']); exit; } @ $prodb = new mysqli('I DONT THINK SO!!!'); if (mysqli_connect_errno()) { echo 'Error: Could not connect to database. Please try again later.'; exit; } $query = INSERT into tblproductinfo (ProductType, ProductTitle, ProductDesc, ProdAuthor, ProductLang, ProductPrice, ProductStatus, ProductImg) VALUES ('.$producttype.', '.$producttitle.', '.$productdescription.', '.$productauthor.', '.$productlang.', '.$productprice.', '.$productstatus.', '.$productimg.'); $result = $prodb-query($query); if ($result) echo $prodb-affected_rows.' book inserted into database.'; $queryshow = SELECT tblproductinfo.ProductID, tblproductinfo.ProductTitle, tblproductinfo.ProductDesc, tblproductinfo.ProductPrice, tblproductinfo.ProductTQty, tblproductinfo.ProductImg, tblauthor.AuthorName, tblproductlang.ProductLang, tblproducttype.ProductType, tblproductstatus.ProductStatus FROM tblproductinfo Inner Join tblproductstatus ON tblproductinfo.ProductStatus = tblproductstatus.ProductStatusID Inner Join tblproductlang ON tblproductinfo.ProductLang = tblproductlang.ProductLangID Inner Join tblauthor ON tblproductinfo.ProdAuthor = tblauthor.AuthorID Inner Join tblproducttype ON tblproductinfo.ProductType = tblproducttype.ProductTypeID; $resultshow = $prodb-query($queryshow); $num_results = $resultshow-num_rows; echo ' table width=700 border=1 tr td Book ID /td td Type /td td Title /td td Description /td td Author /td td Language /td td Price /td td Status /td td Image /td /tr'; for ($i=0; $i $num_results; $i++) { $row = $resultshow-fetch_assoc(); echo 'tr'; echo 'td'.($row['ProductID']).'/td'; echo 'td'.($row['ProductType']).'/td'; echo 'td'.($row['ProductTitle']).'/td'; echo 'td'.($row['ProductDesc']).'/td'; echo 'td'.($row['AuthorName']).'/td'; echo 'td'.($row['ProductLang']).'/td'; echo 'td£'.($row['ProductPrice']).'/td'; echo 'td'.($row['ProductStatus']).'/td'; echo 'tda href=images/'.($row['ProductImg']).'Preview image /a/td'; echo '/tr'; }; echo '/table'; unset($_SESSION['form']); $prodb-close(); ? /body /html Would redirecting the user with a header() request do the job? Or, failing that, how about outputting a scriptlocation.href='foo.com'/script line? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
I think hotmail, or was it some other mail mogul, is allowing their users to have those weird German umlauts and some accented characters. EXAMPLE: [EMAIL PROTECTED] We are living in a multilingual world with dozens of alphabets. Especiall those doing government sites should consider accessibility a must. I would not enjoy getting sued by some one who feels discriminated, because of denied access since his/her name contains abnormal characters. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
Yeti wrote: I think hotmail, or was it some other mail mogul, is allowing their users to have those weird German umlauts and some accented characters. EXAMPLE: [EMAIL PROTECTED] Anyone who allows 8-bit characters on the left side of the @ is in for trouble. It won't work. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
On Sun, 2008-12-07 at 20:31 +0100, Per Jessen wrote: Yeti wrote: I think hotmail, or was it some other mail mogul, is allowing their users to have those weird German umlauts and some accented characters. EXAMPLE: [EMAIL PROTECTED] Anyone who allows 8-bit characters on the left side of the @ is in for trouble. It won't work. /Per Jessen, Zürich I doubt it would be hotmail, can you see M$ actually following a standard any more than their definition?! Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
This one time, at band camp, tedd [EMAIL PROTECTED] wrote: In any event, the interviewer asked me how long I've been using MySQL and I replied several years. After which she asked a single question, which was What does EXIST mean? I only ever use it in rollbacks to check if a table exists. Not sure if it has another purpose... I've read that the common way is to say My Squell, or something like that. But I always sounded out each letter, such as My S-Q-L. The interviewer pronounced it the same as I, but I have heard others say it differently. Only a barbarian would call it Sequel or anything other than My S. Q. L MY ESS KEW ELL Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
Ashley Sheridan wrote: On Sun, 2008-12-07 at 20:31 +0100, Per Jessen wrote: Yeti wrote: I think hotmail, or was it some other mail mogul, is allowing their users to have those weird German umlauts and some accented characters. EXAMPLE: [EMAIL PROTECTED] Anyone who allows 8-bit characters on the left side of the @ is in for trouble. It won't work. /Per Jessen, Zürich I doubt it would be hotmail, can you see M$ actually following a standard any more than their definition?! Ash www.ashleysheridan.co.uk on that note, and seeing as it's sunday.. Three male programmers were in the bathroom standing at the urinals. The first programmer finishes, walks over to the sink to wash his hands. He then proceeds to dry his hands very carefully. He uses paper towel after paper towel and ensures that every single spot of water on his hands is dried. Turning to the other two, he says, At Microsoft, we are trained to be extremely thorough. The second programmer finishes his task at the urinal and he proceeds to wash his hands. He uses a single paper towel and makes sure that he dries his hands using every available portion of the paper towel. He turns and says, At Intel not only are we trained to be extremely thorough but we are also trained to be extremely efficient. The third programmer finished and walks straight for the door, shouting over his shoulder, At Sun, we don`t piss on our hands. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
On Sun, 2008-12-07 at 19:54 +, Nathan Rixham wrote: Ashley Sheridan wrote: On Sun, 2008-12-07 at 20:31 +0100, Per Jessen wrote: Yeti wrote: I think hotmail, or was it some other mail mogul, is allowing their users to have those weird German umlauts and some accented characters. EXAMPLE: [EMAIL PROTECTED] Anyone who allows 8-bit characters on the left side of the @ is in for trouble. It won't work. /Per Jessen, Zürich I doubt it would be hotmail, can you see M$ actually following a standard any more than their definition?! Ash www.ashleysheridan.co.uk on that note, and seeing as it's sunday.. Three male programmers were in the bathroom standing at the urinals. The first programmer finishes, walks over to the sink to wash his hands. He then proceeds to dry his hands very carefully. He uses paper towel after paper towel and ensures that every single spot of water on his hands is dried. Turning to the other two, he says, At Microsoft, we are trained to be extremely thorough. The second programmer finishes his task at the urinal and he proceeds to wash his hands. He uses a single paper towel and makes sure that he dries his hands using every available portion of the paper towel. He turns and says, At Intel not only are we trained to be extremely thorough but we are also trained to be extremely efficient. The third programmer finished and walks straight for the door, shouting over his shoulder, At Sun, we don`t piss on our hands. As the Sun guy is shouting over his shoulder, an open-source developer stops beside him and pees on his leg... while saying, open source developers do it however we please. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
On Sun, 2008-12-07 at 15:13 -0500, Robert Cummings wrote: On Sun, 2008-12-07 at 19:54 +, Nathan Rixham wrote: Ashley Sheridan wrote: On Sun, 2008-12-07 at 20:31 +0100, Per Jessen wrote: Yeti wrote: I think hotmail, or was it some other mail mogul, is allowing their users to have those weird German umlauts and some accented characters. EXAMPLE: [EMAIL PROTECTED] Anyone who allows 8-bit characters on the left side of the @ is in for trouble. It won't work. /Per Jessen, Zürich I doubt it would be hotmail, can you see M$ actually following a standard any more than their definition?! Ash www.ashleysheridan.co.uk on that note, and seeing as it's sunday.. Three male programmers were in the bathroom standing at the urinals. The first programmer finishes, walks over to the sink to wash his hands. He then proceeds to dry his hands very carefully. He uses paper towel after paper towel and ensures that every single spot of water on his hands is dried. Turning to the other two, he says, At Microsoft, we are trained to be extremely thorough. The second programmer finishes his task at the urinal and he proceeds to wash his hands. He uses a single paper towel and makes sure that he dries his hands using every available portion of the paper towel. He turns and says, At Intel not only are we trained to be extremely thorough but we are also trained to be extremely efficient. The third programmer finished and walks straight for the door, shouting over his shoulder, At Sun, we don`t piss on our hands. As the Sun guy is shouting over his shoulder, an open-source developer stops beside him and pees on his leg... while saying, open source developers do it however we please. Cheers, Rob. One can only imagine how the Google developers would do it... Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
Ashley Sheridan wrote: On Sun, 2008-12-07 at 15:13 -0500, Robert Cummings wrote: On Sun, 2008-12-07 at 19:54 +, Nathan Rixham wrote: Ashley Sheridan wrote: On Sun, 2008-12-07 at 20:31 +0100, Per Jessen wrote: Yeti wrote: I think hotmail, or was it some other mail mogul, is allowing their users to have those weird German umlauts and some accented characters. EXAMPLE: [EMAIL PROTECTED] Anyone who allows 8-bit characters on the left side of the @ is in for trouble. It won't work. /Per Jessen, Zürich I doubt it would be hotmail, can you see M$ actually following a standard any more than their definition?! Ash www.ashleysheridan.co.uk on that note, and seeing as it's sunday.. Three male programmers were in the bathroom standing at the urinals. The first programmer finishes, walks over to the sink to wash his hands. He then proceeds to dry his hands very carefully. He uses paper towel after paper towel and ensures that every single spot of water on his hands is dried. Turning to the other two, he says, At Microsoft, we are trained to be extremely thorough. The second programmer finishes his task at the urinal and he proceeds to wash his hands. He uses a single paper towel and makes sure that he dries his hands using every available portion of the paper towel. He turns and says, At Intel not only are we trained to be extremely thorough but we are also trained to be extremely efficient. The third programmer finished and walks straight for the door, shouting over his shoulder, At Sun, we don`t piss on our hands. As the Sun guy is shouting over his shoulder, an open-source developer stops beside him and pees on his leg... while saying, open source developers do it however we please. Cheers, Rob. but but but they give us openoffice, mysql, solaris, java, glassfish. jax-ws, virtualbox (which f'n rocks the big one he says replying to this email on a ubuntu server running on a vista ultimate) yet still.. lol One can only imagine how the Google developers would do it... Catheter? (my first thought was pessary but thats soo wrong) Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
On Sun, 2008-12-07 at 20:21 +, Nathan Rixham wrote: pessary I had to Google that one, and wished I didn't... Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
Kevin Waterson wrote: Only a barbarian would call it Sequel or anything other than My S. Q. L MY ESS KEW ELL I have never heard that product SQL Server referred to as anything other than seequel server. Guess that proves your point :) Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A MySQL Question
Nathan Rixham wrote: tedd wrote: At 3:24 PM + 12/7/08, Nathan Rixham wrote: On the same not does anybody else frequently use (or even know about) the awesome spatial extension for mysql? or use the information_schema tables? I've certainly never used them, but I can imagine information_schema tables that are similar to DOCTYPE as found in xml for defining fields -- is that it? Cheers, tedd not many have :p but there's so much more power and speed can be opened up by using them.. to get you started ( I highly recommend this ) try: SELECT * FROM `information_schema`.`TABLES`; then: SELECT * FROM `information_schema`.`COLUMNS` The idea behind information_schema is it should be reasonably portable and should work on most types of db's. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
tedd wrote: Hi gang: I just interviewed for a job teaching at the local college (imagine me taking minds of mush and molding them to the world according to tedd -- frightening huh?) In any event, the interviewer asked me how long I've been using MySQL and I replied several years. After which she asked a single question, which was What does EXIST mean? There is no 'Exist' keyword in sql, it's 'EXISTS'. Everyone seems to know the drop table if exists syntax but that's not the right one they are after (and it's non-standard sql). There is an 'Exists' keyword for subselects. Instead of doing an IN query, you can do an 'exists' query - but it's use is very different. It returns true if any row in the subquery exists or false if none exist. The idea is instead of: select * from accounts where company_id in (select company_id from companies where name='X'); you do select * from company where company_id exists (select company_id from companies where name='X'); the subselect checks the company table for the id, if it exists, the outer query runs. It does not matter what company_id is returned from the subquery, just that at least 1 does return. I've never used this anywhere myself because I usually care what id's are returned from the subquery. (Yes, that's from the top of my head :P but here's doc's to help). http://dev.mysql.com/doc/refman/5.0/en/exists-and-not-exists-subqueries.html http://www.postgresql.org/docs/8.3/static/functions-subquery.html -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing Strings
Why not preg_split ( http://nz.php.net/manual/en/function.preg-split.php ): $str = 'SCOTTSDALE, AZ 85254'; $ar = preg_split('/,? ?/', $str); //optional comma, followed by optional space // $ar = array('SCOTTSDALE', 'AZ', '85254'); On Sat, Dec 6, 2008 at 1:18 PM, Jason Todd Slack-Moehrle [EMAIL PROTECTED] wrote: How might I also parse and address like: SCOTTSDALE, AZ 85254 It has a comma and a space -Jason On Dec 5, 2008, at 4:02 PM, Jason Todd Slack-Moehrle wrote: OK, making good learning progress today. I have a string that is: Jason Slack and I want it broken at the space so i get Jason and then Slack I am looking at parse_str, but I dont get how to do it with a space. The example is using []=. Then I want to assign like: $fname = Jason; $lname = Slack; Any ideas? -Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Tim-Hinnerk Heuer http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
Re: [PHP] A MySQL Question
EXIST? Yeah I certainly have seen it before in the result of a mysqldump, but from the top of my head, I probably wouldn't have known in exactly what context it is used. I've used MySQL for 5 years now and i think if you ask such a question, you don't know what you should be asking because the context of EXIST is hardly ever needed, and if, if you know where to look for it, that's more important than being able to reproduce it in from the top of your head. It's like asking: Do you know the syntax for ... where ... is a rarely used function in PHP or any other language. It's like requiring your employees to know every function of a language... On Mon, Dec 8, 2008 at 4:03 AM, tedd [EMAIL PROTECTED] wrote: Hi gang: I just interviewed for a job teaching at the local college (imagine me taking minds of mush and molding them to the world according to tedd -- frightening huh?) In any event, the interviewer asked me how long I've been using MySQL and I replied several years. After which she asked a single question, which was What does EXIST mean? Now without running to the manuals, please be honest and tell me how many of you know off the top of your head what EXIST means? I would be curious to know. I answered the question correctly, (I'm one of those weird types who read manuals for fun) but I have never used EXIST in a query. Have any of you? And while we're on the subject of MySQL -- while we all know how to write it, how do you say it? I've read that the common way is to say My Squell, or something like that. But I always sounded out each letter, such as My S-Q-L. The interviewer pronounced it the same as I, but I have heard others say it differently. What say you? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Tim-Hinnerk Heuer http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
Re: [PHP] A MySQL Question
On Mon, 2008-12-08 at 12:33 +1300, German Geek wrote: EXIST? Yeah I certainly have seen it before in the result of a mysqldump, but from the top of my head, I probably wouldn't have known in exactly what context it is used. I've used MySQL for 5 years now and i think if you ask such a question, you don't know what you should be asking because the context of EXIST is hardly ever needed, and if, if you know where to look for it, that's more important than being able to reproduce it in from the top of your head. It's like asking: Do you know the syntax for ... where ... is a rarely used function in PHP or any other language. It's like requiring your employees to know every function of a language... On Mon, Dec 8, 2008 at 4:03 AM, tedd [EMAIL PROTECTED] wrote: Hi gang: I just interviewed for a job teaching at the local college (imagine me taking minds of mush and molding them to the world according to tedd -- frightening huh?) In any event, the interviewer asked me how long I've been using MySQL and I replied several years. After which she asked a single question, which was What does EXIST mean? Now without running to the manuals, please be honest and tell me how many of you know off the top of your head what EXIST means? I would be curious to know. I answered the question correctly, (I'm one of those weird types who read manuals for fun) but I have never used EXIST in a query. Have any of you? And while we're on the subject of MySQL -- while we all know how to write it, how do you say it? I've read that the common way is to say My Squell, or something like that. But I always sounded out each letter, such as My S-Q-L. The interviewer pronounced it the same as I, but I have heard others say it differently. What say you? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Better questions really ought to be along the lines of how would you tackle this problem? and then accept a variety of answers back, or some debugging on erroneous code. Unfortunately, these tests all too often feature questions on those obscure functions that are rarely used. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
German Geek wrote: EXIST? Yeah I certainly have seen it before in the result of a mysqldump, but from the top of my head, I probably wouldn't have known in exactly what context it is used. I've used MySQL for 5 years now and i think if you ask such a question, you don't know what you should be asking because the context of EXIST is hardly ever needed, and if, if you know where to look for it, that's more important than being able to reproduce it in from the top of your head. It's like asking: Do you know the syntax for ... where ... is a rarely used function in PHP or any other language. It's like requiring your employees to know every function of a language... You're making an assumption about the situation. What if it was for a dba job or teaching advanced sql? And 'exists' is not for mysqldump. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
On Mon, Dec 8, 2008 at 2:59 PM, Chris [EMAIL PROTECTED] wrote: German Geek wrote: EXIST? Yeah I certainly have seen it before in the result of a mysqldump, but from the top of my head, I probably wouldn't have known in exactly what context it is used. I've used MySQL for 5 years now and i think if you ask such a question, you don't know what you should be asking because the context of EXIST is hardly ever needed, and if, if you know where to look for it, that's more important than being able to reproduce it in from the top of your head. It's like asking: Do you know the syntax for ... where ... is a rarely used function in PHP or any other language. It's like requiring your employees to know every function of a language... You're making an assumption about the situation. What if it was for a dba job or teaching advanced sql? And 'exists' is not for mysqldump. DROP TABLE IF EXISTS `mytable`; I said, I've seen EXIST in a result of a mysqldump before, which is not wrong is it? Unless I'm hallucinating... Or is EXISTS something completely different? And even a DBA or teacher doesn't need to know every part of syntax in MySQL. It's more important that they know the concepts... Anyway, I think this is all off-topic in a PHP mailing list... -- Postgresql php tutorials http://www.designmagick.com/ -- Tim-Hinnerk Heuer http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
Re: [PHP] A MySQL Question
And 'exists' is not for mysqldump. DROP TABLE IF EXISTS `mytable`; if exists can be used in lots of places other than drop table, like triggers, functions and i'm sure other things. I said, I've seen EXIST in a result of a mysqldump before, which is not wrong is it? Unless I'm hallucinating... Or is EXISTS something completely different? Yes it is completely different. http://dev.mysql.com/doc/refman/5.0/en/exists-and-not-exists-subqueries.html -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
On Mon, Dec 8, 2008 at 3:24 PM, Chris [EMAIL PROTECTED] wrote: And 'exists' is not for mysqldump. DROP TABLE IF EXISTS `mytable`; if exists can be used in lots of places other than drop table, like triggers, functions and i'm sure other things. I said, I've seen EXIST in a result of a mysqldump before, which is not wrong is it? Unless I'm hallucinating... Or is EXISTS something completely different? Yes it is completely different. Sorry, I couldnt find EXIST there, only EXISTS. http://dev.mysql.com/doc/refman/5.0/en/exists-and-not-exists-subqueries.html -- Postgresql php tutorials http://www.designmagick.com/ -- Tim-Hinnerk Heuer http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
Re: [PHP] A MySQL Question
German Geek wrote: On Mon, Dec 8, 2008 at 3:24 PM, Chris [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: And 'exists' is not for mysqldump. DROP TABLE IF EXISTS `mytable`; if exists can be used in lots of places other than drop table, like triggers, functions and i'm sure other things. I said, I've seen EXIST in a result of a mysqldump before, which is not wrong is it? Unless I'm hallucinating... Or is EXISTS something completely different? Yes it is completely different. Sorry, I couldnt find EXIST there, only EXISTS. If you're going to be that pedantic, exist isn't in mysqldump either :P -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
On Mon, Dec 8, 2008 at 5:06 PM, Chris [EMAIL PROTECTED] wrote: German Geek wrote: On Mon, Dec 8, 2008 at 3:24 PM, Chris [EMAIL PROTECTED] mailto: [EMAIL PROTECTED] wrote: And 'exists' is not for mysqldump. DROP TABLE IF EXISTS `mytable`; if exists can be used in lots of places other than drop table, like triggers, functions and i'm sure other things. I said, I've seen EXIST in a result of a mysqldump before, which is not wrong is it? Unless I'm hallucinating... Or is EXISTS something completely different? Yes it is completely different. Sorry, I couldnt find EXIST there, only EXISTS. If you're going to be that pedantic, exist isn't in mysqldump either :P I know it's pedantic, but unfortunately computers are strictly pedantic and I wasn't sure why you said if exists can be used in lots of places other than drop table, like triggers, functions and i'm sure other things. I was just stating that I saw it in a dump and I never really used it, so assume(d), it's not very important because you can do the same thing with IN etc and other conditions, can't u? Anyway, this discussion is getting rediculous. Let's move on. Didn't mean to offend anyone here. Don't worry about answering the last question if you also think it's irrelevant... All good. :) -- Postgresql php tutorials http://www.designmagick.com/ -- Tim-Hinnerk Heuer http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
Re: [PHP] A MySQL Question
Sorry, I couldnt find EXIST there, only EXISTS. If you're going to be that pedantic, exist isn't in mysqldump either :P I know it's pedantic, but unfortunately computers are strictly pedantic and I wasn't sure why you said if exists can be used in lots of places other than drop table, like triggers, functions and i'm sure other things. I was just stating that I saw it in a dump and I never really used it, so assume(d), it's not very important because you can do the same thing with IN etc and other conditions, can't u? They are completely different things you're mixing up here. IF EXISTS with DROP TABLE means if the table does not exist, do not give an error. Same for drop view, drop trigger. If the view/table/trigger/function does not exist, do not give an error. EXISTS in a select query is a subquery - same as using IN. Completely different. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
On Mon, Dec 8, 2008 at 5:50 PM, Chris [EMAIL PROTECTED] wrote: Sorry, I couldnt find EXIST there, only EXISTS. If you're going to be that pedantic, exist isn't in mysqldump either :P I know it's pedantic, but unfortunately computers are strictly pedantic and I wasn't sure why you said if exists can be used in lots of places other than drop table, like triggers, functions and i'm sure other things. I was just stating that I saw it in a dump and I never really used it, so assume(d), it's not very important because you can do the same thing with IN etc and other conditions, can't u? They are completely different things you're mixing up here. IF EXISTS with DROP TABLE means if the table does not exist, do not give an error. I do understand that it's a bit different here. Same for drop view, drop trigger. If the view/table/trigger/function does not exist, do not give an error. EXISTS in a select query is a subquery - same as using IN. Completely different. Right So, how are these different: SELECT * FROM t1 WHERE id EXISTS (SELECT id FROM t2) to SELECT * FROM t1 WHERE id IN (SELECT id FROM t2) ?? According to my understanding of the documentation, these would have the same result. Can't think of any sub query that could not have an equivalent statement with IN (NOT IN). -- Postgresql php tutorials http://www.designmagick.com/ -- Tim-Hinnerk Heuer http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
Re: [PHP] A MySQL Question
Right So, how are these different: SELECT * FROM t1 WHERE id EXISTS (SELECT id FROM t2) If there are *any* results for the subselect, the exists returns true. It's the equivalent of: select * from t1 where id is true; ie select * from t1; If there are no results for the subselect, the exists returns false, ie: select * from t1 where false; which will return nothing. to SELECT * FROM t1 WHERE id IN (SELECT id FROM t2) this returns specific id's that match. According to my understanding of the documentation, these would have the same result. No, they aren't. create table t1(id int, name varchar(5)); insert into t1(id, name) values (1, 'one'); insert into t1(id, name) values (2, 'two'); insert into t1(id, name) values (3, 'three'); insert into t1(id, name) values (4, 'four'); insert into t1(id, name) values (5, 'five'); create table t2(id int, other_name varchar(5)); insert into t2(id, other_name) values (1, 'one'); insert into t2(id, other_name) values (2, 'two'); this returns everything from t1: SELECT * FROM t1 WHERE EXISTS (SELECT id FROM t2); this returns 2 rows that match: SELECT * FROM t1 WHERE id IN (SELECT id FROM t2); -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
On Mon, Dec 8, 2008 at 7:06 PM, Chris [EMAIL PROTECTED] wrote: Right So, how are these different: SELECT * FROM t1 WHERE id EXISTS (SELECT id FROM t2) If there are *any* results for the subselect, the exists returns true. It's the equivalent of: select * from t1 where id is true; ie select * from t1; If there are no results for the subselect, the exists returns false, ie: select * from t1 where false; which will return nothing. to SELECT * FROM t1 WHERE id IN (SELECT id FROM t2) this returns specific id's that match. According to my understanding of the documentation, these would have the same result. No, they aren't. create table t1(id int, name varchar(5)); insert into t1(id, name) values (1, 'one'); insert into t1(id, name) values (2, 'two'); insert into t1(id, name) values (3, 'three'); insert into t1(id, name) values (4, 'four'); insert into t1(id, name) values (5, 'five'); create table t2(id int, other_name varchar(5)); insert into t2(id, other_name) values (1, 'one'); insert into t2(id, other_name) values (2, 'two'); this returns everything from t1: SELECT * FROM t1 WHERE EXISTS (SELECT id FROM t2); this returns 2 rows that match: SELECT * FROM t1 WHERE id IN (SELECT id FROM t2); Oh OK. Thanks for clearing that up. -- Postgresql php tutorials http://www.designmagick.com/ -- Tim-Hinnerk Heuer http://www.ihostnz.com -- Web Design, Hosting and free Linux Support