php

Run code on creation of a PHP class?

I want code to run whenever I create a new object. For example, see this: <?php class Test { echo 'Hello, World!'; } $test = new Test; ?> I want it to echo "Hello, World!" whenever I create a new instance of this object, without calling a function afterward. Is this possible? ...

json and php settings

I am passing a json encoded string from javascript to a php file on the server via ajax. on my online server this works fine. but locally, it does not. There are a few differences in the php installs in the 2 places. minor ones. both are php4. the install locally is actually a newer php4. I'm trying to track down why this is happening....

Facebook Connect Dialog Popup

Hello, When using the "Connect" facebook connect button, when I click it, it opens up a new popup window outside of the current window. This is quite annoying, how am I able to use the inline modal dialog that is found on most sites? I've attached a sample site to see if you can make anything out of it. http://bit.ly/c9Emi Thank you....

Make PHP Object do different actions depending on variable name

For example, if let's say I have a database of users. I have a class that gets information form the database about these users. I want to make the class "self aware" of it's own name, like this: <?php class UserData { //[code that fetches the ID number from the variable name, and queries the database for info] } $user24 = new UserD...

How to check if a date has passed

I am trying to check if a date has passed or if it is the future. If the end_date has passed then I do not want it to display. end_date is a MySQL timestamp. Right now all news articles are displaying even if their end_date has passed. Here is the code I am using to check if the date has passed: function dateExp( $timestamp ){ $exp ...

How best to compare to 0 in PHP?

In one bit of code I'm working on, I need to pull a value from the database and check if it is 0. Originally, I had written this as: if ($myVal == 0) { ... But when I looked at it again today, I realised a bug there: var_dump("foo" == 0); // bool(true) // and while we're here... var_dump(intval("foo")); // int(0) Since this value...

How to process ‘only’ visible fields in an HTML Form ?

Is there a way not to process fields with a “display:none” style ? The fields are dynamically hidden using javascript but are processed normally in PHP. I’m looking for a PHP solution (no javascript). ...

How to generate a secure activation string in php?

After user subscribe email to my website. My website will generate an email confirmation and send to them. In the email content, i need to include activation key, something like: www.domain.com/activate.php?key=$generatedKey How do you generate the key? using sha1($email)?? After generate the key, i store it in database, so that when ...

What is the PHP or C# Equivalent of Ruby's Depot Application?

The book Agile Web Development with Rails has a great application that it takes the reader through to introduce them to the process of developing a real application with Ruby on Rails. Does PHP or C# have an equivalent? At the very least, can anyone think of a good practical exercise for learning PHP or C# "as you go" or through applic...

How do audit a code base to find code no longer used/required?

I'm working with a code base, which in places has code 10 years old. The code has undergone numerous additions, changes, editions, and refactorings without the removal of any code, or modules which are no longer required. As a result, the code base is littered with unnecessary code. Have any of you come up with a comprehensive technique...

Problem on Tag "Filesystem"

For recreational reasons I wrote a PHP class that classifies files with tags instead of in a hierarchical way, the tags are stored in the filename itself in the form of +tag1+tag2+tagN+MD5.EXTENSION and thus I'm stucked with the chars limit (255) imposed by the FS/OS. Here is the class: <?php class TagFS { public $FS = null; f...

ExtJS Gridfilter values to PHP

Hello. I'm using ExtJS v2.0 . I would like to grab the gridfilter values and pass them to a PHP page as $_POST, $_GET, $variable or any possible method that would work to be inserted in PHP query using this backend code: http://www.vinylfox.com/grid-filter-php-backend-code/ I will use those queryes to print one table with the results an...

Gathering POST data from similar fields

I am posting a form that has many similar fields (artist1, artist2, .... artist20). I am trying to add them to a database but I am not sure how to easily get all of the posted data with out having to write out each one separately. How can I combine an int to a string so that I dont have to write each one out? This is one way I tried that...

PHP form design best practice

I have been using PHP for a while now and I have always wondered how to represent a single form to handle updates and inserts into a database. At the present, I am using 2 seperate forms to do this and they both have basically the same information and textboxes, etc. I know there is a better way of handling this but I'm not sure what tha...

PHP: How to insert a string in an empty font tag?

Hi guys, how can I add a string in an empty font tag? Like if in the second font tag there is no value, I will just insert a <br /> tag. How can I do that? Thanks :) I have this HTML code: <P ALIGN="LEFT"> <FONT FACE="Verdana" style="font-size:10" COLOR="#0B333C" LETTERSPACING="0" KERNING="0"> Welcome to jQuery Course </FONT> </P>...

PHP logical coding style

Hello, I have to modify some parts of a large PHP application. The different parts were written, of course, by different people (mostly interns). After looking through the code, I found that there were 2 styles of coding used by the other developers: The 'PHP is the glue of the Internet' style, mixing html and php, ex.: [snip] <tr...

Free RTE [Rich text editor] help needed integrating it

Working on a PHP /html content management system and found Free RTE online which is a free rich text editor. Have no idea how to integrate it into my own stuff. There are sample codes with it alrite, but they are not very clear. Anyone used it before or have any knowledge of integrating it??? ...

php form issues

I have a form with which I am trying to display a form with checkboxes, and then insert into a database whether or not those checkboxes are checked. Then, each time the page is called, check the value and append information to the html form to appropriate display the checkbox as checked or not. I have modified the below code example to ...

Templates with identical names and Smarty

I have a small problem with Smarty... I have two different template files in two different directories that happen to have the same name. Unfortunately Smarty gets them confused. It uses the last one to be updated to create a compiled file in its /templates_c folder, which it then uses to display the page. This means that both files en...

passing a parramter from php to javascript back to php.

I have a php page, which using javascript, creates a popup window which contains another php page. the php page in the popup window is basically a form, and will use that value to insert into a database. Using the following function to load the php page in a popup: phppopup('edit_status.php?cmd=EditStatusData') function phppopup(page){...