php

What happens to models with BelongsTo and hasOne relationship setup?

What happens when two models are associated with a belongsTo and a hasOne relationship at the same time? Does the framework detect this situation to avoid retrieving too much data? EDIT: CakePHP specifically, although what other frameworks do would be helpful, too. ...

Thoughts on securing SWFUpload

One of the issues with using a Flash uploader controlled by Javascript (e.g. SWFUpload) is that Flash starts its own session when executing the upload script. This means that if the upload script authenticates the user, it will fail. One way around this is to pass a PHPSESSID as a post parameter to the script. This isn't a perfect solut...

Zend_Form_SubForm flattening array notation with getValues()

I am working with a series of forms that have subforms embedded into them and I am trying to work out if I can make getValues return the values without the array notation on the subform. ie: $form = new Zend_Form(); $subForm = new Zend_Form_SubForm(); $form->addSubForm( $subForm, 'contact' ); $form->addElement(new Zend_Form_Element_Te...

PHP: get a single key from object

I have an object with a single key and its value. But I don't know the key to access it. What is the most efficient way to get the key without enumerating the object? ...

Is it possible to prevent zend engine to free resources?

Is it possible to prevent zend engine to free resources allocated in PHP? For example, when a process is forked() and the resource is duplicated to the child process, when either child process or parent process exit, the resource is free thus other processes can't access them any more. ...

adding military time in string representation

So what I am trying to do is add two strings together in the form of military time. Here is the example. Time1 = "01:00"; Time2 = "04:30"; Adding the two together would produce "05:30". This seems incredibly simple, but it has been a long long day for a new learner. Any help would be greatly appreciated. ...

OOP: when should i create a base class and when should i not?

I have a large class with lots of methods (25, interrelated of course). I'm not sure I should split it up and create a derivative and base class instead. I don't see any opportunity coming in the future for another class inheriting from the base. So what are the driving factors for breaking a large class down into smaller parts? ...

JQuery/PHP Chat Client Help

Hello my friends. I found this cool Chat tutorial on CSS-Tricks. (http://css-tricks.com/chat2/) I am trying to use it however. Everytime I run it, and I enter my name when it asks in the chat room. It just shows this code: Great! You found a username not in use"; $data['inuse'] = "notinuse"; } else { $data['result'] = " That username i...

How can I detect non-western characters?

I want to disallow certain UTF-8 input (server-side), e.g. eastern languages, where example input might be " 伊 ". However, I do want to continue supporting other latin or "latin-like" characters, such as the welsh ŵ and ŷ, so checking against latin-1 is not possible. What are my options? (if language specific, PHP preferred) Thanks ve...

Looking for encrypt/decrypt functions

I have an array of IDs (e.g. array(1, 2, 10, 34, 100, 101)) that represents files ids of pictures in database. I would like to send a link to customer by email such that when he press this link he will see the pictures, but I don't want customer to see these files ids! Thus, I thought to encrypt the array of pictures ids with some key ...

Why not start from the beginning?

Possible Duplicate: Why use a framework with PHP? Hi, usually all the projects I do I work or with my own framework or I start them from zero. Why shouldn't I do this? or is better to keep doing it this way? I mostly work on php, what suggestions do you have to change this? cake, joomla or another one? or just keep it this wa...

Logged in user, retrieving data from two different tables which have same field names

Hi everyone, Im a PHP/MySQL beginner and I really need some help for the following code (I apologize for the length of it, please bear with me!). I have 3 tables of data in my MSQL database with about 150 users in total. user: Which has the user name, email, password etc thismonth_results: has 25 fields of numerical data, all are popu...

Get contents of the URL and display links

Hi, I want to get contents of a URL and display only the links present on that page. Please help. Thanks ...

advantages from htmlpurifier instead of regex filtering

We have recently implemented htmlpurifier in our web-based application. Earlier we used to have regexes to match commonly known XSS injections (script, img, etc. etc). We realized that this wasn't good enough and hence moved to htmlpurifier. Now given that htmlpurifier is slow in working (very slow compared to the regex method we had ear...

Access a COM interface from a service (apache) with PHP

I've been trying to create a PHP script which will run on a locally hosted web server, and will be able to access various programs on my computer through COM. I've had mixed success and failure, and I've been able to narrow down the problem. If I run the php script using php.exe, it works. If I run the php script using apache running fr...

Merge variables

We have $id and $title variables, which everytime change. For each $id we should create a new variable $temp_title_%id%, and give to it $title's value. Like: $id = 10; $title = 'Hello people!'; $temp_title_10 = 'Hello people!'; Tryed this (doesn't work): $temp_title_ . $id = $title; Thanks. ...

append text javascript,don't get values

This is the code in append input box in java script,i don't get there values in the inputbox <script type="text/javascript"> function addInput() { var x = document.getElementById("inputs"); x.innerHTML += "<input type=\"text\" name=\"box[]\" id=\"box[]\"/>"; i++; } function getdata() { } </script> <input type="button" on...

Multiple PHP vars in a JavaScript onclick() problem

I have the following php code $bigImageSrc = 'images/'.$prodXML->bottles->bottle[$i]->bigImage; $text = $prodXML->bottles->bottle[$i]->title; $title = $prodXML->bottles->bottle[$i]->text; echo "<a href=javascript:void(0); onClick=showProduct('$bigImageSrc', '$text', '$title');> but I'm getting this error: syntax error showP...

PHP check values

We have 2 variables, $id and $title. And a form field for a new $title variable: foreach ($ids as $id) { $id_title = $title; ?> <input name="new_<?php echo $id; ?>_title" value="<?php echo $id_title; ?>" /> <?php } ?> How to check, is $id_title has been changed in the form, and do something if it is. Like: if ($id_title != ...

Changing Text in PHP

Hey all I haven't found anytihng in Google or the PHP manual, believe it or not. I would've thought there would be a string operation for something like this, maybe there is and I'm just uber blind today... I have a php page, and when the button gets clicked, I would like to change a string of text on that page with something else. So...