php

How to submit a form using onChange

i need to submit values of 3 different options in a form, but I'm very inexperienced in using ajax. I have 3 different list of options/select values and whenever one of the option is selected it'll submit all the other 2 options. I've only managed to submit a single option but unable to submit the rest of the options. I need some expert ...

Hide index.php (or index.html) of an URL

When I type the address of my site in a browser (mysite.com), it redirects to mysite.com/index.php. Why not to index.html ? Because I changed it in the conf file in Apache 2.2 . Now I would like to hide the last "index.php" part. How do I do that ? Would it be different it was index.html than index.php ? Wouldn't be ugly if by lookin...

Adding a custom function to an already instantiated object in PHP?

What's the best way to do something like this in PHP?: $a = new CustomClass(); $a->customFunction = function() { return 'Hello World'; } echo $a->customFunction(); (The above code is not valid.) ...

PHP Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION

PHP Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in C:\Inetpub\wwwroot\webroot\www.novotempo.org.br\lib\Twitter.php on line 54 Hi, I´m Douglas from Brazil, and this above is my problem. The line is just a DEFINE.... this one : define('DEBUG',false); Searching the net I found that this usually occurs when yo...

DOMDocument & XPath - HTML Tag of each Node

Given the following PHP code using DOMDocument: $inputs = $xpath->query('//input | //select | //textarea', $form); if ($inputs->length > 0) { for ($j = 0; $j < $inputs->length; $j++) { $input = $inputs->item($j); $input->getAttribute('name'); // Returns the Attribute $input->getTag(); // How can I get the input,...

file_get_contents with HTTP: No such file or directory

I'm trying to execute a straightforward PHP call to load the contents of a web page: $result = file_get_contents("http://www.google.com"); The result coming back is a strange file not found error: Warning: file_get_contents(http://www.google.com): failed to open stream: No such file or directory in /var/www/html/test.php on line 5 I ha...

Inconsistent checkdate results

I have been working with the checkdate function within PHP. You can see the code that I have used at http://codepad.org/JY4hG7jo feel free to fork the code where you see fit. Basically, if I check a month with a leading zero for the months 08, 09 I get an invalid date response. However, when I run it through a loop to check all the mont...

OOP php5 structure

Hello. I have been trying to make OOP PHP5 code. But I think my attempts are clumsy. These are my questions: Is their a better, more leaner way to include database config information? Can I somehow get around having to declare $db = new Db() in every function I make? Should I use PEAR as database abstraction layer instead of Mysqli_da...

Best way to use PHP to encrypt and decrypt?

I plan to store foreign account information for my users on my website, aka rapidshare username and passwords, etc... I want to keep information secure, but i know that if i md5 their information, i can't retrieve it later to use. Base64 is decrypt-able so theres no point using that just plain off. My idea is to scramble the user and ...

Read only when the XML data is updated

Hello guys, I'm able to parse RSS with PHP - What I'm looking for is to be able to get only the updated content, and do nothing if there's no new update to the RSS. For example, I have this RSS File, and if there's no new content, nothing happens, but if there's a new content, I want to send my users the latest RSS update, and not res...

Entering Doctypes

I have a Document class that is responsible for holding the document that will eventually be gzipped and then printed onto the page. In that Document holds the document's DocType. The Problem I am facing is how to correctly implement displaying the Doctype. For example: I could create an array of popular Doctypes that are the most frequ...

Avoid PHP timeout when sending newsletter

Hi, I have recently implemented the Swiftmailer library, but the first time I used it, I got a php timeout error even though it only had to send out mails to around 300 people.. (I should mention that using the set_time_limit(0); workaround is not an option due to restrictions on the server) The way I use it is like this: $transport ...

openID login in cakePHP

I am using cakePHP framework to build a website in which I want to let users signin using openID. and there is no core component in cake to do this. is there any component for openID login that is it differente from cakePHP Auth component ? ...

Variable variables to call programmatically-created arrays

Hello, I am creating a series of arrays from template tags in a content management system, and outputting the titles of these arrays as arrays labeled with variables: <Loop> $<GeneratedArrayName1> = array( "foo" => "bar" ); $<GeneratedArrayName2> = array( "foo" => "bar" ); </Loop> I'm also generating another array of possible Gen...

Debugging the server side of an XML RPC call using Zend Studio and/or xDebug

I'm consuming an XML RPC service using PHP. The Server is also PHP and for development purposes it's running here on my local machine. I'd love to be able to step thru the XML RPC server code. Is there any way to do this? Logically I didn't think it would work, but just for kicks I tried setting breakpoints in the Server code and the...

nicer way to do this? (reading files in php)

Hi there, I just figured out how to read some files but I really don't like it. I have some files named 1.txt, 2.txt, 3.txt and so on. I need to read and print just the last 2 files. I found a way to do it but I would like to see some other ways to do it. My way: <?php $i = 1; $x = 1; while (file_exists('news/'.$i.'.txt')){ ...

Validity of Wordpress 'SEOs'?

Simple question: Am I wrong in reccomending against Wordpress SEOs? Now, I don't want to start a flame war or anything like that, but I'm just curious if my viewpoint is consistent with other developers / hosts out there. I work at a small company, and we specialize in Microsoft-based hosting and CMS solutions, particularly a popular o...

print_r to get object methods in PHP?

I'm working with Views 2 in Drupal 6, and I am having difficulty finding documentation on the methods of the View object. Is there any PHP function like print_r that outputs methods as well as fields? ...

equivalent of each() for mysql results, to mimic first loop of foreach()

Hi, I've seen in the code I'm working on, the following: foreach( $mysql_result as $row ) $site_id = $row->id; $mysql_result is, of course a mysql_result, so this foreach is equivalent to a while( mysql_fetch_row() ) Sometimes, the result is known to yield only one row, but the code still has a "foreach" so it gives the impression of ...

Changing upload_max_filesize on a shared webhost? (Apache, PHP)

Hello! I want to change upload_max_filesize on my shared webhosting account to something greater than 2M. Since I don't have access to php.ini, and apparently you can't use ini_set to change upload_max_filesize, I don't know what to do. Maybe something involving .htaccess? Thanks! ...