php

Installing cake php on xampp

I've got xampp installed on my laptop runing XP, and it's been running without any problems for ages. I've just tried installing cakephp, and have altered the database config and enabled mod_rewrite. But now I get the following on the welcome page: Your tmp directory is writable. The FileEngine is being used for caching. To ...

My xpath/php output needs to show the tags

I'm trying to get an xpath xpression that will remove my outer tag, but it's removing that, plus the inner tag and printing the element data. How do I get it to print my prompt tags also? Hope someone knows... My php looks like this: <?php #get file $xml = simplexml_load_file('content.xml') or die ("Unable to load XML string!"); #lo...

[PHP] How to combine words of a sentence to composed terms?

Hello! I have a sentence, for example John Doe moved to New York last year. Now I split the sentence into the single words and I get: array('John', 'Doe', 'moved', 'to', 'New', 'York', 'last', 'year') That's quite easy. But then I want to combine the single words to get all the composed terms. It doesn't if the composed term...

Encoding PHP Tags for Security?

Kohana and Codeigniter both have encode_php_tags(). I understand XSS cleaning (for Javascript), but when and why would you use encode_php_tags()? What is the security threat? ...

how to get string between [LOOP]...[/LOOP]

how to get string between [LOOP]...[/LOOP] i try this but not work $gloop = preg_replace('/\[LOOP\]([^\[]*)\[\/LOOP\]/', '\\1', $var); ... string: '<tr> [LOOP]<th scope="col">%Gdata_All%</th>[/LOOP] </tr>' but i would string in [LOOP]...[/LOOP] ...

PHP syntax for dereferencing function result

In every other programming language I use on a regular basis, it is simple to operate on the return value of a function without declaring a new variable to hold the function result. In PHP, however, this does not appear to be so simple: <?php function foobar(){ return preg_split('/\s+/', 'zero one two three four five'); } // can ...

What's wrong with my PHP array?

$genreList; function directorGen($array) { foreach($array as $value) { $genreList[] = $value; } } //later.. directorGen($title->genres()); This code results in a NULL array. If I replace $genreList[] = $value with echo $value everything prints out like expected. Any ideas? ...

How to edit and watermark animated gifs, preferably through php?

Ive been looking everywhere for something that could manipulate animated gif files, server-side, preferably through php, but simple command line tools that could be executed via exec() would do also. Essentially Im looking to watermark animated gif files, as well as have the ability to cull frames out of animations (every 2nd, 3rd frame ...

php: trim <br>  from the end of a string?

how can I trim <br>&nbsp; from the end of a string? ...

Live update notification on database changes MYSQL PHP

I was wondering how to trigger a notification if a new record is inserted into a database, using PHP and MySQL. Thanks. ...

Unserialize in Java a serialized php object

Hey guys, Does anyone know if it is possible, actually if it has been done, to serialize an object in php and unserialize it in Java (java-php communication). Maybe an adapter will be needed. What do you think? Thanks ...

How to get Time Zone through IP Address in PHP

Hi, I want to get time zone through IP Address in PHP. Actually i have an application which will run at the client machine. I have IP address of client machine. But not able to get the time zone for each client machine. Please reply me. Thanks Devesh M ...

Determine where a function has been called with PHP

Hello, do you guys know how can i determine from what file was a function called inside of that function? I was thinking of using debug_backtrace .. but that does not look as an elegant way to do it, and they also enumarate other reasons in another question here So what other alternatives are there ? thanks a lot ...

Sort a mysql table using php,ajax and jquery

Hello Everyone Ok here is the deal i am building a messaging system by php,ajax,jquery and mysql i add the new message and i add in 2 rows now what i want to do is to send an ajax request to server and recieve an updated version of the table but sorted So how can i do so //here i add and call the message the message function addMsg()...

PHP/MySQL: Convert from YYYY-MM-DD to DD Month, YYYY?

Hi, I have in a MySQL table a DATE column that represents the date in this format: YYYY-MM-DD. I wanto to retrieve the date from the database using PHP but display it like this: DD Month, YYYY. From '2009-04-13' to '13 April, 2009' for example. Witch is the best way to do it?? ( I know how to get the date from the DB. I only need to k...

PHP 404 error page won't display content

Hi there, I'm having a problem implementing custom 404 error pages on my Windows/IIS/PHP webhost. Whenever I try to send the 404 status message in the header no content is sent to the client and a blank page is displayed instead. Here is a very simple script I'm using: <?php header('HTTP/1.1 404 Not Found'); header('Status: 404 No...

Passing an Array as Arguments, not an Array, in PHP

I seem to remember that in PHP there is a way to pass an array as a list of arguments for a function, dereferencing the array into the standard func($arg1, $arg2) manner. But now I'm lost on how to do it. I recall the manner of passing by reference, how to "glob" incoming parameters ... but not how to de-list the array into a list of a...

Possible PDOException Errors (MySQL 5)?

So I'm setting up an installer for my web app, and have input fields for database credentials. Part of my validation process includes testing the database connection (using PHP's PDO library). If the connection fails, I want to be able to differentiate between a bad password, bad address, nonexistent database name, etc. so I can referenc...

How does one unit test the addition of a row to a database with Zend Framework & PHPUnit?

To test inserting/update of a row, I've written a test to simulate a post, to check that it redirects, and to check that the newly inserted/updated text is on the page. The code works, but not the test - can you tell me why it's wrong? public function testEditProduct() { $request = $this->getRequest(); $request->setMethod('POST...

Timezone in PHP

PHP seems to use a rather annoying method for setting the evnironment timezone, using region names rather than the GMT offset. This makes having a timezone dropdown a huge pain, because it either has to be huge to accommodate all possible PHP timezone values, or I have to find a way to convert a GMT offset to a valid value to pass to PHP...