php

Setting up a PHP web project, the infrastructure.

Hello, How can I best set up my PHP (LAMP) development environment so that I have development, staging and production servers. One-"click" deployment to any of those, as well as one-click rollback to any revision. Rollback should also rollback the database schema and data to how it was when that source code was current. Right now I'v...

Where can I find a free, lightweight YUI-like compressor for PHP?

Where can I find a free, lightweight YUI-like compressor for PHP? I am sure it will decrease the file size but will compressing PHP code boost its performance? Is this the same thing as an obfuscator? ...

PHP Blog system for MODx

I run a site using the MODx Content Management System. What I'd like to do is set up a news feed on the front page, with a blog-style backend that supports the usual things (tags, categories, archives basically). I've looked into the MODx plugins which provide this functionality (the deprecated NewsPublisher - which we use currently - a...

Javascript and PHP functions

Is it possible to call a function from PHP using onsubmit from javascript? If so could someone give me an example of how it would be done? function addOrder() { $con = mysql_connect("localhost", "146687", "password"); if(!$con) { die('Could not connect: ' . mysql_error()) }...

mysql duplicate entry error when there is no duplicate entry (bulk load via php)

i am using mysql (5.0.32-Debian_7etch6-log) and i've got a nightly running bulk load php (5.2.6) script (using Zend_DB (1.5.1) via PDO) which does the following: truncating a set of 4 'import' tables bulk inserting data into these 4 'import' tables (re-using ids that have previously been in the tables as well, but i truncated the whole...

When attaching a file to an email, does it need to be stored on the server first?

I have a function that automatically exports a table into a CSV file, then I try to attach that same file into a function that will email it. I have sent attachments using html mime mail before, but I was wondering if that created CSV file needs to be stored on the server first before attaching it to the email? ...

Is there a MySQL command to convert a string to lowercase?

I have a MySQL database of keywords that are presently mixed-case. However, I want to convert them all to lowercase. Is there an easy command to do this, either using MySQL or MySQL and PHP? ...

In PHP, how can I correct missing keys in an array?

After using array_unique, an array without the duplicate values is removed. However, it appears that the keys are also removed, which leaves gaps in an array with numerical indexes (although is fine for an associative array). If I iterate using a for loop, I have to account for the missing indexes and just copy the keys to a new array, b...

Asynchronous shell exec in PHP

I've got a PHP script that needs to invoke a shell script but doesn't care at all about the output. The shell script makes a number of SOAP calls and is slow to complete, so I don't want to slow down the PHP request while it waits for a reply. In fact, the PHP request should be able to exit without terminating the shell process. I've lo...

How to check for optional fields in $_POST

At the moment my code looks like this: # Assign values for saving to the db $data = array( 'table_of_contents' => $_POST['table_of_contents'], 'length' => $_POST['length'] ); # Check for fields that may not be set if ( isset($_POST['lossless_copy']) ) { $data = array( 'lossless_copy' => $_POST['lossless_copy'] ); ...

Other packages with Xdebug-like features (informative PHP errors, formatted var_dump()s, etc.)?

When Xdebug is installed/enabled, standard PHP errors (when set to display in the browser) are replaced with more informative messages that include stack traces for each. Also, I've noticed that it also seems to improve output in other areas such as the var_dump() function, formatting/color-coding the output to make it more readable. Ar...

Should I use multi-byte overloading (mbstring.func_overload)?

I'm in the process of making my PHP site Unicode-aware. I'm wondering if anyone has experience with the mbstring.func_overload setting, which replaces the normal string functions (e.g. strlen) with their multi-byte equivalents (mb_strlen). There aren't any comments on the PHP manual page. Are there any potential problems that I should b...

In PHP, is there a way to capture the output of a PHP file into a variable without using output buffering?

In PHP, I want to read a file into a variable and process the PHP in the file at the same time without using output buffering. Is this possible? Essentially I want to be able to accomplish this without using ob_start(): <?php ob_start(); include 'myfile.php'; $xhtml = ob_get_clean(); ?> Is this possible in PHP? Update: I want to do ...

Creating a client editable events calendar in html or php

A prospective client wants to have a calendar feature on their website. They want the option to go edit this calendar to update the events. Does Word Press offer something like this? ...

How to call COM function from PHP with OLE_COLOR as an argument?

I am trying to call a COM object from PHP using the COM interop extension. One function requires an OLE_COLOR as an argument? Is there any way to pass this kind of value from PHP? I have tried passing a simple integer value with no success. $this->oBuilder->Font->Color = 255; ...

How do I add an ODBC driver to a MAMP environment?

I'm working on something that was built on a PC set-up using php and an ms access database. When I port the app to my MAMP environment, I get Fatal error: Call to undefined function odbc_connect() in /path/to/index.php on line 37 line 37 looks like this: return odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=myfile.mdb",...

Supposedly valid regular expression doesn't return any data in PHP

I am using the following code: <?php $stock = $_GET[s]; //returns stock ticker symbol eg GOOG or YHOO $first = $stock[0]; $url = "http://biz.yahoo.com/research/earncal/".$first."/".$stock.".html"; $data = file_get_contents($url); $r_header = '/Prev. Week(.+?)Next Week/'; $r_date = '/\<b\>(.+?)\<\/b\>/'; preg_match($r_header,$data,$he...

Converting a sed string to PHP

Hi, I have a regexp I'm using with sed, but now I need to make it work in PHP also. I can't use system calls as they are disabled. $ cat uglynumber.txt: Ticket number : 303905694, FOO:BAR:BAR: Some text Case ID:123,456,789:Foobar - Some other text 303867970;[FOOBAR] Some text goes here Case Ref: 303658850 - Some random text here - hos...

Is it possible to install Kohana libraries for ORM in PHP without using the entire framework?

In a previous question, I asked about various ORM libraries. It turns out Kohana looks very clean yet functional for the purposes of ORM. I already have an MVC framework that I am working in though. If I don't want to run it as a framework, what is the right fileset to include to just give me the DB and ORM base class files? Update: I ...

How can I relax PHP's open_basedir restriction?

open_basedir limits the files that can be opened by PHP within a directory-tree. I am storing several class libraries and configuration files outside of my web root directory. This way the web server does not make them publicly accessible. However when I try to include them from my application I get an open_basedir restriction error l...