[PHP] Closing PHP tag best practice?

2011-07-24 Thread Geoff Lane
Hi All, While watching one of Jeffrey Way's CodeIgniter tutorials, I was gobsmacked when he noted that it was best practice not to have closing PHP tags as closing tags might introduce whitespace issues. So I tried syntax checking a few simple pages and, to my surprise, the syntax checkers

[PHP] Re: Escaping '

2011-07-22 Thread Geoff Lane
On Friday, July 22, 2011, Floyd Resler wrote: I did a fresh install of PHP on a new server. I had gotten used to PHP automatically adding a backslash before single quotes when form data is submitted. It seems that is shut off in my new install. How do I turn it back on? Check the manual

[PHP] Re: Constants in strings

2011-07-06 Thread Geoff Lane
On Wednesday, July 6, 2011, Dave Wilson wrote: OK. We all know that constants cannot be accessed directly via their name in double-quoted or heredoc strings. FWIW, this looked like it might be a right royal PITA for me ATM. However, I've got a work-around. With about a dozen scripts written

Re: [PHP] I want to use POST when redirect via PHP Header function.

2011-06-30 Thread Geoff Lane
On Thursday, June 30, 2011, Md Ashickur Rahman Noor wrote: I want to use POST when redirect via PHP Header function. Is it possible? AFAICT, it isn't. You can use GET variables by passing them on the querystring. These can then be accessed via $_REQUEST, which is an amalgamation of $_POST,

[PHP] Re: I want to use POST when redirect via PHP Header function.

2011-06-30 Thread Geoff Lane
On Thursday, June 30, 2011, Jasper Mulder wrote: Personally, I think that incorrect spelling is far more annoying than the quoting; that is, if it does not originate from incapability due to English (whether it be British or American) being not the native language, as opposed to spelling

[PHP] Re: URL Rewriting

2011-06-23 Thread Geoff Lane
On Thursday, June 23, 2011, Ashley Sheridan wrote: I've not yet seen any evidence yet that pretty URLs actually benefit SEO. I regularly search for answers to problems online, and mostly I get forums as the results, all of which have URLs like showthread.php?t=1234567 Anecdotal perhaps, but

[PHP] Re: URL Rewriting

2011-06-22 Thread Geoff Lane
On Wednesday, June 22, 2011, Daniel Brown wrote: RewriteEngine on RewriteRule ^theme([0-9]+).php$  /index.php?theme=$1 [L] That's neither nginx nor PHP, so it's not really relevant to the OP's questions. I guess that the answer should be that you can rewrite outside of PHP and then make

[PHP] Re: Submit Using An Image Form Processing

2011-06-18 Thread Geoff Lane
On Saturday, June 18, 2011, Ron Piggott wrote: I am not getting anything. Is there a correct way of passing a variable through an image? The value in this above example is the auto_increment value of the product. From this I could remove the item from the shopping cart. An image causes

[PHP] Re: What do you get for ...

2011-06-07 Thread Geoff Lane
On Tuesday, June 7, 2011, Richard Quadling wrote: What do you get for ... php -r var_dump(realpath(null)); PHP 5.3.5-1ubuntu7.2 on Ubuntu 11.04 kernel 2.6.18 returns the same value as __DIR__ However, PHP 5.1.6 on CentOS 5.6 kernel 2.6.18 returns bool(false). Doing php -r var_dump(__DIR__);

[PHP] Re: What do you get for ...

2011-06-07 Thread Geoff Lane
On Tuesday, June 7, 2011, Richard Quadling wrote: But the surprising issue is that your 5.1.6 returns bool(false). So far, that's the only report I've got that shows inconsistent behaviour for PHP5+ I too was surprised, which is why I took the time to report. AFAICT, I've got the standard

[PHP] Re: Date validation

2011-05-21 Thread Geoff Lane
I'm posting here for completeness as I've now rolled my own date validator (code follows my sig). It allows almost all valid 'English' formats except ordinal day values (1st, 3rd, etc.) Because I'm in UK and writing for a UK audience, I've parsed ambiguous dates as d/m/y. Those writing for places

[PHP] Date validation

2011-05-20 Thread Geoff Lane
to be such a common requirement that I suspect I've missed something basic. I'd thus be grateful for any pointers as to how to properly validate user-input string representation of dates. Cheers, -- Geoff Lane -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net

[PHP] Re: Date validation

2011-05-20 Thread Geoff Lane
On Friday, May 20, 2011, João Cândido de Souza Neto wrote: What about using this: $date = DateTime::createFromFormat(Y-m-d, 2011-05-20); Hi João, and thanks for your help. FWIW, I thought about that but it didn't work for me. On further investigation, I'm now completely confused and suspect

[PHP] Re: Date validation

2011-05-20 Thread Geoff Lane
On Friday, May 20, 2011, Peter Lind wrote: This is pretty much as expected except that the second call to date() - i.e. date('d M Y', $date) - outputs nothing. date() takes an int as second parameter - a timestamp. Not an object. And from a quick test it doesn't look like DateTime has a

[PHP] Re: Date validation

2011-05-20 Thread Geoff Lane
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

[PHP] Re: Date validation

2011-05-20 Thread Geoff Lane
On Friday, May 20, 2011, João Cândido de Souza Neto wrote: What about using regular expression to validate so using DateTime object to parse it if it?s a valid date? Again, thanks. For info, I only need to know that it's a valid representation of a date on this occasion as I intend to use

[PHP] Wierd cookie behaviour

2011-05-16 Thread Geoff Lane
Hi All, I'm scratching my head a bit here. I have a form handling script that branches dependent on whether a user has admin privileges over the application. Here's the function that tests this: function isAdmin($user){ global $chan; $query = SELECT isadmin FROM csw_user WHERE username =

Re: [PHP] dynamic copyright in page footer?

2011-04-30 Thread Geoff Lane
On Saturday, April 30, 2011, Simon J Welsh wrote: I would use something simple like: if(date('Y') == '2011') { echo '2011'; } else { echo '2011-', date('Y'); } ... or in one line: echo (date('Y') != '2011' ? '2011-' : '') . date('Y'); However, you might want to change

[PHP] Re: PHP delete confirmation

2011-04-29 Thread Geoff Lane
On Friday, April 29, 2011, ad...@buskirkgraphics.com wrote: Personally I would use the javascript page navigation is senseless if they miss click. Javascript: Small and simple javascript. onclick=return confirm('Are you sure you want to delete?') Personally, I'd use Javascript and also

Re: [PHP] Javascript detection

2011-04-28 Thread Geoff Lane
On Thursday, April 28, 2011, tedd wrote: To answer your question in a new thread. No, the $_SERVER super-global isn't going to give you anything nor is anything else like it. You see, PHP has a difficult time detecting IF Javascript is turned ON in the client's browser because PHP is

Re: [PHP] Destroying cookies... not working

2011-04-28 Thread Geoff Lane
On Thursday, April 28, 2011, Sean Greenslade wrote: On Wed, Apr 27, 2011 at 8:52 PM, Rick Dwyer rpdw...@earthlink.net wrote: The following did the trick... is there any reason I should not use it? $name=mysession; setcookie($name); --Rick Only if you're OCD, since the cookie is still

Re: [PHP] Javascript detection

2011-04-28 Thread Geoff Lane
On Thursday, April 28, 2011, Ashley Sheridan wrote: I'm not sure if my earlier reply got through, but here it is again (or at least the general gist of it) Many thanks. I got your info the first time around but didn't respond directly to you as Tedd made similar comments and I'd responded to

Re: [PHP] Re: What's faster using if else or arrays?

2011-04-28 Thread Geoff Lane
On Thursday, April 28, 2011, Jim Giner wrote: Arrays - using a silly construct that probably still takes as much time to evaluate machine-wise as anything else. And as far as readability goes, it is even sillier. IMO. I don't know so much about that ... I'll use a global array to

[PHP] Detecting Javascript (was Re: Newsgroup status)

2011-04-27 Thread Geoff Lane
On Wednesday, April 27, 2011, Ashley Sheridan wrote: Firstly, please do not hijack a thread, if you have a question, start your own. We won't bite if you create new threads, whereas we might a little if you hijack ;) Ouch! My apologies - Hijacking was not intended and I've changed the

Re: [PHP] Last Name extraction in query

2011-04-04 Thread Geoff Lane
On Monday, April 4, 2011, Jim Giner wrote: Actually - I can't seem to find a mysql newsgroup anywhere. The ones that come up in google search are all dead and buried. You could try http://forums.mysql.com/ or have a look around Yahoo groups (e.g. php_my...@yahoogroups.com). HTH, -- Geoff

[PHP] Re: is there any syntax to save a file in mysql?

2011-03-28 Thread Geoff Lane
On Monday, March 28, 2011, Negin Nickparsa wrote: ... i want every user to have his/her own files in their account. (i used session for them) n now i want them to have their specific files then i think i must have db that store the files n user can retrieve his/hers not just details if i just

[PHP] Re: opening a new window from php script

2011-03-25 Thread Geoff Lane
On Friday, March 25, 2011, Grega Leskovšek wrote: Do I have to use target=_new - I can not do this - I am working this for my University seminar and it has to be valid HTML5. I guess that this is an HTML issue rather than PHP. However: Despite what the W3C validator might claim, I understand

[PHP] Re: echo?

2011-03-23 Thread Geoff Lane
: $q = 'select * from director_records '; $qrslt = mysql_query($q); $i = 1; while ($row = mysql_fetch_array($qrslt)){ echo $i++ . '-' . $row['userid']; if ($row['user_priv']){ echo ( . $row['user_priv'] . ); } echo br\n; } HTH, -- Geoff Lane Cornwall, UK

[PHP] Re: $_POST variable

2011-03-11 Thread Geoff Lane
. -- Geoff Lane Cornwall, UK -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php