php

PHPExcel set specific headers for file format

Hi, While googling I found two different sets of headers that need to be set when outputting excel generated in different file format. for e.g. For Type "Excel5" headers are: header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-dow...

Calculate # of Rowspans and Colspans based on keys in a Multi-Array

Ok, I have these 2 types of layouts, basically, it can be any layout really. I have decided to use tables for this, since using div tags cause undesirable results in some possible layout types. Here are 2 pics that describe the returned results of row and column: This would return the $layout array like so: $layout[0][0] $layout[0][...

Facebook API: How to let the php knows whether the user is a fan of the application or not?

Facebook API: How to let the php knows whether the user is a fan of the application or not? Plan 1: failed is displayed at the html level only.. .it won't let the php level knows whether the user is a fan or not Plan 2: failed has got the same problem too Plan 3: failed fql permission table simply lacked the field of is_fan http://w...

drop down data to appear in form php

I have some data in db,now i m making them to display in the front end so,i ii have a update button,if i click it the selected values to come to database dpaste.com/hold/180863 Thnx in advance. ...

Customize the datetime format in Cakephp

When I use the form helper to make a time input,usaually I write code as follows <?php $options = array( 'label' => '', 'type' => 'datetime', 'timeFormat'=>'24', 'separator'=>'-' ); echo $form->input('Service.endtime',$options); ?> But now I get a problem that I want to make a time input style such as month-day-hour ...

Redirecting a large number of URLs with htaccess or php header

I have undergone a major website overhaul and now have 5,000+ incoming links from search engines and external sites, bookmark services etc that lead to dead pages or 404 errors. A lot of the pages have corresponding "permalinks" or known replacement hierarchy/URL structure. I've started to list the main redirects with htaccess or physi...

Insert string between two markers

I have a requirement to insert a string between two markers. Initially I get a sting (from a file stored on the server) between #DATA# and #END# using: function getStringBetweenStrings($string,$start,$end){ $startsAt=strpos($string,$start)+strlen($start); $endsAt=strpos($string,$end, $startsAt); return substr($string,$startsAt,$...

session_start();echo SID; outputs a blank page on refresh !?

when I run this code for the first time <?php session_start(); echo SID; ?> , I get some thing like: PHPSESSID=9o2bhrqmln2j52caspdhholhk7 but when I refresh I get a blank page Until I remove the PHPSESSION cookie and start a new one ... is that normal or I have a problem ? ...

Zend Form - setting title property of option elements

In Zend Framework how can I set the title properties of option elements within a select? Desired output: <option value="foo" title="bar">option</option> ...

SVN checkout browser

I've been looking all over for a SVN browser. Now I'm not talking about anything like WebSVN or TRAC, I don't want to browse the repository; I want to browse the checkout. I'm looking for a program that lets me browse the checkout (working copy) and shows me the info I'd normally need to SSH for. So I could mark specific files or fold...

Strange PHP reference bug

Hello, I have a really strange bug with my PHP code. I have a recursive code which build up a menu tree with object and one of my customers server can't make it work. Contructor: function Menu(&$menus, &$keys , &$parent, &$menu){ ... if($keys === NULL){ $keys = array_keys($menus); } ... ...

What's the difference between DI and factory patterns?

I have a class which depends on 3 classes, all 3 of which have other classes they rely on. Currently, I'm using a container class to build up all the required classes, inject them into one another and return the application. The simplified version of the container looks something like this: class Builder { private $_options; p...

Cleaning up nasty characters in PHP

Hi folks, Got a little issue where my client is pasting in content from Word into my little text editor in a CMS. The double quotes are coming back encoded in what looks like some form of UTF. Any ideas if I can strip/replace these using PHP when they get displayed out of my mySQL table. Here is the link to the page that spits out th...

html-encode output && incorrect string error

my data includes arabic characters which looks like garbage in mysql but displays correctly when run on browser. my questions: how do i html-encode the output? if i add this to all my files: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> i get this error: Error: Incorrect string value: '\xE4\xEE\xC3\xD8\xEF\xE6...'...

How can I access global variables inside PHPUnit 3.4.9?

I'm trying to write tests for some legacy code with PHPUnit 3.4.9, but it seems that all my global variables are invisible. How can I access global variables inside PHPUnit 3.4.9? ...

Select stats from different days

What is the most efficient way to do this? Right now I am doing it this way.. $m= date("m"); $de= date("d"); $y= date("Y"); $userid = $_SESSION['user_id']; //today $date = date("Y-m-d"); $today = mysql_query("SELECT * FROM cdr WHERE accountcode = '$userid' AND calld...

php 5.3.2 not throwing exceptions

I'm attempting to throw an exception using php 5.3.2 and it is giving me the following error: Parse error: syntax error, unexpected T_THROW I am attempting to throw an exception the following way: throw new Exception('Property ' . $name . ' doesn\'t exist in class Index', ''); Edit: I also tried throw new Exception('Property ' . $n...

why include() don't allow to work setcookie?

i need to set cookies in my page, but it returns Warning: Cannot modify header information - headers already sent by (output started at /home1/bsam/public_html/24kadr/index.php:1) in /home1/bsam/public_html/24kadr/basic_login.php on line 35 on line 1 i have include 'basic_login.php'; but even if i remoove include, ir returns th...

PHP code not working on IE

I have a website with a flag. If it is clicked, the language of the website changes. Here is the code displaying the flag, which is a form with post event: <?php $pagename = $_SERVER['REQUEST_URI']; echo '<form action="'.$pagename.'" method="post"> <input name="formlanguage" type="image" '; if ($_SESSION['lang'] == ...

Keep input from earlier form

I'm a php newbie and im making a small video upload site (very fun :). Anyway How would I do to keep the form inputs for the next part, where you select a file to upload. <form action="upload.php" method="post"> <input type="hidden" name="action" value="step2"> Title: <input type="text" size="50" maxlength="50" value="" name="title" />...