php

in php how do I use preg replace to turn a url into a tinyurl

I need to convert a string of text containing a long url into the same string but with a tinyurl (using the tinyurl api). eg. convert "blah blah blah /http://example.com/news/sport blah blah blah" into "blah blah blah http://tinyurl.com/yaeocnv blah blah blah". How can it be done? PLEASE NOTE I added a slash before the long url as I'm o...

How to use URL Rewrite on IIS for a single code base for multiple sites in PHP.

I have used the Apache Mod Rewrite for PHP but not in IIS. BACKGROUND: I have inherited over 400 sites on IIS with PHP all with a copy of the identical code base. The current code base has a unique connection string per client and that is why it was copied over and over again. Each being a subdomain pointing an individual site in IIS:...

Recursively MySQL Query

How can I implement recursive MySQL Queries. I am trying to look for it but resources are not very helpful. Trying to implement similar logic. public function initiateInserts() { //Open Large CSV File(min 100K rows) for parsing. $this->fin = fopen($file,'r') or die('Cannot open file'); //Parsing Large CSV file to get dat...

Problem with PHP; Posting Hidden Value!!?

Hi, I have a page which basically allows an admin user to create manager user types (basically a register function. So when the values are submitted, they are stored into the DB, very very basic stuff. However, I have a hidden variable type..reasons are I have 3 different user levels and I have declared they identification as an integer...

Wordpress > Exclude specific categories from categories listing

I have created some functional categories that I use to show/hide markup elements. However, when I go to list the legit categories, these show up too, which I would expect. I want to list the legitimate categories and omit others. I need to know how you would do it under two circumstances.... 1) Each category that I want to exclude is...

conditional while loop in php?

I'm pretty sure there's an obvious answer for this-- hoping someone can help me-- I need to do a PHP while loop, but only if a variable is true. And I can't really put the while loop in an "if" statement, which seems like the obvious thing to do, since the code block is huge and it would be ugly and confusing. Do I need to break out th...

Quee operations on Apache with PHP (Run in the background)

Hi. I want to be able to in some way "quee" operations on Apache web server with PHP. For example I want to create a loop like this: <?php foreach($files as $key=>$value){ download($value); } ?> The "download" function just runs wget and downloads the file to a specified position. This is working OK but my problem is that during this...

HTML Select selected value in php variable

Hi, I have a drop down in html. When I change the value of the drop down I want to store the selected value in a php variable How can i achieve this ? ...

Where can I find a free image-uploader library/service?

Where can I find an image uploader similar to the one here? I need this to work with PHP or RoR. ...

Visual PHP GUI IDE

Does anybody know of a reliable, well-made tool for creating standalone desktop applications complete with GUI, using just PHP, or primarily PHP? I enjoy the R.A.D. and many other aspects of PHP and would like to use it for some non server/client projects. ...

Locking a detail view if a user is editing the item...

Hi All I am developing a user manager which must control access to the detail view of editable items. At present, when a user clicks 'edit', the application queries the link table to check if a user is currently editing that page, if not, it allows access to the page and then inserts a record into the link table preventing another user ...

PHP: How to copy elements from an associative array and place them at the beginning of the array?

I have an array of countries that I will be using in a select menu: array( [0] => " -- Select -- " [1] => "Afghanistan" [3] => "Albania" [4] => "Algeria" [39] => "Canada" [47] => "USA" ) //etc... I want to copy create copies of the Canada and USA entries and place them at the front of my array. So the array sho...

Connect xampp to MongoDB

Hello I have a xampp 1.7.3 instance running and a MongoDB 1.2.4 server on the same machine. I want to connect them, so I basically have been following this tutorial on php.net, it seems to connect but the cursors are always empty. I don't know what am I missing. Here is the code I am trying. The cursor->valid always says false. thanks...

php Checking if value exists in array of array

I have an array within an array. $a = array ( 0 => array ( 'value' => 'America', ), 1 => array ( 'value' => 'England', ), ) How do I check if 'America' exists in the array? The America array could be any key, and there could be any number of subarrays, so a generalized solution please. Looking on the php manual I see in_array, but th...

br2nl Replace All XHTML/HTML Line Breaks with Newlines in PHP

I am looking for the best br2nl function. I would like to replace all instances of <br> and <br /> with newlines \n. Much like the nl2br function but the opposite. I know there are several solutions in the PHP manual comments but I'm looking for feedback from the SO community on possible solutions. ...

Calendar Day View in PHP

I'm working on adding a day view option to an existing calendar solution. Like many people implementing their own calendars, I am trying to model Google Calendars. They have an excellent calendar solution and their day view provides a lot of flexibility. For most part, the implementation is going well; however, I'm having issues when ...

php Getting the 'new' values in an array

Trying to learn about php's arrays today. I have a set of arrays like this: $a = array ( 0 => array ( 'value' => 'America', ), 1 => array ( 'value' => 'England', ), 2 => array ( 'value' => 'Australia', ), ) $b = array ( 0 => array ( 'value' => 'America', ), 1 => array ( 'value' => 'England', ), 2 => arra...

How to change Zend_Db_Table name within a Model to insert in multiple tables

Using Zend Framework, I've created a Model to insert a record into a database. My question is, after $this->insert($data) how can I switch the active table so that I can insert a record into another table? Here's my code so far: class Model_DbTable_Foo extends Zend_Db_Table_Abstract { protected $_name = 'foo'; public function add...

Wordpress API: Add / Remove Tags on Posts

I know it seems like a simple operation, but I can't find any resource or documentation that explains how to programmatically add and remove tags to a post using the post ID. Below is a sample of what I'm using, but it seems to overwrite all the other tags... function addTerm($id, $tax, $term) { $term_id = is_term($term); $ter...

Remote connect to mysql?

Hi I don't use php or mysql but I am trying to upgrade a phpbb board I got but the one click installer forgot to install some stuff in the database so I can't upgrade to the newest version till I add the missing stuff. So I need to do a remote connect to mysql database but I am not sure how to do this or what software I need(free, and ...