php

How do I escape a new line character in a .ini file so that Zend_Config_Ini reads it literally?

I am trying to store a multiple line e-mail in an ini file using PHP/Zend Framework. My string has new lines characters in it, and when I use Zend_Config_Ini to parse the ini file, the new line characters come back escaped, so they are printed out on screen, instead of a line feed. Example: // ini file message = Hi {0},\n\nThis is a te...

Remove leading zeros from abbreviated date with PHP

Hello, I was wondering if there is a way, using PHP, to change this date format: 01.08.86 (January 8, 1986) to this format: 1.8.86. ...

How can I employ "if exists" for creating or dropping an index in MySQL?

I was wondering if there's a way to check if an index exists before creating it or destroying it on MySQL. It appears that there was a feature request for this a few years back, but I can't find any documentation for a solution. This needs to be done in a PHP app using MDB2. ...

Is it possible to create a link that acts like a button and can carry out a function when clicked?

In PHP, I want to execute a function when a hyperlink is clicked. The only way I can think of doing this is by having the link attach a get parameter to the url when clicked and by doing an if statement that checks to see if that parameter exists and if so then have the function executed. But is there a way to do this like: <a href='#'...

Anonymous recursive PHP functions.

Is it possible to have a PHP function that is both recursive and anonymous? This is my attempt to get it to work, but it doesn't pass in the function name. $factorial = function( $n ) use ( $factorial ) { if( $n == 1 ) return 1; return $factorial( $n - 1 ) * $n; }; print $factorial( 5 ); I'm also aware that this is a bad way t...

Get width of a single character from ttf-font in php?

Hello I'm creating an dynamic image, which creates headers on my page using PHPs GD-library. The problem is, that I need a line-wrapping system. It's not a problem itself, but first I need to get the width (in pixels) of current character. I'm pretty curious about this, is there any way? Or do I need to manually specify width of every ...

Change date format (in DB or output) to dd/mm/yyyy - PHP MySQL

MySQL stores the date in my database (by default) as 'YYYY-MM-DD' The field type for my date is 'DATE' (I do not need any time storage).. Is there a simple way to change it by default to DD/MM/YYYY ? I call up different dates in 2 different tables, and no where in any of my code do I have anything resembling a date variable or anything!...

Live search results as you type... am I going about this the right way? jQuery + PHP

This is my first time building a tool like this, so please bare with me. I'm doing this to learn more about jQuery and AJAX. Basically, I have a search input and a hidden div. When you start typing in the search input, the hidden div becomes visible and results are brought in. In this case, I'm searching for client names. It all works ...

How do I go about setting up an application so that it has a persistent process in memory and does not have to re-initialize to run?

I'm not sure what's the appropriate terminology here, but I'd like to have an application running passively that is ready to accept commands without having to reinitialize the whole thing. The precise application is a machine learning system written in Python that takes a somewhat long time to train a classifier or to load a cached clas...

change password code error.......

I've created a code to change a password. Now it seem contain an error. When before I fill in the form to change password.the error is: Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\e-Complaint(FYP)\userChangePass.php:7) in C:\Program Files\xampp\htdocs...

Is there a CKEditor PHP drop-in for editing a site (psuedo cms)?

I like CKEditor and my server uses PHP. I want to use CKEditor to edit the static HTML pages. Is there something that I can drop in that will give me a file browser and let me click a file and edit in CKEditor and save? Image upload would be nice but optional. ...

How can I test caching and cache busting?

In PHP, I'm trying to steal a page from the Rails playbook (see 'Using Asset Timestamps' here): By default, Rails appends assets' timestamps to all asset paths. This allows you to set a cache-expiration date for the asset far into the future, but still be able to instantly invalidate it by simply updating the file (and he...

How to handle redirections with codeigniter?

Hi, im having problems starting a codeigniter project, the problem is that when i do something in a controller and then i want a page to display the result, an example: i have a form to add a item to the database, i get all the data in the controller and save it to database and then i want (if all went well) to redirect to the main page ...

Returning errors from AMFPHP on purpose.

When using flash remoting with amfphp, what can I write in php that will trigger the 'status' method that I set up in my Responder in Flash? Or more generally, how can I determine if the service call has failed? The ideal solution for me would be to throw some exception in php serverside, and catch that exception in flash clientside......

Multiple page technique

Six years ago I wrote an large web application. It was my very first php program, and it grew, and grew. I used a lot of forms, and some very (atrocious) techniques to give an AJAX "look" to the site, and to handle multiple users with various permissions. I am looking to expand this, and sell it to other companies in the field, but I ...

can bind successfully to the ldap server, but needs to know how to find user w/i AD

I create a login form to bind to the ldap server, if successful, it creates a session (which the user's username is stored within), then I go to another page that has session_start(); and it works fine. What I want to do now, is add code to test if that user is a member of a specific group. So in theory, this is what I want to do if(u...

Submiting a Form without Refreshing the page with jQuery and Ajax Not updating MySQL database.

I'm a newbie to JQuery and have a problem, when I click submit button on the form everything says registration was successful but my MYSQL database was not updated everything worked fine until I tried to add the JQuery to the picture. Can someone help me fix this problem so my database is updated? Thanks Here is the JQuery code. $(...

problem with seting GET value

in my site i want to set default page to open, using this script if (!isset($_GET)) { $_GET['id'] = "home"; } when i open index.php it must set $_GET['id'] = "home" but it doesn't work. can somebody explain why? ...

PHP Round Minute to nearest Quarter Hour

I need to round times down to the nearest quarter hour in PHP. The times are being pulled from a MySQL database from a datetime column and formatted like 2010-03-18 10:50:00. Example: 10:50 needs to be 10:45 1:12 needs to be 1:00 3:28 needs to be 3:15 etc. I'm assuming floor() is involved but not sure how to go about it. Thanks ...

retrieving data from memcache

Hello, I am starting to learn the benefits of memcache, and would like to implement it on my project. I have understood most of it, such as how data can be retrieved by a key and so on. Now I get it that I can put a post with all of its details in memcache and call the key POST:123, that is OK, and I can do it for each post. But how t...