php

How to determine client pc date format

Is there any way by which we can find Date Format as set in the computer where web pages are loading? I want to show date in my web pages according to what is set in client machine system. I have seem an ASP based web page which lists all the system setting of a clients system including information of drivers installed! So if it is po...

Multiple Similar Layouts

I'm developing a application with CakePHP, and I have two layouts: one for the home page, and another for the rest of the application. Except for some coding on the header, they're almost exactly the same. Is there something I can do to keep DRY, without using IFs all over the layout? ...

How to calculate a relative date based on a date string

I'd like to find the date after a date provided by the user This is not working: $start_date = '2009-06-10'; $next_day = date( $start_date, strtotime('+1 day') ); echo $next_day; // 2009-06-10 ...

Firefox error 'no element found'

First off, this isn't exactly the ideal way of setting up a page, however there's a need to distribute a script as 1 file. I have a php script at the top of an otherwise xhtml document with javascript, and under certain conditions use XHR to send a query string to the page itself. The php at the top then activates, and stores the passe...

Website security question with PHP? (Probably applies to ASP/Rails/etc.. too)

Say, I have "index.htm" and "routines.php". "index.htm" will call eventually call "routines.php" using JS (AJAX). So, my question is, how can "routines.php" verify that the request came from the same local server and not outside? Is there a global variable I can check at PHP level or HTTP level? Edit 1: Using AJAX ...

How do I access a file's icon server-side via PHP?

I have a PHP script running that lists files in a certain directory on the server. Is there any way to access the file's icon metadata? Lots of issues with this I suppose (eg: depends on the OS hosting the script. depends on whether the file is using a custom icon. still have to convert the icn file to something that can be displayed in ...

Multiple columns after a WHERE in PHP?

Hey all, just a quick question (should be an easy fix I think). In a WHERE statement in a query, is there a way to have multiple columns contained inside? Here is my code: $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and pwd='$pass'"; What I want to do is add another column after the WHERE (called priv_level = '$privle...

php array processing question

Before I write my own function to do it, is there any built-in function, or simple one-liner to convert: Array ( [0] => pg_response_type=D [1] => pg_response_code=U51 [2] => pg_response_description=MERCHANT STATUS [3] => pg_trace_number=477DD76B-B608-4318-882A-67C051A636A6 ) Into: Array ( [pg_response_type] => D ...

Why Can't I Include A Blog?

I commonly run into a scenario where "the powers that be" want an exact copy of a page in multiple places on a website. Rather than actually duplicate the content, all I do is override the section in the nav that is highlighted, and then include the page. The final page looks something like this: <?php $top_nav_item_id = 'teen'; ...

PHP - Converting all Errors to Exceptions - Good or Bad?

I was wondering if it's considered a bad practice to globally convert all PHP Errors to Exceptions. Something like the following would be used: function exception_error_handler($errno, $errstr, $errfile, $errline ) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); return false; } I suppose the assumption is ...

How to check if a date is in a given range?

If you have a $start_date and $end_date, how can you check if a date given by the user falls within that range? e.g. $start_date = '2009-06-17'; $end_date = '2009-09-05'; $date_from_user = '2009-08-28'; At the moment the dates are strings, would it help to convert them to timestamp integers? ...

Zend_Uri_Http generates "inet_pton(): Unrecognized address" error

In our application, the backend is accessed via Zend_XmlRpc. In the backend, I'm using Zend_Http_Client together with Zend_Http_Client_Adapter_Curl to connect to another web service over HTTPS. During unit tests, everything works as expected and the remote service is accessible. But when the frontend connects via Zend_XmlRpc to the back...

Handling simultaneous uploads on the database

My web app allows users to upload a bunch of photos simultaneously to the server, and then stores them in a database. When the first photo finishes uploading, it should create a default album based on today's date, and add it to that. But what if photo1 completes, looks for the album, and can't find it so it decides to create it, but bef...

MySQL SELECT with a condition help

CREATE TABLE `comments` ( `comment_id` int(11) NOT NULL AUTO_INCREMENT, `comment_parent_id` int(11) NOT NULL DEFAULT '0', `user_id` int(11) NOT NULL DEFAULT '0', `comment_text` varchar(200) NOT NULL DEFAULT '', `comment_created` int(20) NOT NULL DEFAULT '0', `comment_updated` int(20) NOT NULL DEFAULT '0', `comment_replies_c...

using jquery vs php to reduce load

Hi I'm setting up a registration page, and I'm using PHP primarily to verify the data. I've realized that using a client-driven language for some of the validation will reduce the workload from the server. I don't have much knowledge in jquery, but I'm looking for code that will determine the correct syntax of an email (ex, one '@' and...

log-out is not working in php for a login System.

Hi to everyone, i am implementing a log-in system, i am sure a lot of you know what it is, i use sessions to store the user's ID, and check it if he access a page that needs the user to be logged in. But my problem is when the user clicks the log-out anchor, nothing happens i still can access the other pages as long as the current page i...

Export mySQL to excel or csv

Hi, I'm no php expert (a mere beginner) but need some help! After hours searching Google and trying out about 100 different scripts, I finally found one that does what I need - almost. Basically, my site has a button marked 'Export to Excel'. Visitor to site clicks button and a download begins containing all data from a specified tabl...

Relationships in Zend_DB_Table_Abstract

I'm using the default framework code that was created with the Zend Framework Application tool, I added some autoloader magic so that any classes named Default_<*>_<*> would automatically be loaded from the correct directory, in this case Default_Model_TableName. application/models/ProjectCategories.php: <?php class Default_Model_Proj...

What SMTP server does PHP mail() use by default, and are there better options?

I host my site with GoDaddy , and I use the PHP mail() function at the moment to send form mails from my site. GoDaddy has a 1000 SMTP relay limit per day for form mail stuff, but they swear that with my PHP script that I should not be touching it. Since mail() doesn't take SMTP info, does it just automatically use GoDaddy's (or whatev...

how to make echo print out right away in PHP?

By default it will not print out anything until the whole page has finished executing. Is there any function that can make it flush out right away? But not by calling ob_end_flush() multiple times,which is not what I want. Hope you guys got me? ...