php

How to split a string into words. Ex: "stringintowords" -> "String Into Words" ?

What is the right way to split a string into words ? (string doesn't contain any spaces or punctuation marks) For example: "stringintowords" -> "String Into Words" Could you please advise what algorithm should be used here ? ! Update: For those who think this question is just for curiosity. This algorithm could be used to camеlcase do...

Elegant way to sort an array like this

This is my array: $arr = array(-3, -4, 1, -1, 2, 4, -2, 3); I want to sort it like this: 1 2 3 4 -1 -2 -3 -4 So first there would be values greated than zero sorted from the lowest value to the highest value, then there would be negative values sorted from the highest value to the lowest value. Is there some elegant way to do this...

Reorder a PHP array with usort and strcomp: bug

Using usort and strcomp together to order an array by one of its keys has an odd effect: it returns my array with fewer items in it than I put in. The array in my case contains rows representing tasks, and I want to order the rows in the array by the key 'displayorder', which is a number but which I want to be sorted in alphabetical man...

Using name pipes from php

Hi, just a general question are there any issues with using named pipes from a php script, currently i'm calling a bash script from php to write to a named pipe. This would be on Debian Linux to communicate from a php script to some background running C program ...

Character encoding issue with PDO_ODBC

When accessing a Microsoft SQL Database from PHP using PDO_ODBC with the following code, I have an encoding issue. When outputed the text from the DB is garbled. $dsn = "odbc:DRIVER={SQL Server};SERVER=$hostname;DATABASE=$database;charset=UTF-8"; $pdo = new PDO($dsn,$username,$password); $sql = "SELECT text FROM atable"; $result = $PDO-...

Formatting string for xml attribute in php

I have some strings that are valid in my database but when I include them in an attribute of a UTF-8 XML output they give me the following error: XML Parsing Error: not well-formed My current code (simplified): header('Content-Type: text/xml'); echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'; echo '<root attribute=...

DateTime::createFromFormat - php format issue

PHP - DateTime::createFromFormat — Returns new DateTime object formatted according to the specified format this works: $var = DateTime::createFromFormat('Ymd','20100809')->getTimestamp(); but this fails with "Call to a member function getTimestamp() on a non-object " $var = DateTime::createFromFormat('Y/m/d H:M:S','2010/08/09 07:47:0...

Why does my mysql_real_escape_string not work(PHP) ?

hello, I have read many about SQL-Injection". But it does not work with this code: $inputform= $_GET["password"]; $query = "INSERT INTO user(password) VALUES ('".mysql_real_escape_string($inputform)."')"; For example I use this example: O'Conner. When I submit it and look in my table there is O'Connor and not O\'Conner. thanks ...

Prevent displaying of previous pages after logout

Hi everybody, i'm working at PHP application but i have a trouble, in fact when a user logged out and press after logging out the back button of the browser he can see the previous page as if the session has not been destroyed :(( i have tried all that i find here and on the web but it doesn't work :'( Can I disable the back button? ...

receiving xml files via http post - security

Hi, I've a basic php script set up on a web server to accept xml files received sent via Http post. So far so good. But I'm wondering about security issues and what other things I would need to be aware of before I could put this live. Has anyone done this beofre and what things I should be aware of? Basically all I have so far is: <?...

Open Source Online IDE

Are there any Open Source online IDE's except for Bespin? If found some online IDE's like; phpanywhere.net, coderun.com, squadedit.com, codepad.org, but non of them are open source. Bespin isn't working for me, it could be because I'm a Opera user, but even in Firefox I couldn't get it to work properly. And if there is no other alterna...

Changing the Return-path using PHPMailer

Is there a way to change the return-path using PHPMailer I did the following and it did not work $mail->AddCustomHeader('Return-path:[email protected]'); I'm using the following statement to send mails if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { //Building the reporting email to report...

Cant figure out operators in php statement

I need to edit a function, but I cant figure out what the ? and the : false mean in the return statement. I think the : is an OR but the ? I dont know. public function hasPermission($name) { return $this->getVjGuardADUser() ? $this->getVjGuardADUser()->hasPermission($name) : false; } Anyone that can clear this up for me? ...

Using SOAP to generate XML attributes in PHP

I need to generate the following XML with SOAP: <MetaDataConstraint class="topics"> <Value>FRX</Value> </MetaDataConstraint> I am not sure how to generate the attributes. Based on: http://stackoverflow.com/questions/2045850/using-soap-to-generate-xml-attributes-in-php, I tried to do the following, but unfortunatelly it does not ...

SOAP error (WSDL) in php webservice

my wsdl code- <portType name='CatalogPortType'> <operation name='getCatalogEntry'> <input message='tns:getCatalogRequest'/> <output message='tns:getCatalogResponse'/> </operation> </portType> <binding name='CatalogBinding' type='tns:CatalogPortType'> <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http...

How to use Textile in PHP?

Hello - a (hopefully) quick question - how can I use Textile in PHP? As in, I have some textile-formatted text that I want to convert to html using php. If I was using Ruby I'd use RedCloth but I can't seem to find a similar solution for php. Anybody any ideas? ...

Geting Fatal Error: Uncaught exception 'Zend_Db_Adapter_Exception' in zend framework

I am new to Zend Framework, try to configure on my local machine. Geting Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'The PDO extension is required for this adapter but the extension is not loaded' in C:\Inetpub\ZendFramework-1.10.6\library\Zend\Db\Adapter\Pdo\Abstract.php on line 103 Could anybody please h...

Populate dropdown menu based on groupnumber and MySQL answer

Hello! I am building an webapplication for retailers to register purchased products in PHP/MySQL. What I like to do now is to populate a dropdown menu in a form with the products the specific retailer sells. The retailer is assigned a value for each product that they are selling, and then the values are summed up and putten into the data...

Is there any language which is just "perfect" for web scraping?

I have used 3 languages for Web Scraping - Ruby, PHP and Python and honestly none of them seems to perfect for the task. Ruby has an excellent mechanize and XML parsing library but the spreadsheet support is very poor. PHP has excellent spreadsheet and HTML parsing library but it does not have an equivalent of WWW:Mechanize. Python ...

Create SEO-friendly URL with PHP with just the Querystring Value

Is there a way use mod_rewrite to produce the result below? Original URL: http://www.domain.com/shop.php?id=newyork to SEO friendly URL http://www.domain.com/newyork I've seen plenty of example where the above URL can be converted to http://www.domain.com/shop/newyork but I actually don't want to display the word 'shop/' so just http...