php

How to escape $ in php using preg_replace ?

Hi, I am using preg_replace to escape special characters... $tmpStr=preg_replace("/\?/", "\?", $tmpStr); $tmpStr=preg_replace("/\#/", "\#", $tmpStr); $tmpStr=preg_replace("/\^/", "\^", $tmpStr); $tmpStr=preg_replace("/\&/", "\&", $tmpStr); $tmpStr=preg_replace("/\*/", "\*", $tmpStr); ...

PHP CLI script to login an application

Hi I am trying to write a script to login a web application using PHP CLI script like <?php $post_data = array( 'user_name' => 'abc', 'user_password'=>'XYZ@@11', ); $url ='http://www.myapplication.com?action=Login&amp;module=Users'; $hat = new HttpRequest($url,HTTP_METH_POST); $hat->setPostFields($post_data); $hat-...

How can I do pagination of HABTM data?

hello.., i have a table where a Collection has many Entities and an Entity has and belongs to many colections..now for a particular collection there are many entities..how can i paginate those entities belonging to a particular collection.. my find query says.., $this->Collection->find('first', array('condition'=>array('uid'=>$uid)), ...

Check for a null value from a database -- failing

I am retrieving 3 fields from a database, and by default, only the username field will have content. The other information will be added in from a user application. I want to show the field as "No Info" if there is no entry in the field. I am trying to use both empty() and is_null() to no avail. A var_dump of $row['firstname'] and $row['...

How to enable soap extensions

Is it possible to enable soap extensions in php without compiling the php dist? I´m using Mac OS X 10.5+ with the built in php interpreter. ...

ajax problems? with activexobjects

Hello everyone, I keep getting the following error's: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://site/cms/js/interface.js :: doAjaxCall :: line 300" data: no]   uncaught excep...

PHP "pretty print" HTML (not Tidy)

I'm using the DOM extension in PHP to build some HTML documents, and I want the output to be formatted nicely (with new lines and indentation) so that it's readable, however, from the many tests I've done: "formatOutput = true" doesn't work at all with saveHTML(), only saveXML() Even if I used saveXML(), it still only works on elements...

Editing and creating things with address bar code?

How do I make it so that I can make a thing at the end of the address where the .php is and then tell it to do certain things. For example pull up a page like this: sampardee.com/index.php?page=whatever Help? Anything else I could do with this? ...

dynamically naming a variable?

I have a table with various auctions, where each record has both a username and a category. More than likely, there will be multiple records with the same username and category. There are four different types of categories. I am wondering if it would be possible, given the prepared query below, to have the second bound parameter be the ...

What's a good theoretical MAX_SIZE when managing email attachments?

I'm working on a part of a website where I generate PDFs, attach them to an email and send it off. Right now I am not tracking the current sum of the sizes of all the PDFs to be attached to the email, but I suspect at one point that I should. My question boils down to: What is a good theoretical *MAX_SIZE* that you should go by when ma...

How to make a redirect in PHP?

Is it possible to redirect a user to a different page through the user of PHP? Say the user goes to www.example.com/page.php and it I want to redirect them to www.example.com/index.php , how would I do so without the use of a meta refresh? Possible? This could even protect my pages from unauthorized users. :] Please help ...

PHP filter_input()?

This should be a elementary question but why is better to use something like this: $pwd = filter_input(INPUT_POST, 'pwd'); Instead of just: $pwd = $_POST['pwd']; PS: I understand that the filter extension can be used with more arguments to provide an additional level of sanitization. ...

Using functions in PHP?

How do I simply call a function by using PHP? Say I have created: function sam(){ echo "Hello World!; exit(); } How would I initiate the function? ...

DOM: fetch all text nodes in the document (PHP)

I've have the following (PHP) code that traverses an entire DOM document to get all of the text nodes. It's a bit of a ugly solution, and I'm sure there must be a better way... so, is there? $skip = false; $node = $document; $nodes = array(); while ($node) { if ($node->nodeType == 3) { $nodes[] = $node; } if (!$skip && ...

cakephp isAuthorized() not being called

I am trying to use the isAuthorized() method to do a check for an admin flag, but the function never seems to be called. Even when I set the function to always return false, it allows any user. It just seems like it isn't being called. Do I need to do something more than setting $this->Auth->authorize = 'controller' ? from /app/app_con...

PHP library for converting HTML4 to XHTML?

I need to convert HTML4 input to valid XHTML (strict) in PHP5 for further processing (SAX for instance). Any suggestions? ...

PHP/MySQLi: SET lc_time_names and DATE_FORMAT() into a mysqli query??

Hi, I use the next code to retrieve data from a table in the database: $check_sql = 'SELECT personID, name, DATE_FORMAT(persons.birthdate, "%d de %M, %Y"), birthplace, countryID FROM persons WHERE personID = ?'; if ($stmt->prepare($check_sql)) { $stmt->bind_param('i', $pid); $stmt->bind_result($personDB, $name, $birthdate, $birthpl...

Dump php system command output to a file

Hello all, In the php system command we use the following system("ffmpeg -i test.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv output_file.flv 2>&1 &"). Please explain the usage of the above mentioned system command. What does '2>&1 &' stand for ? I want to dump the process details to a file how do I do that ? Thank you very ...

How to str_pad this PHP date selection month array ???

Needs to be padded to this: str_pad($Month, 2, "0", STR_PAD_LEFT) but how/where??? /*******creates the month selection dropdown array****/ function createMonths($id='month_select', $selected=null) { /*** array of months ***/ $months = array( 1=>'Jan', 2=>'Feb', 3=>'M...

Best white label ecommerce application

Are there any comprehensive ecommerce systems out there (either paid or open source preferably php) that are available for white labelling and selling onto clients ? I already know about http://www.magentocommerce.com/ and http://www.oscommerce.com/ although I'm not sure either of them are what you would describe as 'white label'. th...