php5

PHP: using the eval function with HTML and PHP code

Hey guys, I currently have the following code coming from a database table: <h1 class="widgetHeader">My Friends</h1> <div class="widgetRepeater"> <p class="widgetHeader">Random Selection</p> <?php $friends = $user->getFriends(); ?> <p class="widgetContent"> <?php for ($i=0; $i<count($friends);$i++) {...

Prevent unnecessary HTTP requests for iPhone version of website

I have a website. It uses jQuery, a few plugins, Cufon, etc to spice things up a little, mostly visually. The iPhone version does not need any of these files. Can I, without resorting to subdomains, prevent the iPhone from loading these scripts? <script src="js/jquery-1.4.min.js" type="text/javascript"></script> <script src="js/browse...

[CakePHP] Making a controller for home page

Hello, Can you tell me how to use a controller for home page because i'm trying to put a model's data in home.ctp (homepage view) with <?php $this->user->find() ?>but it returns Notice (8): Undefined property: View::$user [APP\views\pages\home.ctp, line 1] Thanks ...

How to reduce this code?

Is there any way to shorten this code: $resultCategoryName = mysql_query("SELECT ecname FROM electioncategorymaster WHERE ecid=".$Category); $rowCategoryName = mysql_fetch_row($resultCategoryName); $CategoryName = $rowCategoryName[0]; ...

php Currentage not define in the scope

I am quite new to php. Can somebody please guide me what is wrong with the code. <?php if(!isset($_POST['submit']) || $_POST['submit']!="calculate") { $_POST['Contrib']=""; $_POST['Currentage']=""; $_POST['Retireage']=""; $Total =0; $AnnGain =7; }else{ $AnnGain = $_POST['AnnGain...

PHP code called via JQuery stopped working.

Initially, I used a .js file that contains AJAX functions to call a .php file. The .php file contains code to dynamically populate a DropDown based on certain parameters passed via QueryString. Everything works fine with the above method. But now I want to populate the DropDowns on page load and so want to use JQuery instead of my old m...

inconsistent DirectoryIterator+FilterIterator behaviour in PHP?

I wrote a script that is using the FilterIterator class that comes from the Standard PHP Library (SPL) and I get different behabours accross PHP 5.x versions :( Here the accept() function: public function accept() { $current = $this->current(); print_r($current); return true; } and heres its output for PHP 5.3.1: Dir...

Download of .zip file runs a corrupted file php

Hello, I'm trying to force a download of a protected zip file (I don't want people to access it without logging in first. I have the function created for the login and such, but I'm running into a problem where the downloaded file is corrupting. Here's the code I have: $file='../downloads/'.$filename; header("Content-type: applicatio...

Wildcard Query in Zend Lucene

$index = Zend_Search_Lucene::open("/data/my_index1"); $doc = new Zend_Search_Lucene_Document(); $doc->addField(Zend_Search_Lucene_Field::Text('type','auto')); $index->addDocument($doc); $term = new Zend_Search_Lucene_Index_Term('auto*'); $query = new Zend_Search_Lucene_Search_Query_Wildcard($term); $hits = $index->find($query); f...

Doctrine: How to save only collection items that do not exist in DB yet

I have a collection of items to save to database, but I want the record to be inserted only if not exists. I think the most effective way would be to filter the collection before saving. Can Doctrine do it automatically? Or shall I get all id's of all items in the collection, then query the database for items which do not exists on the...

php quits connecting to Oracle

We've got an ongoing issue where php 5.2.6 will quit connecting to Oracle 10.2.0.4.0. We can go weeks without any issues and then (usually Saturday mornings) php will no longer be able to connect. The database is up and running and we can connect to it manually with varous DB tools but php won't ever connect again until we reboot the web...

Sorting array problem in PHP

I have the following array [0] => Array ( [id] => 229 [val] => 2 ) [3] => Array ( [id] => 237 [val] => 1 ) [4] => Array ( [id] => 238 [val] => 6 ) I need to sort this array according to the val values in th...

Help with regular expressions (Parsing Wikipedia Markup) in PHP

Hi, I have this bit of text that I want to remove from a page I am fetching from Wikipedia. {{Historical populations|type=USA | 1698|4937 | 1712|5840 | 1723|7248 | 1737|10664 | 1746|11717 | 1756|13046 | 1771|21863 | 1790|33131 | 1800|60515 | 1810|96373 | 1820|123706 | 1830|202589 | 1840|312710 | 1850|515547 | 1860|813669 | 1870|942292 ...

(syntax trees) recursively iterating over trees bottom-up with current top-down path

Hi I have an abstract syntax tree which I need to iterate. The AST is generated by the lemon port to PHP. Now "normally", I'd do it with the brand new and shiny (PHP 5.3.1) SPL classes, and it would look like this: $it = new \RecursiveIteratorIterator( new \RecursiveArrayIterator($ast['rule']), \RecursiveIteratorIterator::SELF_FI...

Is it possible to extract Meta information from MS office files and/or PDFs with PHP?

So I have files.... .doc .docx .xls .xlsx and .pdf that are on the my server. Is it possible (and if it is, how) to extract the meta data from those files using PHP? I'm looking for things like Author, keywords, title, etc... In office documents it's the information stored along with the document properties (File...Properties...Su...

i wanna fetch data from thd database on search query

my query is "select * from wb_customer where ( sFullName like '%test\'s%') order by sFullName asc" the records such as test's are store in database but still it return empty row your suggestion for this ...

How do I enable the PHP HTTP PECL extension on Windows?

I have an installation of XAMPP version 1.7.3 on Windows 7 x64. I want to enable the PHP HTTP extension. How do I go about doing so? That is, where to I get the DLL, register it, etc. Thanks in advance. ...

How to replace text over multiple lines using preg_replace

Hi have the following content within an html page that stretches multiple lines <div class="c-fc c-bc" id="content"> <span class="content-heading c-hc">Heading 1 </span><br /> The Home Page must provide a introduction to the services provided.<br /> <br /> <span class="c-sc...

Object model for persons/workers who can be of multiple types ("jobs")

Let's say I'm modeling a workforce of workaholics. We have Bob, who is both a plumber and a carpenter by trade. There's Jane, who is a teacher. And finally Jack, the detective, bowling-alley entrepreneur, and mad scientist. Each position or job type can have properties or methods specific to only that job. For example, a plumber will ha...

CakePHP Web Crawler Memory Leak

I am developing an application that is, to put it simply, a niche based search engine. Within the application I have include a function crawl() which crawls a website and then uses the collectData() function to store the correct data from the site in the "products" table as described in the function. The visited pages are stored in a dat...