php

Convert Dashes to CamelCase in PHP

Can someone help me complete this PHP function? I want to take a string like this: 'this-is-a-string' and convert it to this: 'thisIsAString': function dashesToCamelCase($string, $capitalizeFirstCharacter = false) { // Do stuff return $string; } ...

Slicing a time range into parts

First question. Be gentle. I'm working on software that tracks technicians' time spent working on tasks. The software needs to be enhanced to recognize different billable rate multipliers based on the day of the week and the time of day. (For example, "Time and a half after 5 PM on weekdays.") The tech using the software is only requi...

Signs that a SQL statement is dangerous

Hi, I want to develop a function in PHP that checks how dangerous a SQL statement is. When i say dangerous i mean, certain symbols, characters or strings that are used to get data from a database that the user shouldnt see. For example: SELECT * FROM users WHERE userId = '1' can be injected in several ways. Although i clean the par...

Why doesn't this PHP execute?

I copied the code from this site exactly: http://davidwalsh.name/web-service-php-mysql-xml-json as follows, /* require the user as the parameter */ if(isset($_GET['user']) && intval($_GET['user'])) { /* soak in the passed variable or set our own */ $number_of_posts = isset($_GET['num']) ? intval($_GET['num']) : 10; //10 is the default ...

How to transcode Windows-1251 to UTF-8?

How to transcode Windows-1251 to UTF-8? Will such function do it? function win_to_utf($s) { for($i=0, $m=strlen($s); $i<$m; $i++) { $c=ord($s[$i]); if ($c<=127) {$t.=chr($c); continue; } if ($c>=192 && $c<=207) {$t.=chr(208).chr($c-48); continue; } if ($c>=208 && $c<=239) {$t.=chr(208).chr($c-48); continue; } if ($c>=240 && ...

guides for writing php libraries?

i have studied design patterns and want to use them to code an open source library (not an application). but i have never coded a library before and don't know where should i include files, should i have a bootstrap file that loads everything or should every class load their own classes they are dependent on etc. are there any tutorial...

get property from XML using PHP

Hello, I am using PHP's SimpleXML to get some values out of the following XML; - <entry> <id>http://www.google.com/m8/feeds/contacts/email_address%40gmail.com/base/0&lt;/id&gt; <updated>2010-01-14T22:06:26.565Z</updated> <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contac...

checkbox checked with php form post?

how do I check a checkbox? I've tried 1, On, Yes that doesn't work. putting the worked "checked" alone works but then how do I check with php after form post of the checkbox is checked? <input type="checkbox" class="inputcheckbox" id="newmsg" name=chk[newmsg2] value="1" /> ...

HTML form -> Flash submit button -> Set a PHP variable in flash button -> Submit form

Okay, I'm sorry that this is pretty complicated, but it shouldn't be that hard to solve... Here's what I want to do. I have an HTML form that I want to upload to MySQL with PHP. That part's easy, but the thing is I want the submit button to be a Flash object. Somehow I need the Flash button to submit the form, but I think I can figure t...

Slow Speeds when unzipping with PHP onto a NFS, how can I speed it up?

Hi, I'm trying to figure out how to boost my NFS speed and php uploads. File is uploaded to the webserver's local tmp dir With PHP I copy the file userxxx.zip to the NFS With PHP I extract the userxxx.zip on the NFS to another dir on the NFS. What I'm finding is the file is in Step 3, the file is being read through the NFS by the web...

How to forward/redirect an HTTP PUT Request with PHP?

Hi, I receive HTTP PUT requests on a server and I would like to redirect / forward these requests to an other server. I handle the PUT request on both server with PHP. The PUT request is using basic HTTP authentication. Here is an example : www.myserver.com/service/put/myfile.xml redirect to www.myotherserver.com/service/put/myfi...

What is better for PHP developers - Unicode or UTF-8?

What is better for PHP developers - Unicode or UTF-8? I am going to create an international CMS. So I am going to have clients all over the world. They will speak all possible languages. What encoding format is better for browser recognition and for DB data storage? ...

how to generate unique title like wordpress?

hye im maya, i need to generate unique title like wordpress. if title hello-world is exist,the next title will be hello-world-2 thanks ...

limit number of images in a row?

Hey all i have a set of images that i want to show where they are saved into my database as linked, where each images has its thumbs, now i have used limit inquery to show a small number of images where the user needs to go next to show the other, my question is that how can i arrange those images where 4 images in a row and 3 columns ...

How can I simply change the Timezone Offset with Zend_Date?

I'm using Zend_Date to manage dates/times in a scheduling app. The only way I'm able to determine the user's Timezone is via Javascript which only gives a Timezone Offset. Zend_Date only seems to take Timezones in the 'America/New_York' format. Is there a way to get the users timezone in this format or set the Timezone Offset with Ze...

Getting $_POST variable from table

I'm trying to build a sort of resource allocation form. I'd like to be able to print a table from a database, and then allow users to click on each cell that they would like to reserve. Also, being able to drag and select multiple cells. Then send all of this via $_POST to another php script. Problem is, I have no idea where to start. ...

is there a way to see what code is executing when revoking a method?

to learn a library/framework i think the best way would be to use a class method and then see what code is executing in live. then you see the method chain (input and output of each) and can also read the comments. is there a such feature in any IDE or external application for php? ...

Can someone give me some basic XSS and sql injection scripts? (not what it seems)

I am testing out my scripts to see if they will prevent xss and sql injections. Can someone provide me with some basic but good scripts that would "hack" into my programs. I want to test my scripts before it goes online. EDIT: Thank you all for those links, they contain loads and loads of information. But for a beginner to security, is...

Eclipse for PHP, need to know the supporting files?

I have download eclipse for php in winodws, i am new to this, can anyone tell me, like how to run a php program in eclipse environment I need to know the dependencies, i need to install to run eclipse and also tutorial if possible, Regards, RAVI ...

WordPress - How to get posts in a category but exclude those under sub categories?

Assuming the category is A, there are a sub category of it say subA which includes a post postinsubA Then when i use get_posts('category=A&...'), all posts under category A also postinsubA are returned, but i don't wanna postinsubA, how can i exclude these posts in sub categories? ...