php

Redirecting URL with variable in Zend Framework

Whats the recommended method for redirecting with variables in Zend Framework? Lets say we have an action like this within a controller: public function newAction() { $form = new Form_ApplicationForm(); if($this->_request->isPost()){ $data = $_POST; if($form->isValid($data)){ ...

Including PHP functions from another file

I would like to access some functions defined in another PHP file, but that file also outputs content that I don't want to display. Is there any way to access the functions without "running" the whole file? Perhaps by redirecting the output from that file to somewhere hiddeN? ...

Difference between value = ""; and value = NULL; in PHP ?

What is the difference between value = NULL; and value = ""; in PHP ? Am facing wierd response as if I set value = ""; than I get empty array response from database which is what am supposed to get but if I set value = NULL; than I get empty string response from mysql database instead of empty array response. I am not sure why this ...

php cookies,sessions,mysql

I wound up inheriting a site which seems like it was originally designed to provide access to registered users then decided it wanted public access with the exception of specific restricted features. The access control is decent, however, what's boggling my mind is why anyone would add an entry to their database for each unique visitor....

How can I preg_replace special character like 'Prêt-à-porter' ?

There are heaps of Qs about this on this forum and on the web in general. But I don't just get it. Here is my code: function updateGuideKeywords($dal) { $pattern = "/[^a-zA-Z-êàé]/"; $keywords = preg_replace($pattern, '', $_POST['keywords']); echo json_encode($keywords); } Now, the input is Prêt-à-porter, and the output i...

PHP search a string for a email address

Hi Im attempting to search a string to see whether it contains a email address - and then return it. A typical email vaildator expression is: eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email); However how would I search if that is in a string, for example return the email address in the string: "...

Copy entire contents of a directory to another using php

Hello, I tried to copy the entire contents of the directory to another location using copy ("old_location/*.*","new_location/"); but it says it cannot find stream, true *.* is not found. Any other way Thanks Dave ...

Facebook Ajax.post fails after calling Facebook.showPermissionDialog

I have a situation where I call Facebook.showPermissionDialog('offline_access'...) then later I make an ajax.post call. The ajax.post call fails if the call to the permission dialog was made prior. But it succeeds when the permission dialog was not called prior. Is anyone aware of some relationship between this dialog and ajax.post? If...

Incorrect MD5 checksum after downloading with CURL in PHP - file_get_contents works fine

Hi everyone I have a script where I have to download some files and to make sure that everything worked fine I'm comparing MD5 checksums. I have found that the checksums are not correct when downloading with CURL. The script below demonstrates this. It downloads the Google logo and compares checksums. $url = 'http://www.google.com/in...

latest visitors

Say you want to display the latest visitors on a users profile page. How would you structure this? Perhaps a table called uservisitors: userid (the user that gets a visit) visitorid (the visitor) time And how would you select this with mysql? Without any duplicates, What I mean is if User 1 visits user 2's profile, then 5min later v...

Pseudo-Continuous Scrolling

I would like to display a large number of results without multiple "pages" to load results "0-99" on page 1, "100-199" on page 2, "200-299" on page 3 etc. Thus my idea is to create a sort of pseudo-continuous scrollable data list. So essentially, data would be loaded as necessary but only if scrolled to. The box of data would then woul...

Is there the equivent of a Java Set in php?

Is there the equivalent of a Java Set in php? (meaning a collection that can't contain the same element twice) ...

Drupal theme() problem

I am trying to display a custom page the same as my search results page by re-using the theme functions and pre-processors built into the search module. With an empty Drupal cache this works beautifully. I simple call theme('search_results', $results, 'node' ); with a correctly popuated results array, and I get back formatted markup...

In Zend Lucene, how can I change the field which a query searches?

I am trying to create an "advanced search", where I can let the user search only specific fields of my index. For that, I'm using a boolean query: $sq1 = Zend_Search_Lucene_Search_QueryParser::parse($field1); // <- provided by user $sq2 = Zend_Search_Lucene_Search_QueryParser::parse($field2); // <- provided by user $query = new Zend_Se...

How to remove all links from a mixed string with php

Hello, i have a variable in php can be like this : $string = "hello check out this http://xx.xx/xxx & thanks !!"; i want a function to strip that link and remove it from the string, the url can be with WWW. or without it. also, this variable can contains multiple urls . Thanks ...

Porting code that used SimpleXML to Dom in PHP

I have a class that extends PDO to give it the ability to pull the configuration from an xml file. Unfortunately the our hosting provider has disabled SimpleXML so I need to refactor my code to use Dom, which is available. I am using the following code: class xmlPDO extends PDO { public function __construct($xml_uri){ $xml...

Filter Magento Product Collection for Products with Images

I have a product collection that I am getting from a configurable product, and I want to filter that collection to only include products that have images attached to them. How do I go about this? Code looks something like this: $configurableProduct = $this->getConfigurableProduct(); $childProducts = $configurableProduct->getTypeInstanc...

Zend form and Zend filter HtmlEntities

Hi. I have a registration form with a few fields. One of them looks like this: $first_name = new Zend_Form_Element_Text('first_name'); $first_name ->setLabel("First name") ->setRequired(true) ->addFilter(new Zend_Filter_HtmlEntities()); I use the same form for editing user's deta...

Strip All Urls From A Mixed String ( php )

Hi, i reposted this question because i didn't find a good answer. i have a string which can contains text with urls. i want a function to strip all urls from this string and just let the text. by example the string can contains like this : 1) hey take a look here : http://xxx.xxx/545df5 this is nice! 2) hey take a look here : http:/...

dynamically change mysqli connection timeout in PHP

Hi, how can I dynamically change MySqli connection timeout using PHP? I found the following manual that you can set an option after a connection is opened, but it says it only support Windows since PHP 5.3.1: http://www.php.net/manual/en/mysqli.options.php I'm using PHP5.2.4, MySQLi (improved version) the default connection timeout is...