php

How can I replace each URL in a string with another unique URL?

I have the following: $reg[0] = '`<a(\s[^>]*)href="([^"]*)"([^>]*)>`si'; $reg[1] = '`<a(\s[^>]*)href="([^"]*)"([^>]*)>`si'; $replace[0] = '<a$1href="http://www.yahoo.com"$3&gt;'; $replace[1] = '<a$1href="http://www.live.com"$3&gt;'; $string = 'Test <a href="http://www.google.com"&gt;Google!!&lt;/a&gt;Test <a href="http://www.google.com"...

Custom error pages using only one file...

Although I'm sure it's possible I cannot see how I would be able to do the following. Using .htaccess to point the html errors to a single error handling page (this bit not a a problem). That page then checks what the error code actually was (404, 500 etc.) and displays a message according to each one. I am trying to do it in a PHP en...

Alternate posts in wordpress

In order to put ads on my wordpress site, but only every few posts, I want to add a simple conditional to the bottom of each post, containing my ad code. I have ssomething like the following: <?php if (the_ID() % 3 == 0){ ?> ad code <?php } ?> But all this does is echo the id of the post.... for EVERY post! What am I doing wrong? ...

In MySQL how do retrive multiple values from a Search form with three fields?

Hi. I have a two tables: Clients Cities Then in the search form I have three fields: A text input form to fill with the name of the client A select box to choose the city where they want to search(table cities) Another select box to choose the main business that the user wants to search for(businness is included in the clients tab...

Zend Framework: How to unset data rows in a Zend_Db_Table_Rowset object

I would like to iterate over the data rows stored in a Zend_Db_Table_Rowset object and then drop/unset some of the rows, if they don't fulfil certain criteria. I could use toArray() to get only the data rows from the object and then it would be easy to unset the rows I don't need. But since I want to keep my object for further use I don...

How to build upload functionality into a web page

I've seen a number of different solutions for doing this but I wonder if anyone can suggest which is the most elegant and secure version of letting users upload their own files to a folder on their own shared hosting? (php.ini etc is out of bounds). Files will be anything up to 100mb in size, so maybe an FTP based solution would be best...

Uploading a Java Applet into a webpage

I have created a java letter game applet using netbeans 6.0 which also has a Microsoft Access Database for the High Scores. I want to upload it into a webpage (like how its done on miniclip facebook etc) I'd like to know how it could be done ...

ASP.NET ,equivalent to PHP Print_r Function?

PHP Print_r is useful to print out array and dictionary collection. is asp.net build in this function?? ...

PHP: Get text separated by commas

Hi, I have a multidimensinal array.. Something like this for example: Array ( [0] => Array ( [title] => Star Trek - Viaje a las estrellas [country] => Venezuela, Spain, long title, poster title ) [1] => Array ( [title] => Viaje a Las Estrellas [country] => ...

serving images from a filespool using zend framework

Hi, I have a quick question about how to serve data from a repository in a application that I am writing using the Zend Framework. My current structure is: /application /filespool /library /public In the filespool are a number of user identifiable folders that contain user content that is uploaded via forms, mainly jpg/png and pdf. ...

Use SQL to Filter Drupal Views

I have a content type with a CCK integer field which takes a unix timestamp. I would like to create a view with a filter that takes the MySQL function "UNIX_TIMESTAMP": If there is no way of doing this, how can I alter the SQL generated for the view? ...

php global variable modifier not working

I'm using the basic php example for the global modifier, and it doesn't work for me :-| $a = 1; $b = 2; function Sum() { global $a, $b; $b = $a + $b; } Sum(); echo "***: ".$b; Here is the result... $ ***: 2 Is there any parameter on the php.ini that might effect this? ...

Does PHP or LIghttpd create the fastcgi socket?

I'm working on setting this up on Mac OS X Leopard. I'm having a devil of a time getting PHP5 working as fastcgi under lighttpd. I've verified that I've compiled php with fastcgi enabled. I've tried configuring lighttpd as I've seen in various documentation. The core bit that I'm not understanding is if php-cgi is supposed to create t...

Php Db synchronization

Hello, I have a local server where I do all my testing and work. Once I am done, I simply upload the db schema along with the relevant code. However the problem arises when I make some changes to the schema. I have to manually type the "alter table" query on my live server. Is there a way to get the incremental changes that took place...

Encrypt php code

Hi all, I create a software using php. Now need to sale this software .So, I need to encrypt my code that nobody can view my source code. can anybody help me to do: 1. Encrypt my PHP code but software functioning will remaining same. 2. Also I need to bind the software for a particular authorized pc & it will not run any other pc except ...

correct way of using a throw try catch error handling

Hello, I have come accross to this function below and I am wondering wether this is the right way of using the error handling of try/catch. public function execute() { $lbReturn = false; $lsQuery = $this->msLastQuery; try { $lrResource = mysql_query($lsQuery); if(!$lrResource) { throw new MysqlException("Unable to execute...

PHP/MySQL: Insert data into database character set problem.

Hi, I'm building a website that fetches text from another page and insert it into the database. The problem is that all the special characters are saved in the database using the HTML encoding so then I need to convert the output using: <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /> I mean, what I have rig...

Send JavaScript array using JSON or XML? How to turn it to XML?

Okay, my situation is such: I need to send the contents of a JavaScript array to server where a PHP script will persist individual array entries in a MYSQL database. I am NOT using jQuery but I am about to integrate Prototype framework into my project. I gather that the JS array can easily be converted to JSON using the toJSON() method ...

CodeIgniter or PHP equivalent of Rails partials and templates

In CodeIgniter or core PHP is there an equivalent of Rails's view partials and templates? A partial would let me render another view fragment inside my view, like have a common navbar.php view that I could point to inside my homepage.php view. Templates would let define the overall shell of an HTML page in one place, and let each view ...

Is there a way to see all variables in the current scope?

Title kinda asks it all. I'm not referring to $_REQUEST, $_SERVER and all the pre-defined. I just want to know if on line 400 of my program I can somehow see all the variables that have been created up to that point. Duplicate of: http://stackoverflow.com/questions/717852/php-get-all-variables-defined-in-current-scope-symbol-table ...