php

Use simplexml_load_file php funcion to load gmail feed

Hi all, I need to connect my php script to Gmail Atom feed to retrieve the count of unread messages, but I have problem on get the xml feed file: if($xmlGmailFeed = simplexml_load_file("https://USERNAME:[email protected]/gmail/feed/atom/")) $unreadMessages = $xmlGmailFeed->fullcount; gives: failed to load external entity ...

PHP mail function return Server Error

Hi, I am a PHP newbie coder. Currently I am studying the mail function of PHP but the function always give me error such as Server error. I don't know if I have to install a software or configure the server first. By the way, I use Phpdev for my development environment. if(mail("[email protected]", "Hi","This is a test")) { echo "Success...

Disable output buffering on my local xampp server

For some reason my xampp server is buffering the output of my php. I want it to spit it out as it goes. Anyone any ideas which settings I need to change to achieve this? Thanks ...

How to get the disk space on a server ?

Hi, I should to develop a web-application in php for a firm, and I need to know the disk free space of the server. At the moment, I'm able to obtain the free disk space of this kind : $quota="104857600"; //100Mb : (100*1024*1024) after, I do the difference between $quota and my size variable. So, in this case, I must to write the ...

What does this simple php code do?

I was browsing a worpress site, and spotted this line <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(1) ) : else : ?> <li id="recent-posts"> <ul> <?php get_archives('postbypost', 5); ?> <ul> </li> <?php endif; ?> What do the colon before and after else do exactly?? How does this th...

PHP: Cache RSS data to avoid requesting it everytime the page loads.

I'm parsing data from this RSS feed: http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&amp;locCode=SAM|AR|AR005|MONTE%20MAIZ, The data there updates once every hour. To parse it, I load the RSS at the initialization of my class and convert it into an usable object. The problem with this is that every time the page loads, the ...

PDO: Transactions don't roll back?

I am going through this tutorial about PDO and have come to the point about transactions. Skipping the connection parts, I have this php code: try { $db->beginTransaction(); $db->exec('DROP TABLE IF EXISTS animals'); $db->exec('CREATE TABLE animals (' .'animal_id MEDIUMINT(8) NOT NULL AUTO_INCREMENT PRIMARY KEY,' ...

Newbie Programmer needs Motivation

Hi, I'm starting to teach myself computer programming. I am interested in developing a website using PHP but I don't know what kind of concept I should develop. Please advise me on any good ideas for how I can improve my programming skills. Many Thanks. ...

preg_match_all image source

I have the following regex expression which is to extract the source of any img tag in HTML. /(<img).*(src\s*=\s*"([a-zA-Z0-9\.;:\/\?&=\-_|\r|\n]{1,})")/isxmU However, it doesn't appear to be matching the following: <IMG SRC='http://www.mysite.com/pix/lens/mtf/CAEF8512L.gif'&gt; How can I build it to match this as well? ...

Finding the right name for an include that is to be executed before HTML output

I am defining naming conventions for a simple plugin framework. For example: index.php - the main plugin file info.php - returns an array with plugin information install.php - self-explanatory can you think of an elegant, short-hand name for a PHP file that contains the code that is to be executed before any HTML is output? Do any ex...

array_unique for objects?

Hi! Is there any method like the array_unique for objects? I have a bunch of arrays with 'Role' objects that I merge, and then I want to take out the duplicates :) Thanks ...

perl to php translation

How do you translate this perl subroutine into a PHP function? sub disagreement { my $disagreement = 0; my %aggregate = () ; foreach my $item (@_) {$aggregate{$item}++} foreach my $cat_a (keys %aggregate) { foreach my $cat_b (keys %aggregate) { if ($cat_a != $cat_b) {$disagreement += $aggregate{$cat_a} * $aggregate{$ca...

How do I sort a multidimensional array by one of the fields of the inner array in PHP?

Suppose I have an array that mimics a dayabase table. Each array element reporesents a row and within each row is another array that contains the field names and values. Array ( [0] => Array ( [name] => Sony TV [price] => 600.00 ) [1] => Array ( [name] => LG TV ...

Why is my php script freezing?

What is causing my php code to freeze? I know it's cause of the while loop, but I have $max_threads--; at the end so it shouldn't do that. <html> <head> <?php $db = mysql_connect("host","name","pass") or die("Can't connect to host"); mysql_select_db("dbname",$db) or die("Can't connect to DB"); ...

filemaker.php next/previous buttons on record detail page

I'm using filemaker server 10 and the filemaker.php API. on the record detail page, I'd like a "next" and "previous" button to allow browsing the next/previous buttons easily (without having to go back to the list view). is this possible and how? thanks ...

How do I copy files repository to new folder with PHP

I have a folder named "repository" in my admin folders. This folder holds 2 files: index.html and content.php. When a user creates a new page the php creates a new folder specified by the user then will need to copy the two files into that folder while leaving them in the repository. copy(file,dest) does not work. rename(file,dest) move...

PHP getopt Operations

This question is regarding getopt function in php. I need to pass two parameter to the php scripts like php script.php -f filename -t filetype Now depending upon the file type which can be u, c or s I need to do proper operation. I am using switch case for the same: Here is the Code I am using: // Get filename of input file when e...

PHP: What does __('Some text') do?

Reading about Kohana templates and saw soemthing I've never seen before: $this->template->title = __('Welcome To Acme Widgets'); What does __('Text') mean? What is it? What does it do? ...

Cross domain cookie tracking

Hi, The company I work for has four domains and I'm trying to set up the cookies, so one cookie can be generated and tracked across all the domains. From reading various posts on here I thought it was possible. I've set up a sub domain on one site, to serve a cookie and 1*1 pixel image to all four sites. But I can't get this working ...

mysql connect not working with PHP

Any idea why the following code is not working mysql credentials are correct, have verified from command line. The second connection fails i.e., $conn1 . I am clueless !!! $conn = mysql_connect($hostname, $username, $password) or die("Connecting to MySQL failed" . mysql_error()); $conn1 = mysql_connect($hostname, $username1, $...