php

Rename pdf file to be downloaded on fly

Given: All the uploaded pdf files on server are prefixed with timestamps. Later user can download these files again. These (ugly)filenames would never change again on server. Question: When I give the option to download PDF file, name of the file looks ugly and lengthy. How can I change this name to something sensible, so that when user...

How to merge this two specific arrays in PHP?

I have this array: $array['apples'][0]['name'] = 'Some apple'; $array['apples'][0]['price'] = 44; $array['oranges'][0]['name'] = 'Some orange'; $array['oranges'][0]['price'] = 10; How can I merge the two arrays so i get this: $array[0]['name'] = 'Some apple'; $array[0]['price'] = 44; $array[1]['name'] = 'Some orange'; $array[1]['pri...

Passing parameters in breadcrumbs

Hi Guys, I'm still a relative newcomer to Zend Framework, so please forgive me if this is a stupid question! I'm using the breadcrumbs view helper in my application's main layout to provide the usual breadcrumb functionality. However I really need the breadcrumbs to contain the parameters passed to the actions that user has clicked o...

XMPP: Connect to GTalk

Hi, Am using XMPP trying to connect to Gtalk to send a message from one of my other gtalk accounts to my main account from a PHP page. I get an error that its unable to connect before timeout. Please advise. ...

PDT autocomplete broken in Eclpise

Suddenly I can't use autocomplete in my Eclipse PHP projects. When I press alt+/ I jsut hear a dummy sound. Which settings should I check? ...

PHP - Simpletest - Comparing numeric strings

Hi, I'm trying to use simpletest to compare two numeric strings, one from an array and one from an object property. I've printed out the values and they are equal, however, the test always returns false. Can anyone help? Here's the code: $this->assertEqual(strval($this->createdforums[$randomforum]), (strval($forum->getTitle))); pr...

How to organize AJAX handlers in a large site?

Simple question...I am using an MVC structure to build my site (its fairly large, so it helps with maintenance. I am now starting to integrate a few fun AJAX functions to spruce things up for Javascript/AJAX friendly users. Since I am so anal about organization, I wanna store my ajax PHP handlers in a way that is logical, secure, and (h...

Cannot modify header information - headers already sent, Why its happening

I Like to call the page using header(), but the following error occurs, Cannot modify header information - headers already sent why?. How to sort it out. Help me. My code is attached if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) { $adduser=new Users(); if($adduser->checkmob()==true) { $adduser...

How can I determine a first-time hit in Wordpress?

For analytics purposes, I need to determine if a user is a first time visitor, and output some Javascript. Preferably I'd be able to do this from the theme editor, not having to edit the code, but if that is the best way to achieve this, that's fine. I was thinking something with the session, but it seems like I would have to hack som...

How to solve this error? session_start() [function.session-start]: Cannot send session cache limiter

Im encountered the above error and strucked up, thinking that for 3 hours. Is there any way to solve this?? ...

Doctrine ORM JOINS

I have a few simple classes, all extending Doctrine_Record. Now I want to make a slightly more complex query with Inner Join, not just table data extracting. I am doing to use DQL, does this oblige me to manually define relation between 2 tables? Should I define this relation class or I better update schema.yml and somehow re-generate...

email div content in php

Hi, Is it possible to take the content that is under a specific <div> and email that content? For example: If I have something like this: <div id="1"> <ul> <li>a</li> <li>b</li> <ul> </div> Basically I want to just reference <div> and take the whole content and email it. is there any way to cache the contents in the div? Is this a...

Adding an array to a MySQL column in SELECT

I have an array with as set of users and their respective karma: $some_array = Array ( [user_id] => Array ( [0] => 4 [1] => 3 [2] => 5 [3] => 1 ) [karma] => Array ( [0] => 129 [1] => 87 [2] => 13 [3] => 20 ...

Cleanup PHP String from Web Form Input

I have a web-form that is getting customer information. The form is processed using PHP 5.1.6 so using the filter_input() will not work. The form has a text area along with some other standard fields. I am getting lots of strange formatting codes that are being stored in our MySQL database. How can I filter these results where they lo...

mysql/php - store html templates within the a database

I am wondering the best way to store html templates in a database where I am able to retrieve them and insert variables. Obviously I could store them as php and then 'EVAL' the record.... but I heard it was evil. is there a better way? :) edit: Sorry I wasn't clear... I tried to simplify it by saying html templates... what I really m...

How do I put into an array the items in a directory?

I have a directory that contains about 2000 text documents and I want to iterate through each one to parse the data. How can I do this? ...

PHP’s open_basedir value giving a binary value in Apache logs

Reviewing logfiles to figure out why my site was down a few days ago, I found hundreds of lines like these (partially redacted with "x"): [Fri Nov 27 23:14:36 2009] [error] [client xxx.xxx.xxx.xxx] PHP Warning: require_once(): open_basedir restriction in effect. File(/var/www/xxx/xxx.php) is not within the allowed path(s): ...

Help with a DB query.

So I have a category table set up. Within this table there is a field called "id", "name","fk_parent_cat_id" (and more). The "fk_parent_cat_id" basically just ties one particular category to a parent category. Ok. That being said, how would I make a query that grabs the information on the category, but ALSO grabs the information on th...

Using multiple platforms in a single project

I'd like to use C#, Java and PHP in an upcoming project. What potential pitfalls should I watch out for? Are there advantages to using multiple platforms for a project? The target development team is people with varying backgrounds working over the internet on this project. Edit: Please be specific and let me know what possible proble...

PHP Converting a date to a timestamp

How do I convert "9/7/2009" into a timestamp, such as one from time()? Do I use strtotime()? ...