php5

PHP function is_nan() throws a warning for strings

I've been using the is_nan() function (ie: is-not-a-number) to check whether a variable taken from the querystring is a number or not. However, in the case of the variable being a string (in which case is_nan() should return TRUE), the function also throws the following rather annoying warning: Warning: is_nan() expects parameter 1 to b...

Best way to track database table/column for html form control

I am working on a php program that requires javascript on every form control. Once the onblur event takes place the value will automatically be sent to the server to update the database. I have possibly 50 form controls spread over 5 tabs so I don't want to hardcode the information on the php file. I could co-opt an idea from HTML5 and...

I create a menu(Home, My Quote, Send a Quote) using <fb:tab>

can any body help me the create a menu(Home, My Quote, Send a Quote) using for my facebook application. When I select a tab, the menu disappears when a new page opens up. I need to display my page under the menu itself, so how to do that the code is <div> <fb:tabs> <fb:tab-item href="http://apps.facebook.com/ranpariya/ind...

PDO not reading config correctly

I'm not sure what the problem is here, I've inherited some code form Zend Framework and it's using Propel to make DB Queries. I've changed the config file to have the right values in it, username, password, localhost and dbname however, whenever the site has to make a database call it dies with this message: Error processing connection ...

Howto chain objects in PHP5: $this->foo->bar->baz()

How do I make chained objects in PHP5 classes? Examples: $myclass->foo->bar->baz(); $this->foo->bar->baz(); Not: $myclass->foo()->bar()->baz(); See also:http://www.talkphp.com/advanced-php-programming/1163-php5-method-chaining.html Thanks. /Kristoffer :-) ...

Sorting files with DirectoryIterator

Hi, I'm making a directory listing PHP5 script for lighttpd. In a given directory, I'd like to be able to list direct sub-directories and files (with informations). After a quick search, DirectoryIterator seems to be my friend: foreach (new DirectoryIterator('.') as $file) { echo $file->getFilename() . '<br />'; } but I'd like t...

How to Implement URL Routing with PHP + IIS?

I wrote a content switcher script that uses dynamic URLs to pass parameters indicating what data is to be sent. For example to view the about page you would type: http://www.example.com/?page=about The issue is that this is not user friendly especially in my case where users will not necessarily be accessing this page via a link from t...

Error with Propel and ZendFramework

After inheriting some Zend Framework code it didn't work, after lots of fiddling I've managed to create the schema and rebuild the models, although now I'm getting the following error: Call to undefined method Criteria::hasSelectClause() in home/richard/library/om/BaseDomainPeer.php on line 329 Why would propel generate files that c...

How can I zip up a folder and then unzip it to somewhere else?

I'm working on a site which downloads folders users upload from our other server, but first we have to zip that folder - how do I zip up a whole folders' contents? ...

How can I catch the controller/action values of a request before dispatch?

Zend Framework: I have the following url /base/url/[number]/[string] OR /base/url/action/controller/param/value I want in the case of /base/url/[number]/[string] to transform it to /base/url/controller/a/action/b/id/[number]/name/[string] The a and b are constants (i.e. each time I see a number in the place of...

Looping out mysql data

I have a mysql database of entries with dates. So what I want is to show all the dates in my database and then under each date, I want to show all the entries in the database entered on the specefic date. I am thinking of two loops but I don't know how to write the condition to display all the dates in my database before I loop out the e...

How can I ignore time for NOW()?

I have a mysql database of entries with dates. So what I want is to show all the dates in my database and then under each date, I want to show all the entries in the database entered on the specefic date. I am thinking of two loops but I don't know how to write the condition to display all the dates in my database befo...

Caching data vs. recalculating in PHP

Here's the lowdown of the situation. I am creating a role-playing game with PHP. The combat system consists of the various buffs and debuffs. The combat is likely to take several turns (it's against an AI). I am of two mind about ensuring the correctness of the player's data (buffs and debuffs expire over time. A +5 strength buff may la...

Suggestion for a efficient Pagination tutorial?

I have looped data from mysql, and it's a pretty long list. What's the most efficient way to do pagination? Currently, I am looking at this one: http://www.evolt.org/node/19340 Feel free to recommend a better one, thanks ! ...

What causes an HTTP 405 "invalid method (HTTP verb)" error when POSTing a form to PHP on IIS?

I have one form in a PHP (5.2.9-1) application that causes IIS (Microsoft-IIS/6.0) to throw the following error when POSTed: The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access. It's an HTTP 405 status code. All other forms in the application work, so I believe that the ...

PHP Array and ArrayObject

which one should be used to manipulating data, Array or Array Object? Like search,sort and other array manipulations. ...

Optimize regex replace in PHP

I have written a PHP function to take a video embed code that has width and a height and allow you to specify a new width. The function will then scale down the height using the appropriate scaling factor. I discovered that the width and height were not always adjacent so I make a couple of calls which I have a hunch are unnecessary. Is...

Easiest way to grab filesize of remote file in PHP?

I was thinking of doing a head request with cURL, was wondering if this is the way to go? ...

Change scripts extension to .php5 for php 5 execution?

Is there any drawback to this setup? I want to be able to run PHP5 filters and functions... Will renaming a file to something.php5 allow me to do this? My hosting provider suggested this instead of upgrading to PHP5. The default is still php4 with registered_globals ON ...

How can I make a calendar with MYSQL data?

In my database, there are some days with data and some without; I have one column with data, and another column with the date and time submitted. So I want to create this calendar. So it will show all the days in the month, and then the days with data will be a hyperlink. When I click the link, it will show all the data submitted on that...