php

Templates in PHP, and the best way to notify the application that one exists?

I'm using CodeIgniter, and will likely use their template library, as I want to keep things extremely simple and easy to use. The content for the template variables will come from the database, but I want the business admins to know what content areas are available (basically the names of the variables) when they choose a specific templa...

jquery form plugin & programmatic submit

There are similar questions at SO, but none that seem to address this. Below is a very simplified variant of my situation. Drupal/PHP site -- I have a form w/ submit button that I am using jquery.form plugin to ajax-ly submit. It works fine if I use the submit (#submit) button. Now, I want to programmatically fire that button using an...

How to design error reporting in PHP

How should I write error reporting modules in PHP? Say, I want to write a function in PHP: 'bool isDuplicateEmail($email)'. In that function, I want to check if the $email is already present in the database. It will return 'true', if exists. Else 'false'. Now, the query execution can also fail, In that time I want to report 'Internal Er...

Fix for 'return' in cakePHP to return Value from view controller funtion

Hi there I have a function inside of a view function inside of a model class in the model.php file that looks like this function sqlToUnix($date){ $YMDThenHMS = explode(" ", $date); $YMD = explode("-", $YMDThenHMS[0]); $HMS = explode(":", $YMDThenHMS[1]); $UnixTime = mktime($HMS[0], $HMS[1], $HMS[2], $YMD[1], $YMD[2], $...

How to check if directory contents has changed with PHP?

I'm writing a photo gallery script in PHP and have a single directory where the user will store their pictures. I'm attempting to set up page caching and have the cache refresh only if the contents of the directory has changed. I thought I could do this by caching the last modified time of the directory using the filemtime() function a...

How can I workaround the Google Calendar's link redirect notice?

Hi, I have a Google calendar embedded on a webpage, with events related to activities the site is organizing. Some calendar events have links that redirect the user to a page, within the same website, which has more information and the option to enroll in the event. The problem however, is that since the end of last month, Google impos...

Optimize MySQL search process

Here is the scenario 1. I have a table called "items", inside the table has 2 columns, e. g. item_id and item_name. I store my data in this way: item_id | item_name Ss001 | Shirt1 Sb002 | Shirt2 Tb001 | TShirt1 Tm002 | TShirt2 ... etc, i store in this way: first letter is the code for clothes, i.e S for shirt, T for tshi...

How can I disable a compiled in extension in PHP

My home system has a version of PHP compiled with the SOAP extension. The live system has a version of PHP without the SOAP extension, and most of the scripts rely on the NuSOAP library quite heavily. The fact that NuSOAP and the SOAP extension use the same names for their classes is a terrible headache. How can I disable the SOAP exten...

Troubleshooting a recursive stripslashes method in PHP

I'm trying to use the stripslashes_deep function in the PHP documentation as a method, but when I pass it an array, it doesn't work. It does, however, work with a string. Can anyone point out why it might not be working? Magic quotes are on because I'm testing for that possibility, but like I said, it works for a string and I'm also not ...

Renaming File on another server as user downloads it [2] - using PHP

I have asked this question today already but this time I want to know if I can achieve this via PHP since Javascript wasn't up to it. I have a link to a file on another server. If i provide this link to my users the headers are pushed out to download that file from that server. Is there a way for me to capture those headers and file an...

How do I read any request header in PHP

How should I read any header in PHP? For example the custom header: X-Requested-With. ...

PHP and outputting one-to-many results

I've only dealt with one-to-one relationships in php so far, but I'm stuck on a problem which involves a one-to-many relationship. I've been sitting on this for a few days with no luck, so I'm desperate for someone to step in and show me a solution before I lose my mind. In my database have a series of urls, which are received by a SELE...

PHP readdir() not returning files in alphabetical order

I am reading through a directory with some pictures and such using a pretty simple implementation of readdir() like the following: if ($handle = opendir($path)) { while (false !== ($szFilename = readdir($handle))) { if ($szFilename[0] !== '.') { if (is_file($path.$szFilename)) { // do stuff } ...

how to unrar files using php on windows

Hello, how to unrar files using php on windows? Is there any script or codes to make it possible? Thanks ...

PHP : file_get_contents($loc) fails.

I just moved a project from localhost over to my remote server, and noticed that some of my scripts stopped working. Most importantly was one that relied upon file_get_contents() to fetch JSON values from another script. PHP Version is 5.2.4 allow_url_fopen is ON Warning: file_get_contents() [function.file-get-contents]: php_network...

What is += used for?

I think this is a dumb question but I could not find it on php. Why is a + with the = in the following code: function calculateRanking() { $created = $this->getCreated(); $diff = $this->getTimeDifference($created, date('F d, Y h:i:s A')); $time = $diff['days'] * 24; $time += $diff['hours']; $time += ($diff['minutes...

My SQL triggers

Is it possible to set up a mysql trigger that fires back the id number of that record when ever there is an insert into the database AND how do i capture that using php? ...

PHP Array extracting object

Suppose I have an array of a objects of user defined class. Wanted to know how do I extract the elements of the array in PHP. // class definition class User { public $fname; public $lname; } // array of objects of the class defined above $objUser1 = new User(): $objUser2 = new User(): $objUser3 = new User(): $objUser4 = new User(): $a...

The use of PHP vs ASP.net

How many of you prefer PHP over ASP.net because of its open source nature? I find there are more open source projects based upon PHP (and therefore more reusable code) because the sort of people who like to share are attracted to the language. I'm aware of a few open source ASP.net projects, but they're not as mature or active. ...

How do you write and test your regular expressions?

Is their any wizards or tools to create and test regular expressions for PHP, because it is so difficult :( ? thanks :) ...