php

Debugging memory usage in mod_php

I have a request handler running in apache/mod_php which occasionally expands beyond the maximum allowed memory usage (ie, the memory_limit definition in in php.ini). Handling this request calls proc_open() to run external commands. Is the memory usage of those commands counted "against" the requests memory usage? Beyond that, what are...

how to dump mysql table relations in PHP

Hi all; I searched a lot but could not find a way to dump table relations like one-to-one, one-to-many vs in PHP. Is there a way to handle this issue in PHP? A result might be: array( 'tableA' => array( 'one-to-one' => array('tableB', 'tableC'), 'one-to-many' => array('tableD'), 'tableB' => arra...

How do I input data into <input> form using PHP?

Okay, basically, I have a large list of phone numbers in a text file and I need to submit them all into a website by copy and pasting the phone number into the input form on the website and hit submit. Now, how can I automate this using PHP? I have no access to the website with input form. ...

How to detect auto responders

I have written a php e-mail processing client that uses the IMAP protocol. I noticed that it processes auto responders like normal e-mails which is undesirable. Is there something in the mail header that would indicate that the e-mail is not from a human but from an auto/vacation responder? Any help would be appreciated. ...

php progress bar?

Is there a way to show a progress bar in php? I like to let the user know what the php script is doing. Here's an result example from my website http://www.bestsellprice.com/search.php?itemnum=0&amp;keyword=harry+potter+book I have a static loading image with some text that says "Loading...", when the page is fully loaded, I hide the l...

Php: Why is this code not working? Is it cookies problem?

I wrote some code to manage my wordpress mu website, but it seems to not work... It uses libcurl and is supposed to login and create new blog. After i load this script in my browser it only logs me in but no new blog is created and all urls on wp-admin are wrong (when i click on them, for example 'admin' or 'blogs' or 'users', etc i get ...

meta tag scraper

I'm trying to get meta tag information for each page on a particular site, preferable in a txt file. What's the simplest way of doing this? (I mean besides going to each page one by one, viewing source and then copying and pasting the tags, which would be the simplest but also wouldn't be any fun) ...

practical callback functions

How can callback functions help me in my development? Especially with PHP. I am new to php and to programming itself but I saw the power of callbacks in js libraries like jquery. I have worked with a callback in php but I was left asking a lot of questions about it: what is the scope of a callback function what parameters can I pass to...

Adding a key & value to all arrays within an array

Hey all, I would like to take this: $arr = array( array("top"=>10, "left"=>10), array("top"=>50, "left"=>30), array("top"=>60, "left"=>70) ); Run a function and have the result be: array( array("top"=>10, "left"=>10, "width"=>400), array("top"=>50, "left"=>30, "width"=>400), array("top"=>60, "left"=>70, "width"=>40...

XPath find a class?

In my webpage, there's a div class named Test. How can I find it with XPath? or am I doing it wrong? ...

How to sort an array in this way in php

like the function usort in php but if two members compare as equal, their key should be same. for example: $arrayToSort = array(2,6,1,3,3); after sort return array 1 => 1 2 => 2 3 => 3 3 => 3 4 => 6 ...

How can I get jQuery code completion in NetBeans?

I'm using NetBeans for PHP. When I edit a .js file, it gives me javascript code completion. How can I get it to also give me jQuery code completion? ...

Empty variable in PHP script causes IIS7 to throw an HTTP 500 error

I am running IIS7 and PHP5 locally on my machine and the code above will cause IIS to throw an HTTP 500 error. After a lot of frustration and confusion I figured out that any PHP script with empty variable will throw this IIS error. Below is an example of this: <?php $x = $y; ?> I find this behavior very odd and it breaks a large perce...

PHP error display removing all other content

On a development server here, a setting has been changed which makes any PHP error (of any level) only output the error message and nothing else. To demonstrate what I mean, here's a script to reproduce the error: <?php $array = array('a'); echo "Hello world"; echo $array[1]; echo $array[2]; echo "Goodbye world"; ?> What I'd expect fr...

php float calculation 2 decimal point

Hi everyone, Got another math calculation problem again. $a = 34.56 $b = 34.55 $a do some calculation to get this figure $b is doing rounding nearest 0.05 to get this figure what happen is $c = $b - $a supposedly I should be -0.01, but I echo out the $c is show -0.00988888888888 I try to use number_format($c, 2), but the output i...

PHP proxy/mirroring script

I'm looking for a way to use PHP and possibly .htaccess to create a proxy that would essentially create a "dynamic mirror" of one site. Example: http://myawesome.proxy/questions/ask would fetch http://stackoverflow.com/questions/ask and return it to the browser with absolute URLs properly rewritten. Then I could log in and submit a qu...

OpenSocial authentication from external application

I'm working on a web project that isn't all that dissimilar in principal to power.com, where I am attempting to unify several different social networking sites under a single website, allowing users to register once with the system, and then add as many of their individual social networking accounts (Facebook, MySpace, Orkut, etc) as the...

PHP - Getting rid of curly apostrophes

I'm trying to get rid of curly apostrophes (ones pasted from some sort of rich text doc, I imagine) and I seem to be hitting a road block. The code below isn't working for me. $word = "Today’s"; $search = array('&#8222;', '&#8220;', '&#146;'); $replace = array('"', '"', "'"); $word = str_replace($search, $replace, htmlentities($word, E...

MySQL Select entries with timestamp after X time

I am attempting to populate a list of records within the last X seconds of the server time. My current query is.. mysql_query("SELECT player.name FROM player, spectate WHERE (player.pid = spectate.player) && spectate.bid=$bid"); This works currently to retrieve all entries. My first thought was to select the time field as well. And...

Handling delays when retrieving files from remote server in PHP

Hello, I am working with PHP to access files and photos from remote servers. I am mostly using the file_get_contents() and copy() functions. Sometimes accessing a small text file or photo is almost instant, but other times it seems to get "stuck" for a minute on the same exact file. And sometimes it actually causes my script to hang,...