php

Is this the best approach to creating an audit trail?

I'm trying to create some functionality that keeps an audit trail of how data in a given user form has been changed over time, with a dated audit at the foot of that page. For example: 02/04/09 21:49 Name changed from "Tom" to "Chris". I'm doing this by storing the data in it's present format in the session and then on save checking ...

very basic nested php

I am trying to write a very simple statement that will make it so that, if users of my blog don't have a gravatar, an image chosen randomly will appear. The way it works now is like this: <?php echo get_avatar( $comment, $size = '78', $default = '/images/noavatar2.gif' ); ?> this will give me a random number: echo(rand(1,10) I w...

How to control the file permissions when the netbeans php plugin uploads a file with FTP.

Whenever netbeans preforms an ftp upload the files are uploaded with the permissions set to 640. This causes PHP to throw the following error: Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0 Fatal error: Unknown: Failed opening required '/Library/WebServer/Documents/notes/index.php' (include_path='.:/usr...

If no arguments are provided in the function, how do I test to see if it is left blank?

<?php /* Copyright Date --------------------------*/ function copyright_date($creation_year) { $current_year = date('Y'); if ($creation_year == $current_year || $creation_year == '') { echo $current_year; } else { echo $creation_year . '-' . $current_year; } } ?> If someone forgets to add the argu...

PHP: Retrying a query a set number of times or until success

I'm doing a query to the Alexa API which, for some unknown reason, will occasionally fail. When it does fail, I want to automatically retry the query, up to 10 times. When it fails, the response returned by the API contains the substring AuthFailure. What kind of loop can I do that will retry the query until either the response returne...

Building a "crosstab" or "pivot" table from an array in php

I have an array of objects defined similarly to the below: $scores = array(); // Bob round 1 $s = new RoundScore(); $s->Round_Name = 'Round 1'; $s->Player_Name = 'Bob'; $s->Score = 10; $scores[0] = $s; // Bob round 2 $s = new RoundScore(); $s->Round_Name = 'Round 2'; $s->Player_Name = 'Bob'; $s->Score = 7; $scores[1] = $s; // Jack ro...

How do have an RSS feed displayed in PHP

I have an RSS feed from a wp blog that I'd like to display in a series of non-wordpress, php based sites. Any recommendations on a pre-built widget I can use? ...

Why can't I use session_start() in my php script? It says headers are already sent.

Here are the first few lines of my page: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; <?php include_once "dblogin.php"; session_start(); $loggedIn = 0; if(isset($_SESSION["login"])) {$loggedIn = 1;} ?> I'm getting the following error: Cannot send session cookie - headers al...

Send email using GMail SMTP server from PHP page

I am trying to send an email via GMail's SMTP server from a PHP page but I get this error: authentication failure [SMTP: SMTP server does no support authentication (code: 250, response: mx.google.com at your service, [98.117.99.235] SIZE 35651584 8BITMIME STARTTLS ENHANCEDSTATUSCODES PIPELINING)] Can anyone help? Here is my code: <?p...

Loading multiple embedded flash apps onto an HTML page- problem with ordering

We need to load an embedded version of a site written in Flash, and not originally designed to load multiple instances of itself, on a HTML page. The specific issue is how to get them to load in order when embedded, given that they are all being opened by the same instance of the flash player. It's a complicated mapping application, and...

Updating Database Using Javascript.

Hi all, Hopefully this will be the last question I need to ask about this..lol.. I cant be too far of the working solution(hopefully..lol). In reference to this question: Pass data to database using javascript Onclick I am trying to pass a value to the database using javascript. Below is the code i am using. And just for visual aid, I...

PHP and htpasswd

I have a structure like this: /home /home/dir1 /home/dir2 Now when someone goes to /home, he is asked for username and password (in a form) and I set session information in PHP for the remaining files of /home. Now /home/dir1 and /home/dir2 are protected by htpasswd but the same username and password. I dont want the user to re-enter ...

JQuery help with checkboxes and their values

Hi everyone. I am very new to javascript and JQuery but I managed to get my first ajax script almost working 100%. Maybe today will be my lucky day and I can finish this up. :) Let me give you guys a sample of each file so you know what is what. I believe that my last try at figuring this out was not successful because I was confusing t...

How to find day of week in php

I am confused while using php to handle date/time. What i am trying to do is this. When a user visits my page i am asking his timezone and then displaying the 'day of week' in his timezone. I dont want wan to use browser's day. I want to do this calculation in php. This is how i am trying to achieve it. I use 1. The timezone entered...

How do you store database credentials in typical CMS build on PHP?

What's the best practice to store database credentials in a CMS? Now i declare them in my Database singleton class: $this->credentials = array("hostname"=>"hostname", "username"=>"username","password"=>"password", "database"=>"database"); But it's not so intuitive to search where to change them and also i'm planning to makre inmstall f...

merge images with text

Hello, Is there a way to put text on a png and then merge it wit a jpg / gif image? ...

ZF:How to access controller's Request object within Form method?

How to access Request object within Form method? I assume it's somehow possible to access controller's request object using ActionHelper inside Form methods, but writing a new class for such a task seems to be excessive. Or should I somehow save controller's Request to Zend_Registry and access Registry item in Form? ...

PHP complex uses - Interact with external devices.

Is it possible to access & control external devices in PHP? For example, would it be capable of changing the speed of a USB fan or change the direction of a wireless toy car. I'm trying to go beyond web dev and I'm wondering if the programming language I use is capable of handling my ideas or should I consider changing the environment....

Best way to secure data PHP + MYSQL

I'm building an app that will store some of our clients details, things like usernames / passwords, information that we need to remember and keep secure. What's the best method for storing this information securely? ...

php: file_get_contents encoding problem (SOLVED)

SOLVED by changing the encoding in header() function to KOI8-R header('Content-Type: text/plain; charset=KOI8-R'); My task is simple: make a post request to translate.google.com and get the translation. In the following example I'm using the word "hello" to translate into russian. header('Content-Type: text/plain; charset=utf-8'); ...