php

How to delete nodes found with xpath-> query from a string that contains an HTML document with PHP

Hello all, The use case is quite simple. I would like to find node via an xpath statement in a string(!) that basically contains an HTML document and delete them. I know how to find the nodes with PHP. It is basically like this: create new DOMDocument LoadHTML (or LoadXML) Create new DOMXpath and then method "query" or "evaluate". Done...

How can I convert words to numbers in PHP?

The first method that springs to mind is reading each character and converting it to its ASCII value. Are there any other methods of doing this? I would like to be able to give a php script a string, and have it turn that same string (that may or may not contain numbers or symbols) into the same series of numbers every time. ...

How to trim text using PHP

How to trim some word in php? Example like pid="5" OR pid="3" OR I want to remove the last OR ...

problem in getting JSON data through server?

I am using Tropo Web API, to get result from a chat application, i redirected my JSON response to my server side PHP file(http://myhost.in/vj/app3.php?tropo-engine=json), the JSON response is coming correctly but i am not able to fetch data from that using PHP, the JSON response is as follows.. { "result": { "actions": ...

read function problem (not read all fields) in cakephp

hi all, i want to edit row. view file contains dropwons with Ajax. i used $this->data = $this->CourseBuilding->read(null, $id); but it cant read all fields of that id. Can U help me. ...

url rewrite not working in cakephp

Hi Experts, I am working in cakephp.i have done rewrite url for all forms and links. and i have done server side validation through model. but when server side error is generate then url rewrite not working one form i have done urlrewrite for that like Router::connect('/employers/edit-securitydetail/:id', array( 'controller' => '...

PHP str_replace/preg_replace problem with php open tags

I'm trying to replace something like: $text = "Hello <--name--> !!"; echo str_replace("--","?",$text); Expected: Hello <?name?> !! Result: Hello !! (I'm checking the source code, and I have short open tags enabled) I have tried so many ways but it seems that I can't never have as result any <? (or <?php) string. I think it may ...

Making a barebones, PHP-enabled web server in C?

I want to make the most lightweight possible HTTP server in C that supports PHP and possibly FastCGI if it will make a huge difference. I'm not sure how to implement PHP support. Does it just call PHP.exe with the path to a .php file and read the output? What about things like header () in PHP? How are those handled by the server? And ...

PHP OOP Problem

Hi, I have a following class in php - class BaseDatabase { private $host; private $user; private $password; private $database; private $connection; private $IDatabase; // This variable will point to an instance of a class // which implements the "IDatabase" interface privat...

Apaches mod_rewrite VS. PHP routing?

Hi, for some days now I have been trying to make a simple mod_rewrite rule to create friendly URLs, my web host have mod_rewrite enabled but I just can't get it to work. All the next questions where posted by me: .htacces to create friendly URLs Friendly URLs with .htaccess .htacces NOT working… None of the answers worked, so I'm t...

PHP: allowing upload of .php files for users, how do I prevent them from running?

I am allowing people to upload their project files, I've tightened my security but I just need to get to the simple point. How can I stop execution of any files in the subdirectories they're uploading too? I'm thinking .htaccess but I'd need to generate one for each new subdirectory (I think), would I need to scrap my current code and u...

Timeout with Ajaxterm

Hi Everyone, I have a similar question to this: http://stackoverflow.com/questions/1287064/php-session-timeout-callback Basically, I want to run some code once a user has been inactive for a certain amount of time. However my case is a little more tricky than the above question. This is because I am using Ajaxterm: http://antony.lesuis...

Separating application from app library, shared libary, components, etc

I am creating an MVC application framework, using only libararies and components that I create myself (mainly a learning experience), but I'm not quite sure how to separate each kind of library from one another. We'll call my application Cat. Lets say I'm creating a library called Dog, which would sort of be like Zend and is full of di...

Accept message from gsm devices and update table periodically

A gsm device sends data in each 3 seconds. 100 such devices are sending messages and there is a device to accept these messages. I want to insert these messages in mysql table in each 5 minutes using php. ...

PHP: How to determine if a database connection is open

Hi, I have the following class method - class Someclass { /* Other properties and methods */ public function close_connection($connection=NULL) { return mysql_close($connection) } } Now, before calling the mysql_close function in the above code, I want to check if the $connection points to a open database con...

How to make PHP set HTTP status code to 500 automatically in case of any error condition? (including those that cannot be handled by user)

Hi all. I am running Apache 2.2.15 with PHP 5.3.2, 'display_errors' disabled, 'display_startup_errors' disabled, 'log_errors' enabled. At my setup (so I consider it a norm), PHP aborts on fatal errors, which is good, and sets HTTP status code to 500. Fatal errors include E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR and...

got 417 reponse in twitter

Hi , in my server i have enabled the CURL , Even am using some contact grabber and paypal , and so many application with curl , But i dont know why this Twitter showing response as 417 this is my snippet , $host = "http://twitter.com/statuses/update.xml?status=".urlencode(stripslashes(urldecode($message))); $ch = c...

Remove trailing tags from a HTML textfield in PHP and/or TinyMCE

Hi there I have a problem: I am using TinyMCE for a text field. It all works fine until a user hits the enter button some times at the end of his input (new lines that are not needed). So for some inputs I save <p>CONTENT</p><p> </p><p> </p> or <p>CONTENT</p><br /><br /> Since this input is displayed at other places of the webpag...

random order within mysql order by case

My query selects results correctly using ORDER BY CASE. I would like to randomize the results within EACH case. i.e. ORDER BY CASE WHEN apples (randomize) THEN 1 WHEN pears (randomize) THEN 2, etc. So my results are still ordered by each case but within the results PER case they are random, each time the query is run. ...

Passing the name of the link when clicked

I have the following code <a href="process.html">cholera</a> I want to pass cholera to process.html onClick. Is there any way to do that in HTML? If no, PHP scripts are also most welcome. ...