php

PHP: Check if 0?

Hi, I am using a class which returns me the value of a particular row and cell of an excel spreadsheet. To build up an array of one column I am counting the rows and then looping through that number with a for() loop and then using the $array[] = $value to set the incrementing array object's value. This works great if none of the value...

CakePhp: model recursive associations and find

Hello to everybody! I've some trouble with a find() on a model on CakePhp. I have three model relationed in this way: Project(some_fields, item_id) ------belongsTo-----> Item(some_fields, item_id) ------belongsTo-----> User(some_fields campi, nickname) I need to do a find() and retrieve all fields from project, a field from Item and ...

Get post author name and category name from other table by ID

I have three mysql tables, first holds information about articles (Article ID, author ID, title and content), second tables holds information about registered users on my site (ID, name, password, email), third holds information about categories (ID, name). I need to get all the articles and displays title, author name and category name...

how do I write a command-line interactive php script?

I want to write a php script that I can use from the command line. I want it to prompt and accept input for a few items, and then spit out some results. I want to do this in php, because all my classes and libraries are in php, and I just want to make a simple command line interface to a few things. The prompting and accepting repeated ...

PHP oop build array

Hi! If I would need to build up an array with OOP based PHP, would this be the proper way to do it? class MyClass { $array = array(); function addElement($value) { $this->array[] = $value; } function fetch() { $return = $this->memcached->getMulti($this->array); return $return; }...

Displaying a list of objects with Views - Drupal

Hi folks, I'll briefly explain what I'm trying to do: I need to sort a set of content-types within a paginated page. Also I need to add filtering to the page, for example each content-type should have a set of tags and the filter needs to filter through these tags. This is a basic mockup of what this page consists of: I'm finding ...

cakePHP and GROUP BY

I am trying to solve a hopefully simple problem here is the query I am trying produce: SELECT `categories`.*, COUNT(`entities`.id) FROM `categories` LEFT JOIN `entities` ON (`categories`.`id` = `entities`.`category_id`) GROUP BY `categories`.`id` I am really struggling to do this is in cakePHP 1.2 How would/should I go about doing t...

preg replace h2 tags with spaces

Possible Duplicate: PHP Regular express to remove <h1> tags (and their content) I have some HTML that looks like this: <h2> Fund Management</h2> <p> The majority of property investments are now made via our Funds.</p> Trying to use a regular expression to strip h2 tags but doesn't work because of the space between the openi...

Facebook Graph API Search without logged in user

Hi folks, I'm trying to issue a Facebook Graphp API search call for groups with a specific search term. The important fact is to search for groups not only beginning with the term but also to search for the term within the group name. So something like that. FQL => SELECT * FROM groups WHERE groupname LIKE '%term%' As far as i know th...

how can i access a folder or file in parent folder php

i want a shared folder which contains images to be accessed by html pages inside sub folders.(child folders) ...

PHP OOP: Chainable objects?

Hi everybody, I have tried to find a good introduction on chainable OOP objects in PHP, but without any good result yet. How can something like this be done? $this->className->add('1','value'); $this->className->type('string'); $this->classname->doStuff(); Or even: $this->className->add('1','value')->type('string')->doStuff(); Tha...

Insert date and time into Mysql

Hi..guys I am trying to insert date and time into mysql datetime field. When a user select a date and time, it will generate two POST variables. I have searched internet but still not sure how to do it. My code. //date value is 05/25/2010 //time value is 10:00 $date=$_POST['date']; $time=$_POST['time']; $datetime=$date.$time If...

PHP - BUG with filter_var and FILTER_VALIDATE_FLOAT

I think there is a bug in this filter_var or maybe I'm doing something wrong: Try this: $options = array( 'options' => array( 'default' => 3, 'min_range' => 1000.0, 'max_range' => 5000.6, ) ); $VariableValue2 = 5698; $VariableValue4 = 5698.2; ...

linux dot utility (with xhprof)

i installed the xhprof profiling extension for php Everything is fine except for the callgraph.php file, it returns: failed to shell execute cmd=" dot -Tpng" so i checked and the dot utility wasn't installed, so i installed it. it appears to be running fine from the command line so i ran the scritp again, same error: failed to shell e...

What is the best desing pattern to design the interface of an WebPage?

I am trying to build the interface of my WEB site using OOP. For this I need to have several objects like menu, thumbnails, contentBoxes joined together to form a complete layout. I know OOP is not used for presentation but I need to do it anyway. Can anyone help me on this? ...

Where can I learn web programming from start to mastery?

I tried doing tutorials but it is unorganized and unstructured, where can I learn PHP from beginner to master? I'm looking for a site like www.w3chools.com, but somehow I feel it is incomplete, specially when it comes to more advanced functions. I know some basics but I wouldn't be able to for example make a secure online webstore, and ...

PHP OOP: Parenting objects/functions?

Hi everyone, How is parenting functions in PHP done properly according to the following example? Can I make sure that my array isn't overwritten and the previous values inside array lost, on each addArray call? function arraybase() { $this->array = new ArrayObject(); return $this; } function addArray($value) { parent::$t...

1054 - Unknown column 'apa_calda' in 'where clause'

I keep getting the error 1054 - Unknown column 'apa_calda' in 'where clause' in MySQL. Here is the query: SELECT user_id FROM `detalii_contor` WHERE tip_contor=apa_calda I want to use this query in a PHP file but it doesn't give any results. So I tried to write it in the SQL command prompt. Here is what I tried in the PHP file: $Q = ...

Symfony - Several form on the same page -> ID issue

Hi folks. I have an issue while displaying several forms of the same model on the same page. The problem is that with the NameFormat, the fields have the same ID : $this->widgetSchema->setNameFormat('display[%s]'); Will display <form class="update_display_form" id="update_display_0" action="/iperf/web/frontend_dev.php/update_display...

trouble selecting FROM WHERE ?

Hi guys, I have this code, but strangely it always echos out "yes!", even if there is no such value as '555' in FLD2 or even if there's no FLD2 at all. $testresult = mysqli_query($database, "SELECT * FROM imei359327039828680 WHERE FLD2 = '555'"); if ( $testresult ) { echo('yes!'); } else { echo('no!'); } Any idea, thanks! ...