php

Upload Progress Bar in PHP

Does anyone know how to get a progress bar for an upload in php? I am trying writing code for a photo album uploader. I would like a progress bar to display while the photos are uploading. I am fairly new to php so I dont know everything about it. ...

How can I make this multidimensional array and these foreach loops work together?

// a beautiful multidimensional array public $form = array ( array( 'field' => 'email', array( 'params' => array( 'rule' => 'email', 'on' => 'create', 'required' => true, ), ), ...

where to place images folder in Kohana PHP ?

I have a page with some HTML in it. and I need to set the src property to the location of pictures. How can I achieve that with Kohana PHP ? Thanks. ...

Is casting a mysqli result object to an array good practice?

Hey everyone, I was wondering, if I have some code such as: $result = $db->query($sql); // dont worry, its escaped $myData = (array)$result->fetch_assoc(); where $result->fetch_assoc(); returns a mysqli result object. Is casting it like this right away good practice? I would imagine this is an expensive call - is this true? It...

Finding cause of memory leaks in large PHP stacks

I have CLI script that runs over several thousand iterations between runs and it appears to have a memory leak. I'm using a tweaked version of Zend Framework with Smarty for view templating and each iteration uses several MB worth of code. The first run immediately uses nearly 8MB of memory (which is fine) but every following run adds ab...

Zend_Search_Lucene on Leopard: problem

Leopard 10.5.6 Macbook Zend 1.6, Apache 2, PHP 5.2.5 I cannot seem to do indexing, using Zend_Search_Lucene api. Building or opening indices on generates the following exception message: string(30) "Wrong segments.gen file format" However, the indices/segments files were scp from a working version of my site and I've chmoded them all...

Performing Photoshop's "Luminosity" filter programmatically

I have two JPEG's and would like to overlay one on the other with the same results as the "Luminosity" mode available in Photoshop (and Fireworks). You can read more about Luminosity mode here: http://www.adobetutorialz.com/articles/662/1/Photoshop%92s-Luminosity-Mode How can I do this? Programming language doesn't matter much, but I ...

How do I create a decent error 404 handler for CodeIgniter?

CodeIgniter has /system/application/errors/error_404.php which is displayed when there is a 404 due to what is effectively a "controller not found" condition. However, for my project, I really need this error to be handled just like it is when a method is missing from the controller class. In that case, I show a normal view with a pretty...

How to be safe when PHP6 is released and ereg regex is turned into an extension instead of core.

For those of you who don't know what's gonna happen in PHP6, here's a nice short read: http://jero.net/articles/php6 Now, if you have functions that depend on ereg and you don't have control over the php.ini file on the server that's hosting your scripts, how do you deal with that? For instance, this function here: function currentDat...

Pulling multiples pages of search terms from Twitter

I'm trying to figure out a way to pull all tweets of a specific search term via PHP and the Twitter search api. So functionality would include 1. Include a search term 2. Pull terms from each page. 3. Only pull new terms from last search 4. Export to a db or a flat file. I'm pretty clear on all of these except for traversing across mul...

Inserting input field text into textarea with JavaScript

Hi I need to insert a text/string from an input field into text area that already has some text inside. The inserted string must be in the position of the cursor, and a button for inserting is required. Is there a way to accomplish this with JavaScript? Thx in advance P.S. the text/string that should be inserted is fetched from the ...

how to count and rank data in php as efficiently as possible

I'm not new to programming, but i'm new to MySQL and PHP. I'm wondering what the most efficient way of doing the following. I dont need the actual code, but just the steps. I have a list of user reviews, lets say simply: USER REVIEW Bob nice John good Fred bad Bob poor Bob the best Fred medicre Bob shiny ...

How to do directed graph drawing in PHP?

I'm looking for a way to draw directed graphs in PHP. (as in http://upload.wikimedia.org/wikipedia/commons/0/08/Directed_acyclic_graph.png). I want it to create an image of the graph just like GD can output an image. I've googled a lot on this, but I only can find a lot of libraries for drawing graphs in general (with bars etc), not dir...

How do I output more than 255 characters in an Excel cell using Spreadsheet_Excel_Writer() in php?

I am trying to output a few paragraphs of text in an Excel spreadsheet, but right now the text is truncated to display only 255 characters. The code is pretty straightforward: $xls =& new Spreadsheet_Excel_Writer(); $sheet =& $xls->addWorksheet($name); foreach ($rec as $field) { $rec = ($rec['data'] ? $rec['data'] : $rec); $sheet...

Write php array in HBase using thrift

I have a Thrift php client and I want to write in a HBase table and I'm doing the following: $mutations = array( new Mutation( array( 'column' => 'entry:num', 'value' => array('a','b','c') ) ), ); $client->mutateRow( $t, $row, $mutations ); The problem is that when inserting in HBase the value, which is an ar...

Is Horde an acceptable framework for PHP groupware development?

I'm working on this project and the customer wants it to integrate with a groupware package including bulk email, calendars, and task lists. He has heard about Horde and Horde GroupWare and is interested in using that. Do you have any developer related experience with Horde? If so, then what were your findings? Did you find it to be sta...

PHP: Transform a city, state, country string to proper title case

I've got city, state, country strings like: NEW YORK, NY, US REDMOND, WA, US US HONG KONG CALGARY, CA E. SYRACUSE, NY, US I'd like to transform them to their proper case (New York, NY, US; etc). Whats a quick way to do this in PHP? ...

mail() header problem for html email

I am trying to write a error reporting feature for a website in php. I cannot get the headers right so that the email will display as html. Here is the code: if( isset($_POST['submit']) ) { $browser = $_SERVER['HTTP_USER_AGENT']; $page = $_POST['page']; $email = $_POST['email']; $error = $_POST['error']; $mess...

XML Form validation?

Is there a simple form validation that runs off of an XML file that controls the generation of HTML, Javascript, and PHP would actually follow the rules too? The way its done now i have to split the two up. ...

Finding a sequence of numbers in an array

I'm making a Yahtzee game and I need a way to calculate a small straight (a sequence of 4 numbers in order). So valid ones would be: 1,2,3,4 | 2,3,4,5 | 3,4,5,6. I have an array of 5 numbers and I need to figure out if one of those 3 combinations is in that array. For those not familiar with Yahtzee, there are 5 dice (the five numbers ...