php

Static within non-static method is shared between instances

I've come across some unexpected behavior with static variables defined inside object methods being shared across instances. This is probably known behavior, but as I browse the PHP documentation I can't find instances of statically-defined variables within object methods. Here is a reduction of the behavior I've come across: <?php cl...

Need code to execute a single php script that exists on multiple servers (without leaving the calling page).

I've got an updater.php script located on several of my sites. This updater.php file is set to execute code when called from a home base (my central server). So I'm looking to create a dashboard of sorts in which all my remote site addresses are listed, with the path to this updater.php script like so... www.server1.com/path/updater.ph...

Array to named variables

How can I take: $userarray (which is an array and I know holds 3 values) and put them into 3 seperate variables instead of looping through. There seperated by , (commas) so explode will be in there somewhere. Say $userfield1, $userfield2, $userfield3? ...

Zend_Form Prepend Element

I can add an element to a form like this: $form->addElement($element); However, that will put the element at the end of the form, I would like to prepend an element (put it at the beginning of the form). Why? The form has dynamically generated fields (number of text fields and their labels are generated based on parameters from reque...

Email isn't inserted into mysql database from form.

I have a newsletter for one of my sites and I can't the email posted to the mysql database. Here is the html form code: subscribe <h2>newsletter</h2> <br /><input type="text" name="email" value="" id="email" /> <input type="button" name="submit" onclick="submit_it(...

PHP ORM with support for SQL Server 2005

I have been looking around the current options (and related SO questions) regarding PHP ORM solutions, however I have a couple of unique requirements: I am running PHP on Windows Server 2003 I need to interface with SQL Server 2005 I can't seem to find a simple answer from the PHP ORM solutions out there as to which (if any) support ...

Zend_Search_Lucene failing to return documents

Hi, I am struggling with a bug/problem that I am having trouble with when using Zend_Search_Lucene. Now I have 2 indexes that I search one that is parsed html pages/text that I use the Zend_Search_Lucene_Document_Html::loadHTML() function to read the contents and add to one of the lucene indexes. The other index I manually create a lu...

Convert and array into an ordered list of input fields...

I've got an array of sites like so... $data = array( 'http://site1.net/', 'http://site2.net/', 'http://site3.org/' ); And I'd like to create a script that iterates over the array and creates a list of input text fields containing each array element... Example: 1. [] http://site1.net/ 2. [] http://site2.net/ 3. [] http://site2.net/...

Delete confirmation in php

I'm trying to delete a record in mysql using php. What do I have to add in my code so that there will be a delete confirmation first. Because in my current code, it automatically deletes the record corresponding to the pnum inputted. <html> <style> input { font-size: 16px;} </style> <?php include('header.php'); ?> <div id="main_content...

What's the proper way of adding anchor links inside a php array?

I changed the single quotes to doubles quotes after I faced th following problem: $lang = array( 'let's do something...' ); Now I have this problem: $lang = array( "tagline_h2" => "A paragraph...<a href="#">this is a link</a>" ); What should I do? ...

comma-separated string to array

I'm looking for the simplest way to take a single variable such as: $variable = 'left,middle,right'; and write it to an array(); split at the commas. ...

Should I use a setter within a class to set a property?

I want to set a property value within my class. I can do it without a setter and a getter but I want to know the "correct" way to approach this. This is for a login script so the property and the setter are both private. Should I just set the property directly or use a setter and a getter? ...

Cron job creating empty file each time it runs

I have a php script I want to run every minute to see if there are draft news posts that need to be posted. I was using "wget" for the cron command in cPanel, but i noticed (after a couple days) that this was creating a blank file in the main directory every single time it ran. Is there something I need to stop that from happening? Than...

Pdf on web page: best solution

Hi, I need to include pdf files in some webpages, and I'm gettin' in troubles. The app is a simple newspaper's archive, in which i can read right on page or download as pdf files, one file per page. What my customer can provide me is one pdf file for each page; what my customer wants from me is to navigate them in indexes (with page th...

Problem with simple regular expression in PHP

The best way to explain my problem is to just show you. Input String: /04-11-2010/12:45/ Regular Expression to get date and time parts: preg_match('@/(\d\d)-(\d\d)-(\d\d\d\d)/(\d\d):(\d\d)/@', $input, $matches); PHP Matches Array: Array ( [0] => /01-11-2010/12:45/ [1] => 01 [2] => 11 [3] => 2010 [4] => 12 ...

if(0 == '%') echo "WTF, Php, why can't you compare things sanely?"

I just reduced a crazy bug to what's in the title of this question. I'm sure there's a Perfectly Reasonable Explanation for why Php thinks that 0 == '%' (or any other special character, I think). I thought it would be good to get that explanation on StackOverflow! ...

PHP CLI and Task Scheduler problem

I thought I had set up a successful schedule in Windows to run a PHP script. But all I got was an error which slaps only when run through the task scheduler. Here is how I run the task: I created a batch file runCron.bat: start php.exe reportGenerator.php and placed reportGenerator.php in the same folder as of the batch file. When ...

How do you recommend I pass data from one form to another, and finally to another final page?

I'm taking a class in PHP and I'm a real newbie when it comes to best practices and whatnot. I have a little homework that the teachers wants me to hand in. Create a form that asks a user for his name, last name, age and birthday. When the users clicks submit, take him to the second form and ask for his location, nationality and reli...

RSS speed vs. AJAX speed

I am attempting to pull posts from my Wordpress (on the same server as my main site) to my main site. I am able to use both RSS and Ajax - but I need to choose between them. What are the performance pro's and con's of either, and what should my final decision be? ...

filter mySQL database with multiple words in any order in Concatenated field

I have Concatenated in mySQL to produce a field that I can search with. This contains animal as well as owner names and addresses for a client database. I need to be able to search by animal name, owner names and postcode in any order. Thus if if my name is john smith and i own a dog called Fido and live in postcode AB1 2CD, I want the s...