php

Submit text and Wysiwyg form to both Database and flat file.

I've created a form that is made up of 2 input fields and a wysiwyg text area (ckeditor). I have a function using ajax to gather the ckeditor data to be submitted. I have the form properly submitting to the database, but I also need it to write to a text file. How would I go about doing this? Edit to include code: using onclick to subm...

How best use Regular Expressions to convert Heirarchical Text File into XML?

Good morning - I'm interested in seeing an efficient way of parsing the values of an heirarchical text file (i.e., one that has a Title => Multiple Headings => Multiple Subheadings => Multiple Keys => Multiple Values) into a simple XML document. For the sake of simplicity, the answer would be written using: Regex (preferrably in PHP)...

How to force PHP to output a number preceded by zeros?

for ($number = 1; $number <= 16; $number++) { echo $number . "\n"; } This code outputs: 1 2 3 ... 16 How can I get PHP to output the numbers preceded by zeros? 01 02 03 ... 16 ...

Convert .xls file to xml using php

Hello all! I need to implement a functionality where a user can upload an Excel file, that is, .xls file and i need to write a function that will read that file and then save the values in a table, compare them to values in another table and then print some kind of billing quotation. From what I have read, it seems that the best way to...

Youtube API PHP problem

Hello. I downloaded the library Yotube API PHP (search for videos) from zend.com and its examples. On windows (localhost) everything works fine ... Uploading on the debian server, and there at the request search video gives an error: Invalid response received - Status: 404 Code of this error from videO-browser.js /** * Sends an AJ...

Does WGET timeout?

I'm running a PHP script via cron using Wget, with the following command: wget -O - -q -t 1 http://www.example.com/cron/run The script will take a maximum of 5-6 minutes to do its processing. Will WGet wait for it and give it all the time it needs, or will it time out? ...

A good book for PHP XML DOM

Unfortunately the PHP DOM classes and functions are not very well documented and I am starting projects that are going to be very XML heavy. I do not have a solid grasp on the DOM functionality and have been making due with SimpleXML abd XMLWriter untill now, but I am running into some serious problems with their limitations. Is there ...

Formatting column results in Doctrine ORM?

I have a timestamp field (using the timestampable template) that I want formatted differently in the results for only one SELECT query. Is there a way to pass in a date/time format string in the Doctrine_Query::create() method? Or maybe there's a way with ->setParams() or ->setOptions? I could format the date in the View using Zend_Da...

Apache - 406 Not Acceptable PHP Problem

Hello Everybody, I'm debugging a flash website that do a request to an php file named upload.php to upload some images to the server. The problem i'm having that debugging it with Firebug the request to that page is throwing a 406 Not Acceptable status code and is not saving the images. Post Data: This website runs well on the sta...

Getting ’ instead of an apostrophe(') in PHP

I'v tried converting the text to or from utf8… didn't seem to help Im getting: "It’s Getting the Best of Me" It should be: "It’s Getting the Best of Me" Im getting this data from a url -> http://www.tvrage.com/quickinfo.php?show=Surviver&amp;ep=20x02&amp;exact=0 ...

process of commenting and improving already written program?

Please allow my intro to properly define the scope of my question: I'm still very new to the programming world. This all started for me when I had an idea for a software program, but no programming experience. I ended up going the outsourcing route to get the program, and after almost a year, we do have it live and functioning. This ...

How to save image attachment from email using IMAP & PHP?

Hi All, I've successfully written script that connects to my mail server and retrieves the headers and bodies of all new messages. I want to take it one step further to detect if attachment exists (images only), if so, download to server. How to go about this using PHP & IMAP? Thanks in advance ...

Use am/pm to create php timestamp

I have a couple textboxes that allows a person to enter a time and date. The time is entered with a textbox for hours, a textbox for minutes, a drop down for am/pm and some drop downs for months/hours/years So, I'd like to combine all of these to create a timestamp out of it and save it to the database. But i've confused myself in ho...

Highlight Search Terms in PHP without breaking anchor tags using regex

I'm searching through some database search results on a website & trying to highlight the term in the returned results that matches the searched term. Below is what I have so far (in php): $highlight = trim($highlight); if(preg_match('|\b(' . $highlight . ')\b|i', $str_content)) { $str_content = preg_replace('|\b(' . $highlight. ')(...

How do I invert a multidimensional array in PHP

Whats the easiest way to invert a multidimensional array. By invert I mean similar to array_flip. e.g [0][5][var_name] = data [0][3][var_name2] = data2 [1][var_name3] = data3 [0][1][4][var_name4] = data4 inverted would be: [var_name][0][5] = data [var_name2][0][3] = data2 [var_name3][1] = data3 [var_name4][0][1][4] = data4 Any ide...

What's the most efficient way to get data from a model in CakePHP?

I'm new to CakePHP, and still figuring out the basics. Right now I'm a bit mystified by the process to get one or more fields from a model (from inside another linked model). So far, I have this: $this->user->id = 123; $this->User->read(); $field1 = $this->User->data['User']['field1']; $field2 = $this->User->data['User']['field2']; W...

PHP loading new models in a loop

I am currently battling this error message by refactoring some of my code: Fatal error: Allowed memory size of 33554432 bytes exhausted I figure I must have sloppy code somewhere. Is it a bad practice to load new models in a loop like so: <?php foreach($blog_ids as $blog_id) { $blog = new Blog($blog_id); echo $blog->titl...

JQuery Alert Problem?

I'm trying to get the following code to display only on specific pages but when I click through certain pages like the home page or any other pages that does not use this code I get the following `alert("some error occured, please try again later");. How can I have the code not display the alert box on pages that do not use this JQuery ...

URL Rewriting: "index.php?id=5" to "home.html"

Hi everybody, I'm developping a website using php and the "template.inc" class. The problem is that I want to create a mini-cms that allows the admin to create an "html" page with these mysql attributes: Table Name : Page ----------------- id :auto-icremented) name :varchar In the architecture, if he created the page number "5", t...

How to create databases on mySQL using script (PHP, etc)

Hi, I am thinking of running a hosted service using Amazon Services (PHP + mySQL). What I like to do is have a site where someone registers, pays PayPal and returns to site where they will get an automated information to their mySQL account. So this mySQL account would only be used by them. They can create tables, etc. Some questions ar...