php

Accessible way to notify a user their session is about to expire

I have a site which authenticates a user for a given time period and on any subsequent page request that time interval is extended. I am wondering how to notify users their time is about to expire without using a js.alert() but also remain accessible. I have seen some sites where content will slide in from the top and not intrude the ...

How to handle php errors and exceptions centrally

Hi previously in PHP 4 i created a custom error handler (below) to handle my own triggered errors and general PHP errors. But now PHP 5 introduces Exceptions i.e. I'm leveraging PDO for database manipulation and I'm not sure how to handle both general PHP errors and these Exceptions? function errorHandler($errno, $errstr, $errfile, $e...

php newbie class help.

class Theme { function __construct() { } function load( $folder, $file ) { $theme_path = ROOTPATH . '/theme/' . $folder . '/' . $file . '.php'; require_once($theme_path); return TRUE; } } on index.php <?php require class.theme.php $theme = new Theme; $theme->load('site','index'); ?> ...

Wait on Event due to database update

Hi, i am using a MYSQL database as form of IPC datastore between web client and C code process on Debian linux. When web client writes some data to the mysql database via php script, i need my C code app to go and pickup that data. However i don't want the C app continually polling some flag to check if data is available. Is there anywa...

PHP script "update process" management tutorials

Hi, We are creating a php script project; which we will be selling to customers. The customers can host the script on their web server. We would like to develop an update or upgrade process for this script. Means if a customer is using the version 1.2 of the script and we have released the new version 1.3 of the script, the users w...

mysql database connection problem in php

final class MySQL { private $connection; public function __construct($hostname, $username, $password, $database) { if (!$this->connection = mysql_connect($hostname, $username, $password)) { exit('Error: Could not make a database connection using ' . $username . '@' . $hostname); } if (!mysql_select_db($database, $...

Any way to automate - for testing - a human-dependant action?

I wonder if there are any good / possible ways to automate - for a unit test perhaps - a human-dependant action on an eCommerce website? For example, could I have a macro or a script to simulate "can user put items in basket?" or "can user reach the payment gateway?". I am currently managing a very heavily used eCommerce codebase and w...

Checkboxes and Image Uploads not in $_POST var?

I have a form. In the form, there is an image upload plus a series of checkboxes. I am trying to loop through the $_POST vars to process them. When I do foreach($_POST as $key => $value){echo "$key $value"; } I only get 'input' $_POST vars outputted. The checkbox values and the image upload value are not. I am utilizing Code Ignit...

php 4 variable variables

Hi, $str='input_arr["username"]'; $input_arr=array(); $$str='abcd'; print_r($input_arr); When I run the above code it only prints Array(). I expected it to print Array([username]=>'abcd') What am I doing wrong? This is in php 4 by the way. Thanks a lot. Edit:What am I trying to do? $input_arr is supposed to be a static variabl...

Is it some bizarre heresy to use classes without objects?

This may be a silly question, but it's been bugging me. I've been writing what I believe to be procedural code, but I'm using classes which group together related public and private functions according to purpose. Instead of using objects and methods, I call the functions when needed with a scope resolution operator. ie: db::execute($s...

How to upload a file via ftp in PHP?

I have a form with html browse type and a submit button. I chose a file using browse button and submit the form. On form submission following code is called. $conn_id="myid"; $conn_id = ftp_connect ( 'server' ); $ftp_user_name="username"; $ftp_user_pass="password"; // login with username and password $login_result = ftp_login ( $conn_i...

how much effect does number of function calls have on performance?

Does calling more functions have any kind of noticeable effect of performance, or is trying to cut down on number of function calls a pointless premature optimization? Simplified Example: Is there any real performance example between this: function foo($var) { echo $var; } foo(); And This: function foo($var) { bar($var); } f...

Document Sharing App With MVC

Hello, I have been assigned a new task by the client, a document sharing application to be made as per MVC design pattern. Here are the requirements: Uploads and downloads files with a browser Store the document in db if that are more secure documents else store on the directory with options of password enabled or accessible with out ...

php, is int and GET or POST

Hi, why always i get false? even in a this situation: echo $_GET['id']; //3 if(is_int($_GET['id'])) echo 'int'; ...

PHP: substr ".."

So i have echo substr($message, 0, 30).".."; this line right now. As you can see the two dots after, is to show that there´s more and it has been cutted down to 30 chars, but how do i do so ONLY if it has been cutted down to 30 chars then it should echo the dots ".." else then dont show ".." ...

PHP:MySQL what if we don't close the opened connections

in PHP + mySQL $conn = mysql_connect("server","user","pass"); mysql_select_db("datbasename"); this is what we do to open a connection. and mysql_close($conn); this is what we do to open a connection. WHAT if we don't close the connections...what are going to be the effects after what CONDITION the opened connections a re automati...

checking for status transition

I've created a simple function which allows me to determine which status options a change can have. For example a status of 'Pending' can only be changed to 'Active', 'Rejected' and 'Removed'. In my class I store these as constants which reference the necessary record in a status column for purposes of comparison throughout the site. M...

PHP:MySQL - Security Threats

Possible Duplicate: What security issues should I look out for in PHP what are the SECURITY THREATS while using PHP connected with MySQL what STEPS should be followed\insured to maximize security ...

How to determine the amount of entries an array has?

I'm trying to loop through an array backwards, so I figured I could try $Array = Array("One", "Two", "Three", "Four", "Five"); For ($Entry = Amount_of_values($Array); $Entry = 0; $Entry = $Entry-1){ Echo $Array[$Entry] . " "; //Should be Five Four Three Two One } but I have no idea how to retrieve the amount of values in an array ...

10 different domain names with 2 php files only database query changes

i have 10 domain names which has 2 php files index.php, inside.php only query changes as per site id right now i am uploading 2 pages through ftp to 10 sites is there any easy way to do this? ...