php

PHP : Creating a folder in the registry

How do I create a new registry value using PHP? The following code doesn't work: function registry_write($folder, $key, $value, $type="REG_SZ") { $WshShell = new COM("WScript.Shell"); $registry = "HKEY_LOCAL_MACHINE\\SOFTWARE\\" . $folder . "\\" . $key; //$result = $WshShell->RegRead($registry); $result = $WshShell->RegWrite(...

Are PHP processes called via AJAX cancelled on "ESC"?

If I do an AJAX call, would the AJAX call be canceled if the user pressed "ESC" or leaved that page? If the AJAX call gets canceled, would my PHP script continue to run until it finished what it was doing (provided time limit doesn't get reached or any other server configuration stops.), or would that process get killed at the same time...

ajax woes. Submitting without refreshing. I need help.

I'm having problems submitting my ajax form. I am used to the old fashioned way with refresh but this new stuff is beyond me for the time being. It's time to start learning new technolohies. I have an autosuggest box that is getting my results from a database and populating the textbox just fine. When I designed this about 6 months ago,...

How do I remove blank lines from text in PHP?

I need to remove blank lines (with whitespace or absolutely blank) in PHP. I use this regular expression, but it does not work: $str = ereg_replace('^[ \t]*$\r?\n', '', $str); $str = preg_replace('^[ \t]*$\r?\n', '', $str); i want result of: blahblah blahblah adsa sad asdasd will: blahblah blahblah adsa sad asdasd ...

Eloqua web services API in PHP?

does anyone have any code samples/tutorials for using the Eloqua web services api in php? ...

open_basedir not having any effect

For my web hosting panel, users need to be blocked from accessing files outside their own directory (/var/www/u/s/username). I tried to use this line in httpd.conf to prevent people from going up a directory. php_admin_value open_basedir .:/usr/lib/php5 But in php.ini, it seems to have no effect. What am I doing wrong? ...

PHP: Buy both and save $50?

OK my client wants to show a buy both feature in the cart, if they have 1 particular item type in the cart they want it to show up for another particular item type so if they buy both they can save $50 off the total. I am trying to wrap my head around what would be the best way to set this up so it couldn't be easily hacked (ie: adding b...

Using mod_rewrite to convert folders to querystring

What's the easiest way to convert these requests: http://www.example.com/en/ http://www.example.com/en/index.php To: http://www.example.com/index.php?language_id=en There's various PHP files, so the rule would also need to map http://www.example.com/en/anyfile.php To: http://www.example.com/anyfile.php?language_id=en The lang...

phpmyadmin security

I have a production server with apache2, php, mysql. I have just one site right now (mysite.com) as a virtual host. I want to put phpmyadmin, webalizer, and maybe webmin on there. So far, I installed phpmyadmin, and it works but the whole internet can go to mysite.com/phpmyadmin How can I reduce the visibility to say 192.168.0.0/16 so...

How do I run unit tests stored in my application direcotry as opposed to in the PHP directory?

I've just installed PHPUnit and wrote a quick class which I saved to C:\PHP and it worked fine. If however I move the php file containing the test class to the tests directory of my application, it returns the error Class firstTest could not be found in .. How do I resolve the problem such that it can see the class in the application t...

Can IIS supporting ASP.NET and LAMP supporting PHP coexist on the same server?

Can IIS supporting ASP.NET and WAMP supporting PHP coexist on the same server? We already have a WAMP stack setup on a Windows Server 2003 box to support some internal PHP applications, and I want to also setup CI Factory on that box which will try to configure IIS to support it's ASP.NET based dashboard. I want to make sure that there...

INSERT 6000 Rows - best practice

I have a PHP script that calls an API method that can easily return 6k+ results. I use PEAR DB_DataObject to write each row in a foreach loop to the DB. The above script is batch processing 20 users at a time - and although some will only have a few results from the API others will have more. Worst case is that all have 1000's of resul...

Gmail like file upload with jQuery

I would like to upload files just like google mail does. I would want to use jQuery and PHP to do it is there anyway of getting the progressbar etc.? Here I added a video of how google does it. http://dl.getdropbox.com/u/5910/Jing/2009-04-02_1948.swf No flash, no perl or cgi please.. I guess I can live without the progressbar now I am...

How can I hide file extensions in PHP?

I'm using the jquery plugin jqueryFileTree with the PHP connector (slightly modified to give directories individual classes) to show the contents of a directory. I want to, however, hide all file extensions. Has anyone done something similar? I can think of one or two ways of implementing it but they seem overly-complicated... Is there...

How can I have PHP avoid lazy evaluation?

I have an interesting question about the way PHP evaluates boolean expressions. When you have, for example, $expression = $expression1 and $expression2; or if ($expression1 and $expression2) PHP first checks if $expression1 evaluates to true. If this is not the case, then $expression2 is simply skipped to avoid unnecessary calcul...

Reproduce Smarty foreach with Php preg_match_all

Hi, I would like to reproduce the "Smarty foreach" comportment. The tpl file content is ($tplContent) : {foreach from=$tabMethodTest item=entry} /** * @todo Implement test{$entry.name}(). */ public function test{$entry.name}() { $this->markTestIncomplete("This test has not been implemented yet."); } {/fore...

How can I use a reset button for php form?

I've got a form that I'm handling with PHP. Before the user submits it, the Reset button works. But when they submit and the page reloads (I've made the form fields sticky based on the $_POST values) the reset doesn't work. How can I fix that? EDIT: For example, a checkbox on the form: <input type="checkbox" <?php if (isset($_POST['c...

PHP "implode" error when submitting form

Just noticed I get these errors if I DON'T select a checkbox and submit: Warning: implode() [function.implode]: Invalid arguments passed in /home/content/o/l/t/oltvcb/html/feedback_mtg.php on line 148 Warning: Cannot modify header information - headers already sent by (output started at /home/content/o/l/t/oltvcb/html/feedback_mtg.php:...

Why can't I connect to my sql database? I get the error message: "Can't connect to local MySQL server through socket"

I just moved my site to a new web host, and after changing the database-login file, it still can't connect. I get the following error: Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /usr/www/users/simpleof/index.php on line 91 I changed the password and tried a...

HTML Class with <select>

I'm trying to design a Form class in PHP. So far, I have the <input> buttons pretty well working. But the <select> boxes have me stymied. I'm trying to figure out a "generic" way of adding the <option> tags, and am lacking the creativity. I'm not asking for teh codez, but implementation ideas are welcome. ...