php

iterate over properties of a php class

How can i iterate over the (public or private) properties of a php class? ...

multi dimensional array keys returning single characters, not values

I see this problem on and off again in my PHP coding, and I've never understood what's happening. $val = $matches[1][$i] In this example, $i = 0 (set in a for loop) and the value held in that dimension of the array is a string. Instead of that string being assigned to $val, $val gets assigned the 0th (first) character in the string. I...

How do I store a value from a sql query into a variable?

$resourcesbuilt = mysql_query("SELECT resourcesbuilt FROM user WHERE username = '$username' LIMIT 1"); if ($resourcesbuilt<=0 ) { mysql_query("INSERT INTO resources (username, dollars) VALUES ( '$username', '1000')") or die (mysql_error()); mysql_query("UPDATE user SET resourcesbuilt = '1' WHERE username = '$username'"); } Basically...

PDF Line break

Hi this might seem like a weird question. Anyway, I'm generating some PDF file on the fly using PHP and some third party code I found. My problem is I need to insert line breaks in some part of the text that will be inserted in the PDF file. Something like: $pdf->InsertText('Line one\n\nLine two'); So it prints Line one Line two I k...

redirect page to root path

i have this class here and what im trying to do is, if the checking of something equals false then the user will be redirected to the root domain path. but its not working. here is the class class security { function checkAuth() { if(isset($_COOKIE['AUTHID'])) { $cookie = $this->secure($_COOKIE['AUTHID']); ...

how can i limit the find to a specific number in cakephp?

i have a user model which gives me latest users as output. how can i limit the record to just output me 200 records instead of all the users in database?? ...

Need a way to present a prerequisites for an object.

I don't really know how to explain this in a understandable way but here goes. The project I'm working on is a web application that revolves around courses, and each course have a set of prerequisites, the problem is that I don't know a good way to present these for the user. Example: To take course4, the person must have sold at least...

updation of table through php mysql

This is my code to update a table. My problem is that after submitting a fresh record I'm unable to update the first time (it shows blank), but the second time it works fine. One more thing: when I remove the include statement then it is working fine on submessage.php there is no any phpcode. [annakata: I have no idea what this means] ...

Could u tell me any popular air animation site ?

i want learn more thinks about air animation . not an application so any one know popular air animation site ? ...

How to show user e-mail in Drupal 5.x profile (nodeprofile)?

The email field in user profiles in Drupal is as far as i understand not ment to be shown (for good and obvoius reasons). But I still need to know how to show user e-mail in Drupal 5.x profile (nodeprofile)? ...

Testing a php object

This may be rather noobish but I'm gonna ask anyhow. I have a class that inserts into my database. After the insert is finished, I would like to be able to test whether the insert was successful. Can someone tell me what a good way to do this may be? I call the class like this: foo = new Myclass('my params'); print_r($foo) returns an ...

Report generation in PHP (formats required pdf,xls,doc,csv)

I need to generate reports in my PHP website (in zend framework) Formats required: PDF (with tables & images) // presently using Zend_Pdf XLS (with tables & images) DOC (with tables & images) CSV (only tables) Please recommend robust and fast solution for generating reports in PHP. Platform: Zend Framework on LAMP I know there are ...

Using smarty default varible modifier with gettext

Hi there. I'm currently using smarty with zend framework, and I have set up smarty to use gettext in the following manner: {gettext text="resource-identifier"} This works properly, but I got a problem when trying to use this with the smarty default variable handler. I want to do this: {$somevar|default:gettext text="resource-identif...

Problem with a SELECT WHERE query

Hi guys, Got a relatively simple MySQL query that I'm pulling using php with the following code: $employeeNames = mysql_query( "SELECT * FROM employees WHERE team=\"1st Level Technical Support_a\" LIMIT 0,5000") or die(mysql_error()); $employeeNumRows = mysql_num_rows($employeeNames); echo ...

php non-greedy regex problem

demo: $str = 'bcs >Hello >If see below!'; $repstr = preg_replace('/>[A-Z0-9].*?see below[^,\.<]*/','',$str); echo $repstr; What I want this tiny programme to output is "bcs >Hello ",but in fact it's only "bcs " What's wrong with my pattern? ...

PHP script that reports progress to Client

I'm writing a PHP script that does a lot of repetitive work, and when the client executes it, I'd like it to send back HTML in some way, dynamically, as it completes tasks. (without AJAX?) How can this be done? ...

Automatically detect user's current local time with JavaScript or PHP

I often need to display information based on or influenced by a user's actual local time which differs across time zones. Is there a reliable way of getting a user's current time and/or timezone? Key Issues: Server-side code is based on the website host or user's ISP Client-side code is based on the user's system clock which is too ea...

Count pattern in simpletest (PHP test framework)

Hi How can I test if there is a string only once in a site? I use the WebTestCase from simpletest. ...

editing a multidimensional array with [index]es, not only [name]s

public $form = array ( array( 'field' => 'email', 'params' => array( array( 'rule' => 'email', 'on' => 'create', 'required' => true, 'error' => 'The email is invalid!' ), array( 'ru...

Zend Framework html form input element with whitespaces

When I create a html form like this: $form = new Zend_Form(); $form->setMethod('post'); $form2->addElement('textarea', 'Name with Space'); The HTML becomes: ... <textarea name="NamewithSpace" id="NamewithSpace" rows="24" cols="80"></textarea> ... Mention that the input name becomes camelcase! When I call $form->getValues(); after ...