php

uploading a zip file causes some problem for some users - weird mime type

I have a form where the user can upload a zip file, it works perfectly on my side but the client I'm making the website for is not able to upload the zip. I check for the mime type and normally it should work for her to but the problem is that her mime type looks like this: application/octet-stream/" why is there a /" ? anyone experie...

Using -> instead of direct function call

In some classes I see a call to a function is like: $this->ClearError(); When the function is residing in that class itself. How is the above approach different from a direct function call like: return ClearError(); ...

Regex for parsing .strings files

I need a PHP Regex that can parse .strings files. In particular, it needs to be able to handle comments, blank lines, escaped characters and angle brackets. Example of a .strings file: /* string one */ "StringOne"="\"1\""; "StringTwo"="<2>"; /* Bob Dillon */ "Bob"="Dillon"; By request, the desired output would be something such as:...

XSLT / Xpath: Selecting a preceding comment

I have XML in the following format which I want to reformat: <blocks> <!-- === apples === --> <block name="block1"> ... </block> <!-- === bananas === --> <block name="block2"> ... </block> <!-- === oranges === --> <block name="block3"> ... </block> </blocks> My problem is I can't figu...

How to store the timezone?

Hi i am using PHP to store the timezone.The timezone coming from dropdown and when I try to store it if its (GMT+5.30) or (GMT+anything) the plus symbol doesnt stored on database.It stored as (GMT 5.30).How can I store it correctly? ...

Abstract class 'n Interface, specifically in PHP

This question is in continuation to my previous post located here. Since there is no way to post code sample again without editing your original post, I am starting a new post. And also, this contains PHP code. I am writing two classes, first is for opening and closing connection to the database, and the second is to provide various r...

get top 3 result from foreach loop in smarty

I have an array to loop in smarty. My array look like this: Array( [0]=>( [title] = 'some title' [url] = 'image url' ) ).... I loop it in file .tpl and I just want to get top 3 result from this array. My array has the number of item larger than 3. I'm a beginner of smarty someone help me fix this problem. Thank you ver...

getting posts from Wordpress to out of WP in codeigniter view

Hi friends, I use codeigniter and need to display last 3 posts at footer from blog as blabla.com/blog located. when I create a test.php file as below. it works well, test.php <?php // Include Wordpress define('WP_USE_THEMES', false); require('./blog/wp-blog-header.php'); query_posts('showposts=3'); ?> <ul> <?php while (have_posts...

Is it possible to upload image to server without submitting the form?

I have a file field in my form. I want the user to be able to choose an image, press OK, and then without submitting the form, preview the image in a smaller resized way. If everything is to the satisfactory of the user, then hit submit and the image as well as the form is submitted... How would you good professionals do this basically...

Execute PHP code after something is displayed in the browser

I want code in a php5 page be executed after all of the page (or maybe even after the first part of the page) is displayed. I would prefer no javascript and no frames / iframes and no redirects. Just one page written in php, only emitting html. I remember some special function in php5 to register a callback function that will be execu...

correct arguments format for strtotime

Hi, I've been using strtotime("$day-$month-$year"), in my app and it works cool... but know I want to make some date comparisons still in this format but I'm not sure about what is precise, It's as if any format goes ...

PHP admin screens for Flex objects

I am creating Flex application that will call PHP via Zend_Amf. It's basically CRUD operations with file uploads sometimes. This will require to create admin screens for PHP side (for editing various records on server) automatically, using scuffolding. It seems that CakePHP would do well at generating admin screens. How well does Cake...

PHP last day of the month

How can I get the last day of the month in PHP? Given: $a_date = "2009-11-23" I want 2009-11-30; and given $a_date = "2009-12-23" I want 2009-12-31. ...

PHPMailer Content-Transfer-Encoding

If i send any mails with Content-Transfer-Encoding - 8bitm those mails will be send with Content-Transfer-Encoding: Quoted Printable! I can't find any solution for this, and it's getting frustating. ...

How to make sure the user cannot interrupt execution of php code called by "register_shutdown_function"?

How can I make sure that some code, that is executed in a php shutdown function, that was registered via "register_shutdown_function" is also executed, if the user leaves the page or closes the tab or the whole browser of that page, before the shutdown code is executed, but after the page is displayed? I just want to make sure the user ...

Class call a function in another class....

I have a class like: <?PHP abstract class dbCon { public function OpenConnection() { // Do Something; // On error: $this->ShowError(); } abstract function ShowError(); } class ErrorHandling extends dbCon { public function ShowError() { // Show error } } ?> There is a ...

Avoiding many try...catch blocks

I have various functions in a class. In each function I use try...catch. Is there any way to simplify this? I want to make one error class and it must be accessible from any file in my project. I don't want to use try..catch in each function, rather it should be automatically directed to the Error class. ...

PHP 'end date' from a given 'start date' - last day/15th of the following month

I'd like to get an 'end date' from a given 'start date' in PHP. End date is based off the start and are calculated as follows: If Start date is from the 1-15th of the month, End date is the 15th of the following month. If Start date is from the 16-31 of the month, End date is the last day of the following month. eg: $start_date = '20...

working with dates

Hi. I was wondering if anyone would help with the following: I have a date called into a function in php. I need to estrapolate the month form this date in order to make some calculation base on the month only. I really have no idea how do go about it. I have tried few things but none works. It there anyone who can give a clue? Appre...

Problem with Zend_Date and ISO_8601 format

Frankly, I'm flummoxed. Can anyone tell me why I would get a failure message with this code? $date = Zend_Date::now(); $date = $date->getIso(); if(Zend_Date::isDate($date, Zend_Date::ISO_8601)) { print('success'); } else { print('failure'); } exit; It also fails if I just pass in a Zend_Date object. UPDATE: a var_dump of...