php

Shared data multiple sites

I have recently taken on a php web developer position for a large firm. They have multiple sites that share much of the same content (mainly news articles). All the sites although written in PHP, the content is static and manually edited on all the sites when a news article is added or other information is changed. The "senior programme...

doe anyone know of a free tool or how to convert an rtf to a jpg

I have an RTF file that I need to display to a user. I know that I need to convert it if I want to display it in the browser. I would like to be able to convert it to JPG so that I can take advantage of other code that I am using that uses ImageMagick to convert JPG to PDF. ImageMagick will convert a PDF to a JPG, but not an RTF :( I...

constants class in php

Hello, I once heard it's good to have one class with all your application constants so that you have only one location with all your constants. I Tried to do it this way: class constants{ define("EH_MAILER",1); } and class constants{ const EH_MAILER =1; } But both ways it doesn't work. Any suggestions? ...

Best way to embed Login Form in Zend Framework pages

What is the best way to embed Login Form into several pages in Zend Framework? Currently I have two controllers, LoginController for separate login form and IndexController for actions on index page. I need to include Login Form into index page to let users log in both from the front page and from Login page. My current solution is to...

Simple Paypal IPN examples?

I would like to have a text input form with a submit button that goes to paypal, upon payment the contents of the form should go in a mysql database.. This sounds trivial, but I'm having such a hard time with paypal's IPN. Can anyone point in me in the right direction? Thanks! ...

E-mails sent through php5+htmlMimeMail are being received with random characters replaced with =

Hi all, currently using PHP5 with htmlMimeMail 5 (http://www.phpguru.org/static/mime.mail.html) to send HTML e-mail communications. Have been having issues with a number of recipients seeing random characters replaced with equals signs e.g.: "Good mor=ing. Our school is sending our newsletter= and information through a company called......

Passing $_GET[] parameters to a script with Jumi?

I am using Jumi to include a number of PHP scripts on Joomla! articles and it works great. The problem I am having is with passing variables (in the form of $_GET parameters) to a PHP script. Lets say I have a script "index.php" and I wish to pass the $_GET[] parameter "var" with the value of "10". This would normally be accomplishe...

How do you perform a preg_match where the pattern is an array, in php?

I have an array full of patterns that I need matched. Any way to do that, other than a for() loop? Im trying to do it in the least CPU intensive way, since I will be doing dozens of these every minute. Real world example is, Im building a link status checker, which will check links to various online video sites, to ensure that the vid...

Can I install the memcached PHP extension with PECL?

I'm having trouble installing the "memcached" PHP extension from PECL, though I can successfully installed the "memcache" extension. (They are separate PHP extensions.) For example, these commands work okay: $ sudo pecl install memcache $ sudo pecl install APC $ sudo pecl install oauth However, attempting to install memcache...

PHP removing text in a link

How do you strip/remove wording in PHP? I have a form that's passing a full URL link to an output page. Example: maps/africa.pdf And on the output page, I want to provide an "href link", but in PHP use that same posted URL, but strip off the "maps" and have it provide a link that just says africa. Example: africa can this be done?...

CodeIgniter 1.7 Auth Library

Trying to find an Auth library for CodeIgniter 1.7.x but am not having much luck. I originally found this SO post: http://stackoverflow.com/questions/346980/what-code-igniter-authentication-library-is-best which listed several, but most were either too simple and/or were designed for CI 1.5.x I've played with FreakAuth, UserAuth, Redux,...

jquery $.GET multiple calls

I'm learning jquery and wrote this so I can do two seperate $.GET to a php file, retrieve some info and do some calculations on it. I understand I could create one specific php file that does everything and returns the value I need, but I thought it would make more sense to reuse this php file any time I need to retrieve info. I have...

Best practice for naming an argument that can mean 3 different things

Consider this... I am writing a class named Cache which will accept either a path to a file/url or a string. I am going to use PHP's functions such as parse_url() and is_file() to determine which input I am receiving. here is my example, in PHP class Cache { public function __construct($pathUriOrString) { } } What is the bes...

Debug a DOMDocument Object in PHP

I'm trying to debug a large and complex DOMDocument object in php. Ideally it'd be nice if I could get DOMDocument to output in a array-like format. DoMDocument: $dom = new DOMDocument(); $dom->loadHTML("<html><body><p>Hello World</p></body></html>"); var_dump($dom); //or something equivalent This outputs DOMDocument Object ( ) ...

encode array to JSON in PHP to get [elm1,elm2,elm3] instead of {elm1:{},elm2:{},elm3:{}}

I am trying to json_encode an array, which is what returns from a Zend_DB query. var_dump gives: (Manually adding 0 member does not change the picture). array(3) { [1]=> array(3) { ["comment_id"]=> string(1) "1" ["erasable"]=> string(1) "1" ["comment"]=> string(6) "test 1" } [2]=> array(3) { ["comme...

How do I check a table to see if a string is already in use?

I am using this code to check my username column (username is primary) in my userdb table to see whether or not the string is already there. If it isn't there then it adds the string entered from a previous form into the username column in my table. But if it is there then it says "(Username) is already in use!". This works when I put a...

Problems with encoding Json request

I try to manually build a Json string to send to the client. {'result':'hhh'} When I use echo json_encode(array('result'=>'hhh')); It arrives perfectly. But when I do echo "{'result':'hhh'}"; It isn't The only difference I find between the two requests is that the first one has: Content-Length: 9 header and the second o...

Should I use "id" or "unique username"?

I am using PHP, AS3 and mysql. I have a website. A flash(as3) website. The flash website store the members' information in mysql database through php. In "members" table, i have "id" as the primary key and "username" as a unique field. Now my situation is: When flash want to display a member's profile. My questions: Should Flash pas...

Convert PHP array string into an array

I have an array: $myArray = array('key1'=>'value1', 'key2'=>'value2'); I save it as a variable: $fileContents = var_dump($myArray); How can convert the variable back to use as a regular array? echo $fileContents[0]; //output: value1 echo $fileContents[1]; //output: value2 ...

Batch script to replace PHP short open tags with <?php

Hello everyone, I have a large collection of php files written over the years and I need to properly replace all the short open tags into proper explicit open tags. change "<?" into "<?php" I think this regular expression will properly select them : <\?(\s|\n|\t|[^a-zA-Z]) which takes care of cases like <?// <?/* but I am not s...