php

Add rss xmlns namespace definition to a php simplexml document?

I'm trying to create an itunes-valid podcast feed using php5's simplexml: <?php $xml_string = <<<XML <?xml version="1.0" encoding="UTF-8"?> <channel> </channel> XML; $xml_generator = new SimpleXMLElement($xml_string); $tnsoundfile = $xml_generator->addChild('title', 'Main Title'); $tnsoundfile->addChild('itun...

jQuery recursive function to upload many files while giving the user some feedback

Hi guys, I'm trying to write a jQuery function to let users upload many files at once. Here's the function I thought to give the user some feedback about the upload process progress. function uploadFiles(numbersOfFiles, start) { $("#info").html(start + " files uploaded"); $.post('upload.php', { start: start }, function (d...

Assigning Object to View, big MySQL resultset.

Hello (Sorry for my bad English) Is it bad practice to assign object to view and call its methods in there? I use smarty as my template engine. In my controller I could do like this 1# $this->view->assign("name", $this->model->getName); and in my view <p>{$name}</p> OR 2# $this->view->assign("Object", $this->model); and in m...

How to scale php application servers horizontally?

Hello, I'm using lighttpd as webserver for php application server. The avg. load on this server is about 2-3. MySQL database is separated to another server (it's load ~0.4). How could I scale php application server? Thank you. ...

Drupal: adding disclaimer text above the submit button in a webform

Hi, Is there an easy-ish way to modify the webform-form-tpl.php template to show disclaimer text above the submit button in a Drupal webform? I can add text below the button, but do not know how to split up the button from the other elements to add text between them, ie: [form-elements] [disclaimer text] [submit button] Cheers! ...

PHP Retrieve Cookie which was not set with setcookie

I have the following problem - a third party software is setting a cookie with the login credentials and then forward the user to my app. I now need to retrieve the cookie values: The problem is - I can do this easily in the Frontend/AS3 with var ticket : String = CookieUtil.getCookie( 'ticket' ).toString(); but in PHP, the cookie i...

Cron job and EasyPHP

Hi, I'm using EasyPHP (my OS = Windows XP) and I've wroten an little php-script that should update my database every hour while server is up. I could include the script into the index.php but then it would only be executed when there is activity on the site. How can I configure EasyPHP or Cygwin to execute my cron job ? thx ...

php function last_insert_id() is not working with REPLACE INTO query

I am using REPLACE INTO query to insert in to table but after executing query by using mysql_query() function and if I use last_insert_id() it is only giving me 0 value. why this is happening so? and how can I overcome this behavior. :Pankaj ...

Detect remote charset in php

Hello, I would like to determine a remote page's encoding through detection of the Content-Type header tag <meta http-equiv="Content-Type" content="text/html; charset=XXXXX" /> if present. I retrieve the remote page and try to do a regex to find the required setting if present. I am still learning hence the problem below... Here is ...

How to send from fields and a file using PHP Curl?

I'm trying to send form fields and file to a web service using php curl. The form has already been passed from a browser to a proxy php client web app and I'm trying to forward it to the web service. When I pass an array to curl_setopt like this: curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->fields); I get a Array to String notice...

looking for php-based image viewer / browser

(don't know if this better belongs to SU/SF, feel free to move if so) Hi, I've got a directory with 1000+ subfolders full with hi-res images. I'm looking for php software that would allow me to explore it server-side: browse folders - preview images - download hi-res. NB: support for print formats (tiff, eps) is a must! ...

How do I find the ceiling and floor for a number from a set of numbers?

1st number: 50 2. 30 3. 70 4. 40 5. 11 and other number is 33 I need to calculate which two numbers the last number is between (using php) .. any help? ...

selectLimit in JQgrid

Hallo, I have a problem. I'am trying to get some data from my database. But with a limit. So i use the selectLimit command. But when i load the grid my firebug gives the following error: "parsererror"?e:null},parse:function(d...d(a.fn.jqGrid,d);this.no_legacy_api|| When I go to the selectLimit in the jqgrid.php and print out what the ...

How to use the php fopen() correctly

I am learning php, trying to use the fopen() function. The php file I am coding is in this directory /domains/xxxxx.com.au/public_html/phpfile.php What path do I specify for the file to be opened, the example I am looking at is based on a server on a pc where this is the file path $filename = "c:/newfile.txt"; not an online server. UPD...

larger file upload problem with php

I need to upload a csv file to a server. works fine for smaller files but when the file is 3-6 meg its not working. $allowedExtensions = array("csv"); foreach ($_FILES as $file) { if ($file['tmp_name'] > '') { if (!in_array(end(explode(".", strtolower($file['name']))), $allowedExtensions)) { ...

What does reorder() function do in Joomla?

What does reorder() function do in Joomla? I have a statement for a function of menu "copy" in administrator code for menu as: $curr->reorder( 'menutype = '.$this->_db->Quote($curr->menutype).' AND parent = '.(int) $curr->parent ); as i Have executed this code it has reordered my id to any other position.. I just need to know is thi...

How can you find all HTML hyper link tags in a string and replace them with their href value?

I'd like to take a string of text and find all of the hyper link tags, grab their href value, and replace the entire hyper link tag with the value of the href attribute. ...

PHP Path issue running backticks/exec()

Hey all I'm trying to run a java jar file from the command line and within the the execution it gives a path. Withing this path their are spaces and this is causing the issue. ie foreach($paths as $path): $f = `java -jar /OCR/ocr.jar /Folder/$path /ocr/output.txt`; echo "<pre>$output</pre>"; endforeach; If you can see the space in b...

Can't get custom error rendering to work in symfony 1.4

I'm tring to customize error rendering in my form according to this example. Here is my code: if ($this['message']->hasError()) { $error_msg = '<ul>'; foreach ($this['message']->getError() as $error) $error_msg .= "<li>$error</li>"; $error_msg .= '</ul>'; } return $error_msg; but when $this['message'] has error this code retur...

Why do two array values look the same, but don't evaluate as equal?

When I compare two array values I see two strings that look the same. php doesn't agree. $array1 = array('address'=>'32 Winthrop Street','state'=>'NY'); $array2 = array('address'=>'32 Winthrop Street'); $results = array_diff_assoc($array1, $array2); var_dump($results) //echos ['address'] => string(18) "32 Winthrop Street" ['state']=...