php

PHP Contact form editing

Im not a pro at PHP, just starting actually and was wondering if you could help me. Im trying to get this contact form to email me stating the Persons Name and the message like this. Name: Fred Blogs Message: Message, Message. But when I try all I get is the message, I cant seem to insert the name variable anywhere. This is the cod...

Casing an Array with Numeric Keys as an Object

I was poking around PHPs casting mechanism, and ran into an odd case when casting an array as an object $o = (object) array('1'=>'/foo/bar'); $o = new stdClass(); var_dump($o); As I understand it, PHP properties need to be declared with the same rules as PHP variables. That is A valid variable name starts with a letter or underscore...

Why is it a good practice to remove PHP files from the htdocs directory?

Why is it a good practice to remove PHP files from the htdocs/public directory? They are being parsed anyway, right? ...

Install zip extension for PHP --enable-zip on Mac OS X

I'd like to install the following but am not sure where I should add --enable-zip? Is there more to it than putting it in php.ini ? http://www.php.net/manual/en/zip.installation.php ...

Sorting a table in PHP

Hi, I have some difficulty sorting my array. It looks like this : [0] => Array ( [firstname] => Jnic [lastname] => Fortin [points] => Array ( [id] => 20453 [f] => 31 [r] => 7 [tota...

How to avoid blocking indefinitely when using a PHP script to update a DB table that has an open/pending transaction?

I have found that if I modify table X via SQLplus and don't commit the change, then if my web appliation (which runs as a PHP script under Apache in ModPHP mode) attempts to commit a change to table X it will block indefinitely until I commit my changes via SQLplus. This behavior is correct, but what I want is a clean/reliable/simple wa...

Automated Integration and Staging environments for LAMP-based application

What would be a good tool-for-the-job to do automated deployments of LAMP-based applications(MySQL, PHP, Zend Framework) to integration and staging environments? I am looking specifically for tools that handle deployes to remote hosts. I assume building tools such as phing and ant I assume could be used for that, but I was wondering if t...

How do i get out of the habit of procedural programming and into object oriented programming?

Hiya all, I'm hoping to get some tips to kinda help me break out of what i consider after all these years a bad habit of procedural programming. Every time i attempt to do a project in OOP i end up eventually reverting to procedural. I guess i'm not completely convinced with OOP (even though i think i've heard everything good about it...

Javascript not working on Blackberry

Have a script that using jquery validation. Tested on 2 Blackberry's and neither worked properly. http://andrewpeller.com/contest/indexTest.html 1st one - Blackberry Bold Email validation would not work even with valid email such as [email protected] 2nd one Form would not submit at all. Any suggestions as to how to get this to wo...

Post form data to external url + curl

Hello all, I have this form that I am trying to use to post data to an external url. I do have some very basic knowlegde of using php curl. So far if I use this code that I have written: <?php if ($_POST['request_callback']) { $customer_name = cleaninput($_REQUEST['customer_name'],"text"); $debtor_id = cleaninput(...

i18n/gettext : setlocale configuration in web applications

So I started messing around with gettext but I'm still puzzled about certain things, would be great if anyone could help me out and fill in the gaps for me. Usually most of the implementations just invoke setlocale based on a language parameter. Is there any case in which I need to use putenv, perhaps for edge cases on Windows setups? ...

What is the business best practice on validating filename?

I have a "dilema" and wonder what is business best practice. I'm using Uploadify to upload images. Now I need to validate the filename before saving the file. I've looked at different solutions, but can't get down to one good solution. Here are my criterias: Filename must be all in lowercase Filename can only contain charaters [a-z0...

Running background processes after a web request

I'm interested in kicking off processes after a web request, or possibly forking a new process after the initial thread is finished. I would prefer not to use a cron, because of the nature of the the jobs I'll be running and how often they need to be run, waiting a minute to refresh is not an option. I'm considering a few ways of doing...

Mobile version of a website/web application using php...???

Hello.. I was working on a website in which user can upload videos and images etc etc and can view his images and videos etc etc..Whatever the thing is image uploading/ add video via youtube link. or view image and view video added Now i want to make a same website havin its mobile version means user can add upload videos and images fr...

php __DIR__ to other location

Hi, Say I have echo realpath( dirname(__DIR__) ); that points me to /usr/location How can I use the same mechanism to point to /usr/otherplace? Thank you, Tee ...

Is it possible to parse PHP using PEG?

The question is very straightforward: Is it possible to parse PHP using PEG? I want to use a PEG parser-generator to parse PHP. Please kindly advise. Thank you! ...

Cleaner PHP Random Text

Playing around with generating text randomly with each page refresh using php. Is there a cleaner way to approach this? Also, can this be done with jquery? <?php $random_text = array("Random Text 1", "Random Text 2", "Random Text 3", "Random Text 4", "Random Text 5"); srand...

PHP, does "else" always get processed?

I have a rough program sketched thusly: if (condition){ //redirect to some page } else{ echo $some_var; } So when I test is and the condition is true, it does the redirect, but also throws notices that there are undefined variables $some_var (that are pulled from a DB and WON'T be defined if the condition is true). So does the cod...

PHP Cannot write to file even though it has 777 permissions

Im trying to make a php file write to a file that resides in the same folder. Both the php file and the file its trying to write to have their permissions set to 777 (its a linux server) as well as the folder they reside in. Whenever I called fopen() with the 'w' or 'w+' mode, the function just returns false. Its on my school's webser...

Which is the better client for Solr + PHP?

I have two options http://www.php.net/manual/en/book.solr.php http://code.google.com/p/solr-php-client/ I read it somewhere that that 2) use JSON as output types whereas 1) use XML doc. Isn't that a property of Solr which returns doc both in JSON and XML? What other features do I have to consider before deciding? ...