php

javascript function arguments in Jquery

Dear all I am using the JQuery and Javascript.I have onclick event ,that calls the javascript function. How to extract the arguments of function_A and function_B in JQuery And Is it Any Best way to do It? I need to Do ajax Call after javascript Click.Is any performance based issue ...

NetBeans PHP and XDebug - jumping to methods on call stack?

Hi everyone, I'm having trouble with debugging a PHP project through NetBeans using XDebug, and was hoping someone out there might have had this problem before. Debugging works fine for the requested php file - so if I go to index.php on the remote server, I can put a breakpoint anywhere in index.php in NetBeans and the code stops there...

PEAR Mail_Queue sending duplicate emails

Here's a couple of questions: Is mail_queue->put supposed to insert a message twice in the database? The only differences are the time_to_send value and the user_id. This is what I get for a single message for one user: 1. user_id = 1, time_to_send = 2009-02-10 14:02:02 2. user_id = -1, time_to_send = 2009-02-10 14:00:02 The first o...

How do I implement a screen scraper in PHP?

I have a user ID and a password to log in to a web site via my program. Once logged in, the URL will change from http://localhost/Test/loginpage.html to http://www.4wtech.com/csp/web/Employee/Login.csp. How can I "screen scrape" the data from the second URL using PHP? ...

How do you refactor a Codeigniter controller function that is too long?

I have a function in my controller that has grown longer than I'd prefer and I'd like to refactor it to call a few discrete functions to make it easier to manage. How can I better organize a long function in a Codeigniter controller? What I've tried: I know you can create private functions in a controller by naming them with a leading ...

Problem with php function to catch error on saving image

I have a method to save an image, which is meant to deal gracefully with an error, setting $imageSrc to a particular image in the event of failure. My method works fine if the image is present, but no error conditions seems to be handled correctly. $imageSrc = save_pic($PIC_URL, $pk); function save_pic($pic_url, $pk) { $imageDir = ...

Inheritance of static members in PHP

In PHP, if a static attribute is defined in the parent class, it cannot be overridden in a child class. But I'm wondering if there's any way around this. I'm trying to write a wrapper for someone else's (somewhat clunky) function. The function in question can be applied to lots of different data types but requires different flags and o...

PHP Regex Question

Would it be possible to make a regex that reads {variable} like <?php echo $variable ?> in PHP files? Thanks Remy ...

handling timestamps with PHP and MySQL(have I got my theory right?)

Hi I've been researching timestamps in PHP & MySQL. My undertanding is that UNIX timestamps only exist in GMT ... the whole point being that you convert it into the users timezone (GMT +/- timezone = users localtime). I'm doing this successfuly by saving the timestamp in it's "raw" form (as a 10 digit long int) and converting it into l...

<?php instead of <?

Why should I use <?php instead of <? in my php script? ...

How to get rid of . and .. while scaning the folder creating an array in php?

If you scan a folder containing other folders AND files, how do you get rid of . and .. and files? How do you put in array only folders WITHOUT . and ..? I would like to use regular expression, but I'm newbie and I can't get it right. My code is now this but doesn't work: if(fnmatch("\.{1,2}",$dir_array[$i]) || is_file($dir_array[$i]...

How to do a PHP nested class or nested methods?

How can I do this in PHP $myDBClass->users()->limit(5);//output you limited users to 5 $myDBClass->comments()->limit(3);//output you limited comments to 3 what I meant is nested methods or nested class (I don't know!) so when I call the limit method as a child of users it will know that I am calling it from "users" method -or class- ...

How to safely allow embed content?

Hi guys. I run a website (sorta like a social network) that I wrote myself. I allow the members to send comments to each other. In the comment; i take the comment and then call this line before saving it in db.. $com = htmlentities($com); When I want to display it; I call this piece of code.. $com = html_entity_decode($com); This w...

instantiate a class from a variable in PHP?

I know this question sounds rather vague so I will make it more clear with an example: $var = 'bar'; $bar = new {$var}Class('var for __construct()'); //$bar = new barClass('var for __construct()'); This is what I want to do. How would you do it? I could off course use eval() like this: $var = 'bar'; eval('$bar = new '.$var.'Class(\'v...

Dealing with dates

So basically I am storing a bunch of calendar events in a mysql table. And I store the day of the week they are supposed to happen, as well as the time. Right now the time is stored as the number of seconds from midnight calculated in GMT. But when I have people log on and check the calendar and they are from a different timezone othe...

PHP: Work out duration between two times

Ok, a really simple question but I am too thick to figure it out. I want to get the difference between two times. For example, "1:07" (1 minute and 7 seconds) and "3:01" (3 minutes and 1 second). It will only be ever minutes and seconds. I have been trying to make use of this: function timeDiff($firstTime,$lastTime) { // convert to uni...

Packages in PHP?

Is it possible to create packages of related class and have the same protected and private fields which are visible only to classes from the same package? Basically, the same type of packages as what Java has? Is it possible? ...

What does mysql_real_escape_string() do that addslashes() doesn't?

Why do we need a DB-specific functions like mysql_real_escape_string()? What can it do that addslashes() doesn't? Ignoring for the moment the superior alternative of parameterized queries, is a webapp that uses addslashes() exclusively still vulnerable to SQL injection, and if yes, how? ...

Zend Form: How do I make it bend to my will?

I've read the manual many times, I've scoured the posts offered by Google on the subject, I have even bought a couple of books that deal with ZF. Now, why am I still confused? I can, using Zend_Form, make a form that validates and functions fine. What I cannot do it make a form that looks exactly like I want it to look with the error me...

Tracking the script execution time in PHP

PHP is obviously tracking the amount of CPU time that a particular script has used (to enforce the max_execution_time limit). Is there a way to get access to this inside of the script? I'd like to include some logging with my tests about how much CPU was burnt in the actual PHP (the time is not incremented when the script is sitting an...