php

unexpected '{' in header.php on line 1 of WordPress

I am using following code to redirect users based on browser language: if(!isset($_SESSION['lang'])){ if(preg_match('/en-US/', $_SERVER['HTTP_USER_AGENT'])){ $_SESSION['lang'] = 'en'; header("location:index.php"); }else{ $_SESSION['lang'] = 'other'; header("location:http://cn.gearor.com"); } } I put the code in my...

is it possible to use regex to search inside an array using php...

I have an array of string i need to search an string inside the array using regex is it possible if so please explain.. ...

Why is header() causing an internal server error?

I cannot figure out what could be causing this error. My Apache log is not recording any errors in the access log or error log regarding the page, yet somehow whenever I uncomment the header() line I get a 500 Internal Server Error. It can't be coming from PHP's fatal error when content is outputted before header() is called, that wouldn...

What does {$histogram{$value}++} mean in Perl?

The whole subroutine for the code in the title is: sub histogram { # Counts of elements in an array my %histogram = () ; foreach my $value (@_) {$histogram{$value}++} return (%histogram) ; } I'm trying to translate a Perl script to PHP and I'm having difficulties with it (I really don't know anything of Perl but I'm trying). So...

C# Use WebClient.UploadFile(string, string) to upload to a Apache & PHP webserver

The C# WebClient.UploadFile(string, string) sample on MSDN shows how to make it work with an ASPX page handling the upload. However I have a Apache server with PHP set up to handle my subversion repos. I have very little web programming knowledge, but would like to know... Can my Apache/PHP web server handle a file from a c# client usin...

uploading image and downloading

Hello, In my web application, I need to be able to allow users to upload and download their images. How can this be done in php I want to user to be able to sign in (I already have that done) and be able to upload images to their account. Later on, I want them to be able to download them. ...

Echo php into google map javascript

Is it possible (and if so please explain how) to echo php into javascript, specifically for my purpose I am trying to echo the input of a custom field from the wordpress platform into the description of a google map. I am hoping I can give the client a cms backend to input the text that appears in the marker points on a map. What I am ...

looking for PHP Framework with special abilities

I am looking for a php web framework that supports multiple databases with the same schema/model. Every customer of us will become his own webserver with his own database. On top of this we want to develop a central administration app that works on all customer databases, which are all have the same schema/model. Is there a php framework...

Update query that needs to find the 'newest' row

My logout function needs to update the latest row of a list of logins. This is what I have came up with, however it doesn't even pass syntax validation. $query = 'UPDATE user_logins SET active = 0 WHERE user_id = ' . Database::instance()->escape($this->getCurrentUserId()) . ' AND datetime = MAX(datetime) LIMIT 1'; ...

is there a window program that can convert word (.doc and .docx) into text

Hi, I need a window program to convert word file (.doc) into text. Something like "anitiword" for windows. I need it because I need to convert word file into text and use Lucence to index it and I am in a windows environment :( Thanks for all your help!!! ...

Php polling Is it required

Hi, I want to write a php code that displays a html button only till some point of time. Since php is a scripting language and code get executed only when the html page is rendered, I was thinking that instead of polling I can just check the time at the time the page is getting rendered. If the current time does not satisfy my conditi...

PHP CSV export function

I am trying to export data from my MySQL database to multiple CSV files and then GZIP them. I have a couple of problems which make exporting it to a CSV file complicated ... Several fields (10) need to be in 1 CSV file Other fields (multiple!) are serialized and need to be exported into a different CSV file with two other non seriali...

Strict Standards: Only variables should be passed by reference

$el = array_shift($instance->find(..)) The above code somehow reports the strict standars warning,but this will not: function get_arr(){ return array(1,2); } $el = array_shift(get_arr()); So when will it report the warning anyway? ...

(PHP) Is handling a form submission on the same page more/less/equally good as handling on a separate page?

I have a PHP form, and I'm wondering how I should handle submission. I remember when learning Rails that the behavior was to have a special handler page for a form, which then redirected the user to a landing page, which would prevent the user from accidentally re-submitting data by hitting the back button and going back to the form subm...

Recording a Yes/No question from a form in PHP

Hello all , I want to write a Yes/No form with radio buttons. By default none of the buttons would be checked. On submit, I want to check that at least one of then is checked! function draw2($postid, $postName, $canId, $canName) // for Yes/No candidates { colspan='2' img src='images/".$canId.".jpg'".$canName." input type...

change the who of google calendar event with gdata framework

$gdataCal= new Zend_gdata_calendar($client); //on retrouve l'event a partir de eventURL stocké lors de la création $event = $gdataCal->getCalendarEventEntry($id_event); $who= $gdataCal->newWho();// $who objet de type Zend_Gdata_Extension_Who //les nouvelles valeurs du who $email ="cn21lqqt8jeb9qgulpra6bj948%40group.calendar.google.com";...

regex in php for finding words

i want code for the following example.... example.... $words = "The sculpture was selected during a design competition. After Kapoor's design was chosen, numerous technological concerns regarding the design's construction and assembly arose, in addition to concerns regarding the sculpture's upkeep and maintenance. Variou...

Converting date to this format

I have a date in this format: 24-12-2010 // DAY - MONTH - YEAR I need to get it in this format: 1995-12-31T23:59:59.999Z // The Z is for the TimeZone I think. Check this link out: http://lucene.apache.org/solr/api/org/apache/solr/schema/DateField.html The above link is the way I need the date. I am using PHP now, so this n...

PHP: Does die() must die?

Is it considered bad practice to let die() live in a production enviroment? Just happened to read this article http://www.phpfreaks.com/blog/or-die-must-die where the author fies upon people who use such a thing in a production enviroment. So shouldn't I code this way: $connection = mysql_connect($db_host, $db_username, $db_password); i...

Storing regular expressions in MySQL database table and maching against them

I have a very interesting task, which I don't know how to implement. I need to store many regular expressions in a database table, and need to be able to find which of them matches the given string. For example: id | regexp ---|------------- 1 | ^hello world$ 2 | ^I have [0-9] flowers& 3 | ^some other regexp$ 4 | ^and another (o...