php

How do you past post data without the name value for inputs?

passing post data using cURL requires that the name of the input. However, I was wondering how can you do it if the input was not assigned a name? curl -d "user=foobar&pass=12345&id=blablabla&ding=submit" http://www.formpost.com/getthis/post.cgi ...

How do I remove a directory that is not empty?

I am trying to remove a directory with rmdir, but I received the 'Directory not empty' message, because it still has files in it. What function can I use to remove a directory with all the files in it as well? ...

Browser performance question.

Using an adapted version of jquery.inplace.js for some page creation and use an OBDC connection in the background php file to query for content. Everything works, BUT... I am surprised that IE6, 7, or 8 are all pretty quick, as is chrome, but firefox seems to take quite a few seconds for exactly the same task, in this case. This is wit...

[PHP]: Search on files in a folder.

I have a search box on my site. If a student enters some text, the script must search for files with that type of name in a folder. How to read folder and search for files? ...

Flex: Output of a C file in real time via PHP+Flex?

I have a C executable (named myprogram). When I run it by ./myprogram I get some output statements on the standard output of my Linux shell. I used run.php to get access to whatever is being printed to the standard output: #run.php <?php $output = shell_exec('./myprogram'); echo $output; ?> Then I called an HTTPService having id="ser...

how to find number of mondays or tuesdays between two dates?

I have start date and end date. I need to find out the day that is Sunday or Monday etc dependent upon user click on check box. How can I find/calculate that in PHP? ...

Dealing with path issues with PHPUnit

I've just started to use PHPUnit, but I've run into a bit of a snag. My code uses $_SERVER['DOCUMENT_ROOT'] to compute paths for includes, which works when my apache server is the one running PHP, but DOCUMENT_ROOT is not set when I run phpunit from the command line with "phpunit Tests", so these includes don't work. Am I missing somet...

PHP exec() function

Hi All, I developed a program on windows xp and I used exec to run a ".bat" file and it worked fine. I copied the exact program on windows 2003 and the bat file didn't run. I used echo before the exec function and it seemed to work fine, I mean it echoed : D:\xampp\htdocs\x>RunDLL32.EXE printui.dll,PrintUIEntry /y /n "HP LaserJet P2015 ...

Using jquery to get google "results 1-100 of about" ??? "for..." value

Hello, I have a question. How could I get the data from a google search response? I.e.:Results 1 - 100 of about 230,533,709 for blogs. (0.25 seconds) I want to get the value 230,533,709. I use php to get the html response from the url. I.e.: http://blogsearch.google.com/blogsearch?hl=en&amp;ie=UTF-8&amp;q=blogs&amp;btnG=Search+Blog...

What's the all fit header to show images?

header("Content-type: image/gif"); readfile($filename); The above can only be used to show gif images. Is there a header that can be used to show jpg/png/gif? ...

Trimming a parameter in the function header

A function header looks like this function doit($theparam){ //$theparam is untrimmed $theparam = trim($theparam); //$theparam is now trimmed } Is it possible to do the trimming on the first line itself? I tried those 2 but neither worked. function doit( trim($theparam) ){ //access trimmed version } function doit( $thepara...

data storage and retrieval in the database

in PHP while using a form the details what we enter has to be stored in the database... is it like the data gets stored using any encoding scheme in the database...bcoz when i use a different language except English the storage shows some absurd codes in the DB...but when I retrieve the data..it comes as I had enetered in standard Englis...

SQL: Insert only new rows/records into a table?

I'm parsing a json feed routinely and need to insert only the newest users from the feed and ignore existing users. I think what I need is ON DUPLICATE KEY UPDATE or INSERT IGNORE based on some searching but I'm not quite sure which is why I'm asking - so for example: users 1 John 2 Bob Partial JSON: { userid:1, name:'John' ...

Php reg exp: Matching repeating pattern

Hi I want to match strings like those below. abc|q:1,f:2 cba|q:1,f:awd2,t:3awd,h:gr I am using php and have tried both preg_match and preg_match_all with this expression. /^([a-z]+)\|([a-z]+:[a-z0-9]+,?)+$/iU This only returns the first part before the pipe, and one a:1. What am I doing wrong, why is it behaving this way and how c...

Order alphanumerical list in PHP

HI, i need to order a list in PHP that looks like: B1200 120A81 00A12 00A22 C100B C100C ordered list would be: 00A12 00A22 120A81 B1200 C100B C100C I was thinking about splitting each line in multidimensional arrays and order it but i am stuck and maybe theres a completely different way for that. Thanks! ...

Sorting an array / a variable by first letter in PHP

How can you sort the following word by the given rule? Example data is saapas which I want to be either aaapss or in the array s a a p a s and then somehow a a a p s s The function arsort with sort_flags SORT_REQULAR and SORT_STRING did not work for me. ...

Load big XML files to mySQL database (PHP)

Hello There, For a new project I need to load big XML files (200MB+) to a mySQL database. There are +- 20 feeds i need to match with that (not all fields are the same). Now when i want to catch the XML I get this error: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 171296569 bytes) in E:\UsbWebserve...

I have .Net code uses byte array and get sha1 value but in php i cannot use array to sha1

I have .net code that need to be converted to PHP but I got value $bytearray[] in php need to do sha1 how to do that in PHP.... Pls help ...

With PHP/GD, how do I trim an image?

I want to mimic the trim behavior of Photoshop (crop the area that is covered by the same color on all sides) with GD and PHP but I'm lacking ideas on how to accomplish this. If someone has any idea on how to do this I would very much like to hear it. Thanks in advance. ...

Square root in PHP

Why is the output of sqrt not an integer for "16" in PHP? Example php > $fig = 16; php > $sq = sqrt($fig); //should be 4 php > echo $sq; 4 php > echo is_int($sq); // should give 1, but gives false php > I feel that the problem is in the internal presentation which PHP hides similarly as Python. How can you then know when t...