php

PHP SimpleTest - Handling Exceptions

Hi, I have a few simple classes used in a forum application. I'm trying to run some tests using SimpleTest, but I'm having problems with exceptions. I have a section of code which generates a custom exception. Is there a way to catch this exception in my test and assert that it is what I expect? This is the method within my class: p...

Escaping user data, without magic quotes

Hey, I'm taking a look at how to properly escape data that comes from the outside world before it gets used either for application control, storage, logic.. that kind of thing. Obviously, with the magic quotes directive being deprecated shortly in php 5.3.0+, and removed in php6, this becomes more pressing, for anyone looking to upgrad...

php code secuirty ?

If anyone can suggest secuirty techniques for php coding? how to make your php code more secure ? Thanks ...

Check if PHP function returns null or nothing

I have this code $return = $ep->$method($params); if ($return === null) { throw new Exception('Endpoint has no return value'); } return $return; Is there any way to distinguish between a method that returns null and a method that does not return anything? ...

Getting an error when trying to load a model

I'm loading a model for my CodeIgniter based website, but it keeps giving an error: "Fatal error: Call to a member function on a non-object in /nfs/c02/h05/mnt/30796/domains/planetchustar.com/html/arguit/system/application/controllers/home.php on line 8" Here's the part of code its referencing: function index() { $this->load-...

Why is filter_input() incomplete?

I am working a lot on a PHP-based CMS at the moment, and while I'm at it I would like to move all the handling and sanitation of user input to one central place. (At the moment, it's a $_REQUEST here, a $_GET there, and so on). I like filter_input() very much and would like to use it for basic sanitation, but I'm unclear as to whether t...

Create, Delete and Use e-mail accounts within a website! Is it possible?

Hello! I'm developing an administration panel (in php), for a website (in a shared host), to let the administrator to manage the personal infos of the employees! With this panel should be possible to create or delete an e-mail account for an employee and if the employee logs in the admin panel, he/she should be able to access to his/her...

What to avoid in php/mysql/ajax when relying on heavy reads/writes

Hi, i was wondering what the main things were to avoid when creating an webapplication that relies on heavy reads and writes every second. Think of online gaming where money is involved. For example you have an javascript that constantly updates the browser(1), There is a cronjob running that updates the db(2), There is user input subm...

PHP foreach glob to load images from a folder not working quite right

Hi, I need to load images from 2 different folders, each thumbnail has its associated large version (same name, different folder). I have 3 files in the large pics folder and 3 files in the thumbs folder and I'm getting 9 links! Each thumbnail gets repeated 3 times or x times the quantity of pics in the main folder This is the code: <?...

Resize image withour squash or strech with php?

Hi all; In a folder i have my main images ,i need some code in php that read all images from folder and resize it without squash or strech with php and put the resized images in a destination folder. Thanks ...

SELECT COUNT(DISTINCT name), id, adress from users

Hi, With PHP I'm trying to run a SQL query and select normal columns as well as COUNT. $sql_str = "select COUNT(DISTINCT name), id, adress from users"; $src = mysql_query($sql_str); while( $dsatz = mysql_fetch_assoc($src) ){ echo $dsatz['name'] . "<br>"; } The problem is that when I have "COUNT(DISTINCT name)," in my query, it ...

URL rewriting and GET forms in Apache/PHP

I enabled URL rewriting on my PHP site with Apache (http://example.com/index.php?param=12 becomes http://example.com/index/param/12). I have a few forms which are in GET instead of POST. After subitting the form, the resulting URL is not rewritten. Is it possibile to keep rewritten URLs after submitting a GET form? UPDATE: I found th...

How can I check if mysql table column even exists ?

How can I check if mysql table field even exists ? The column name is 'price' and I need to see if it exists. Haven't understood really how the 'EXISTS' works... Any examples or ideas ? Thanks ...

pass multidimentional array from javascript to php

Hi, Im running a javascript code which reads values from different XML files and it generates a multidimentional array based on those values. Now I need to pass this array to a PHP page. I tried different but it always pass the arrray as string not as an array. Anyone has an idea :( ... and thank you very much ...

What are the right uses for cURL?

I have already heard about the curl library, and that I get interest about... and as i read that there are many uses for it, can you provide me with some Are there any security problems with it? ...

Using Symfony's sfForm standalone, without the rest of the framework

I've seen some posts and questions regarding this: how can I use Symfony's sfForm as a standalone library? Just for managing a simple "hand-made" form but without the bulk of the framework. ...

Load method from current Controller

Hi there! I have a problem that I can't figure out. I'm building a small framework (practice) and now I'm building the Validator library. everything works superb except when I trying to fix the "callback" rule. Callback rule is used when the dev need to use a rule that dosen't exists in the Validator lib.. Here's how I'm doing it. In...

Exception re-throwing through layers and usage of status codes

Hi all! I searched for this for a long time (here too), have read many php codes, but still couldn't find a satisfying answer. It may seem a too wide topic, but it really sticks together - at last for me. Could you please help? In a php website I have PDO as DAL, what is used by BLL objects, and they are called from the UI. Now if some...

How to access value from within multi-dimensional object in php

Here is a slice of the array in question: Array ( [Pricing] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [MType] => A [PType] => JBN ) ...

MySQL: add created and modified fields

What's the best approach to add created and modified fields in MySQL: 1) using MySQL features like on update CURRENT_TIMESTAMP or 2) using PHP (or something else)? Why? If the answer is MySQL, how would you do this? Thank you! ...