php

PHP Memory Limit 25MB Exhausted - File Upload/Crop/Resize

I'm using a single image upload/crop/resize script for files up to 10MB. When testing, I set php_ini memory limit to 25M and that is exhausted when uploading a file only about 1.4MB. "Allowed memory size of 26214400 bytes exhausted (tried to allocate 10368 bytes)" This seems strange to me, isn't 10368 < 26214400? (Rhetorical Questi...

PHP Countdown to Date

How could set a date and get a countdown in PHP? For example if I set the date as 3 December 2PM it would tell me how many days and hours are remaining. No need for user inputs for the date as it will be hard coded. Thanks. ...

Directory structre change using .htaccess

I want to move all my web site files (even including index.php) into a subdirectory (for exp: "abc") For example BEFORE: public_html index.php a.file directory an.other.file ... AFTER: public_html abc_directory index.php a.file directory an.other.file ... I want everything to work, as it was before, but i ...

Is there garbage collection in PHP?

I know that in PHP you don't have to free memory. Is it reached by garbage collector? ...

What is the "right" Way to Provide a Zend Application With a Database Handler

Assuming you're hewing closely to the conventions of a ZendApplication, where should you be setting up a database handler for application developers to access? I know how to setup a ZendDb adapter. What I want to know is, in the context of the Zend Framework, how should developers be instantiating their DB handlers so they don't have t...

PHP File Upload Workaround for Recent Flash Vulnerability

There was a recent Flash vulnerability found that allows for the potential of malicious attacks when someone uploads a flash file or a file embedded with flash (for example, a gif overloaded). According to the article, even a simple image can be hijacked. In php, the typical ways of checking a file type are by extension, and by mime-ty...

Magento - Displaying Configurable Product Options under a Grouped Product

Hi All I am trying to create a grouped product by grouping some configurable products. I know it is possible. The grouped products attributes should be set to Not Required. This is found on Inchoo's website. What I am trying to achieve here is that, I want to show the options of the configurable under the grouped products grid. For ex...

MVC in PHP without the "magic"

Let's say I have a PHP Model-View-Controller framework that maps an address like http://site.com/admin/posts/edit/5 to an action that looks like Posts_Controller::editAction($id) in file /admin/controllers/posts.php Now, many existing PHP frameworks that I've looked at would accomplish this by something similar to $module = Router::...

PHP preg_replace text variable

I want to echo a string with the variable inside including the ($) like so: echo "$string"; I dont want it to echo the variable for string, I want it to echo '$string' itself, and not the contents of a variable. I know I can do this by adding a '\' in front of the ($), but I want to use preg_replace to do it. I tried this and it doesn...

Construct a Magic Square by a given number of rows

Hi! I'm trying to build an application in simple PHP but could be done in any language. I want the user to enter number of rows and the output will be the magic square of it. For example, for $rows=3: 8-1-6 3-5-7 4-9-2 Notice that in every row,column,diagonal the sum of numbers is equal to 15. There is a method for constructing thi...

Does php mail need configuration to work?

I'm trying to do a very simple mail form in PHP but get the error: PHP Notice: Undefined index: in /var/www/html/sites/send_contact.php on line 10, referer: http://example.com/contact2.php My PHP file looks like this: <?php // send_contact.php // Contact subject $subject =$_POST["$subject"]; // Details $message=$_POST["$detail...

PHP regex not new line

How do I have a regex statement that accepts any character except new lines. This includes anything but also includes new lines which is not what i want: "/(.*)/" ...

how to use php mail on fedora

I'm running fedora core 9 with php 5.2.6. I want to send a simple email from a form using the php mail command. Do I need to configure my system to be an smtp server? If so do I have to load something like pear? I've read that pear is installed by default. however when I go to /usr/lib/php/pear , the folder is empty. When I go to...

PHP: fastest way to check for invalid characters (all but a-z, A-Z, 0-9, #, -, ., $)?

I have to check the buffer input to a PHP socket server as fast as possible. To do so, I need to know if the input message $buffer contains any other character(s) than the following: a-z, A-Z, 0-9, #, -, . and $ I'm currently using the following ereg function, but wonder if there are ways to optimize the speed. Should I maybe use a diff...

Why is the jquery multi upload plugin not uploading?

I am using the multi-upload plugin found at: http://www.fyneworks.com/jquery/multiple-file-upload/ This is what I am doing: These steps will reproduce the problem: Create a file input field, add 'multi-upload' as the class and 'images[]' as the name Use the input field to select an image and redirect to upload.php page via the action...

PHP Accessing the user's country (locale)

Is there a superglobal reference to the user's country or is using the IP against a database of IP to Country lookups the best way to go? ...

PHP not change color in quotes

I want to change the color of text inside single quotes, but i have also want to change the color of parenthasis as long as they arent in quotes. this is what i have but its not working as planned. "/([^'])\((.*?)\)([^']+)/is" => "$1<span style=\"color: ".$ccode['green']."\">(</span>$2<span style=\"color: ".$ccode['green']."\">)</span>$...

Is there a way to get the full contents of the address bar in php or htaccess?

Specifically. I am making an ajax app and trying to preserve the back button. My javascript is working properly and registering a new url in the address bar with an anchor-like hash in the url: http://t2b.localhost/#/clients/ I can catch the url when the page loads with javascript and load the "clients" page, but I want to know if ther...

Paginator Class

Hi,everyone. I am working on a site with smarty templates using php and a mysql database. This is a more specific question than my first one which asked how to pass methods to a class. I thought it would be easier to repackage the question than edit the old one. I have written a paginator script for my image gallery which displays imag...

search tags like stackoverflow?

how do you code a search box like the one in Tags where you enter a tag name and all tags are showing immidiately without you press enter. can someone link me a script or tutorial for that. is it javascript or jquery? does it involve ajax? and does it search in the database for tags? or is it searching through a xml file with tags? ...