php

problem getting redirect to work properly php

Hi. I have a little problem with redirecting. Registered users follows this link site.com/reg.php?passkey=1234 but the first the user get redirected to the correct language based on a cookie. I need to keep the passkey variable when the user is redirected. like this ?lang=en_US&passkey=1234 My code so far look something like this: if...

empty backreference causes match failure in PHP... is there a workaround?

I'm having trouble with a regular expression in PHP that uses a potentially empty backreference. I was hoping that it would work as explained in http://www.regular-expressions.info/brackets.html: If a backreference was not used in a particular match attempt (such as in the first example where the question mark made the first ba...

Questions about parsing

I know we can grab information (with php) from any site and create own. I'm talking about parsing some additional content like movie information (dates, budget, persons, etc) or video file properties from youtube (size, duration). I'm excited on realizing of grabbing process from big sites and large amounts of information. Seems there...

Adding a new file and calling functions from that file yields undefined function add_action()...

Hi, I am adding a new file called subtypes.php to my theme /library/includes in order to allow for a dynamic dropdown list. This file uses functions from /library/functions/custom_functions.php. The problem: whenever I call any function from custom_functions.php, I get fatal errors: Call to undefined function add_action(), other times...

stmt->bind_params dynamically? PHP

How would it be best to approach this task? require_once('models/databaseModel.class.php'); class crudModel extends databaseModel{ public function __construct(){ parent::__construct(); } public static function create(&$data, $tbl){ // TEST $data array // $data = array('name'=>'philip','email'=>'[email protected]','age'=>2...

exec always returns -1

Hello, I'm using php 5.2.9 on a production server, and it seems that the exec() function behaves "non-standard". If i run exec("ls", $output, $return_var) then $output will contain the list of files in the current folder as expected, but $return_var will be set to -1 instead of 0, as expected. I'm using the $return_var to determine wher...

Dynamic input in Selenium/PHPUnit

I want to take dynamic input for values in my unit tests. How can I do this? Thanks! ...

SQL table design advice

Hey i want to create a list like this. The pic below isnt my list just an example of what i want to create. My category table is currently just: category( id int, title varchar(20) ) Should i just keep everything in one table or add a section table to deal with each category section? ...

How to add an attribute programmatically

Hi, I'd like to add an attribute to products, and I want to do this programmatically. So I added a mysql-install-0.1.0.php to a module of mine, and I added this (inspired from existing examples) : <?php $installer = $this; $installer->startSetup(); $installer->addAttribute('catalog_product', 'collection', array( 'type' ...

Curl GET request through Zend_Http_Client

Hi, I am trying to make a GET request to gowalla spots by Zend_Http_Client (cURL adapter) here is my class: class Application_Model_Gowalla { private $_config; private $options; private $array; private $json; public function __construct() { $conf = Zend_Registry::get('config'); $this->_confi...

.htaccess & wordpress site - How to add 301 redirect rules for no longer valid permalink?

I recently did a big update on my wordpress site, thus some old permalink are invlid now. Seach google for a tutorial on this and found a lot about static html page redirection examples or specific php page which are not what i'm looking for Both my old and new permalinks are in path format, for example, i need redirect a couple urls o...

Wordpress how to set the post excerpt length to 100 characters and 200 characters

Example I want use the_excerpt in two locations. On functions.php I add function new_excerpt_length($length) { return 100; } add_filter('excerpt_length', 'new_excerpt_length'); Question. How to make another function to accept another the_excerpt will be 200 characters? Or another solutions. How to make something like this.. Dyn...

How to loop through dynamic form inputs and insert into an array

Hi, I have a form that asks users to input numbers into multiple form fields. They can select how many form fields they would like. I have labelled the form fields as df1, df2, df3 etc. For each extra form field the user adds it will simply plus 1 to the number after df. My problem it trying to capture (using PHP) these fields and put t...

Does std Class in PHP creates a Hidden Fields for each property

$Var = new StdClass; if($_POST['somvar']){ $Var->somvar = $_POST['somvar'] } else { $somevar='' } Why is it creating hidden varaible for this statement "$Var->somvar = $_POST['somvar']" when i see the view source How do i persist the state of this variable when moving to next pages ...

preserve html content when parsing xml file

I have a xml file <text> <defalut>This file has the following features:</defalut> <value> <ul> <li><info>CSS text formatting </info></li> <li><info>Text loaded from a XML</info></li> <li><info>Scrolls with easing</info></li> <li><info>Mouse wheel supported</info></li> ...

Get content (images) from above webscope

I am creating an online service where "special users" can upload their images. It is very important that the images are not exposed to anyone else than the user who uploaded them. I have heard that the best way to protect the images is to put them over the webscope. So far so good. My problem is that i can't display the images, how is ...

Is there better way to transpose a PHP 2D array?

According to the PHP Manual, calling array_map with a NULL callback causes it to perform a "zip" function, creating an array of arrays of parallel elements from the given arrays. For example: array_map(NULL,array(1,2,3),array('a','b','c')); yields array(array(1,'a'),array(2,'b'),array(3,'c')) This is also equivalent to transposing...

Trying compile a C Code with PHP

I have a file named gcc.exe and I have a php page... I want to use: gcc test.c And, if there's some compilation error, I want to show it on the php page... But I can't. What happens is: If the file is correct, it generates the .exe file, but if it's wrong, nothing happens. What I want here, again, is to show all errors. Anyone has an...

Manually build JSON encodable array in PHP...

This is kind of a strange one. I have a CSV that I'm uploading and passing to a PHP script that parses it into arrays, encodes it into a JSON string and sends it back to be further processed by my Javascript. However, I am having difficulty getting the response in a format that is easily parsed. Maybe it can be parsed, I'm just not su...

PHP List Images In Folder

I have the following code // Define the full path to your folder from root $path = "../galleries/".$album; // Open the folder $dir_handle = @opendir($path) or die("Unable to open $path"); // Loop through the files while ($file = readdir($dir_handle)) { if(strlen($file)>1){echo "<a href='htt...