php5

Check database stores includes same units from session PHP

Hey I'm trying to check sessionbasket before buying (and check if database store includes same units from session ) foreach($_SESSION['cart'] AS $key => $qty){ $sizes_id[] = $qty['units']; } output from session: Array( [0] => 1 (units) [1] => 5 (units) ) lets assume that there is max 2 units in db, and 5 in session....

get all related tags?

this is very tricky. i´ve got a table with 2 columns thread_tag_map: thread_id and tag_name. thread_id tag_name 1 football 1 manchester 2 manchester 2 england 3 england 3 queen 4 queen 4 diana as you can see one thread can have multiple tags, and this gi...

Creating an array of data from a text file with items seperated by hashes/pound-symbols with PHP.

Hello, I have weather forecast data formatted like so: loc_id#location#state#forecast_date#issue_date#issue_time#min_0#max_0#min_1#max_1#min_2#max_2#min_3#max_3#min_4#max_4#min_5#max_5#min_6#max_6#min_7#max_7#forecast_0#forecast_1#forecast_2#forecast_3#forecast_4#forecast_5#forecast_6#forecast_7# 090180#Airey's Inlet#VIC#20091204#20091...

Convert to dd/mmm/yyyy

I am retrieving date from MySQL in the format yyyy/mm/dd 00:00:00. I want to convert this date into format dd/MMM/yyyy in PHP. How to do this? ...

Writing PHP5 only code for CakePHP 1.2

Given that CakePHP 1.2 supports both PHP 4 and 5, what's the politics on writing plug-ins, helpers, components etc to be shared with the public that only run in PHP5? I want to be better my own code, properly marking functions as protected or private which is only possible in PHP5, but at the same time make reusable code that benefits o...

how to take a report in CSV format in php codeigniter

how to take a report in CSV format in php codeigniter ...

PHPExcel style problem

$objPHPExcel->getActiveSheet()->SetCellValue('A1', 'Name'); 1.How I set this to bold? 2.How I set the width(I will have some dinamic text in the cells!)? I have read the documentation, but I haven't found any solutions! ...

Counting an eliminating duplicate associative values in an array

I have the following issue, I have an array with the name $data Within this array I have something like [6] => Array ( [code] => 642 [total] => 1708 ) [7] => Array ( [code] => 642 [total] => 53 ) [8] => Array ( [code] => 642 ...

PHP coding conventions?

Where can I find PHP coding convention references for PHP coding standards? ...

PHP: How to return an instantiated class object, given a class name?

They say that eval() is evil. I want to avoid the use of the eval() line using proper PHP5 functionality. Given a class name in a static class method, how do I make it return a real object? class Model { public static function loadModel($sModelPath) { if (!(strpos(' ' . $sModelPath, '/')>0)) { $sModelPath .= '/' . $sModelPat...

PHP: How to pass existing database connection to static class methods?

I have a set of static class methods. I also have an existing database connection in a script stored in an object variable $DB. How do I call those static class methods and let them use that $DB object without having to pass them this variable every time as a parameter on the class method? For instance, right now I'm having to use a glo...

PHP sessions passing values through offsets

I am working on the following code in file1 $_SESSION['manu']="hello"; $_SESSION[0]=$msg; $_SESSION[1]=$msg1; for($arr=0;$arr<sizeof($msg2);$arr++) $_SESSION[$arr+2]=$msg2[$arr]; $_SESSION[++$arr]=$msg3; $_SESSION[++$arr]=$file_name; In file 2 echo sizeof($_SESSION); for($arr=0;$arr<sizeof($_SESSION);$arr++) echo $_SESSION[$a...

Working with HTML Entities

I am storing HTML code in my MySQL table column. For inserting records, I framed the query like this: $InsertQuery = "INSERT INTO listing (ldate, places, company, designation, projectdetails, desiredcandidate, hrname, hrcontact, email) VALUES (DATE_FORMAT('" .$ldate ."','%Y/%m/%d'),'" .$places. "','" .$company. "','" .$designation. "','...

Recursive directory searcer PHP

How can i write an recursice directory searcher that takes a geven string and return the whole path plus the filename in php? ...

PHP fopen/fwrite problem on IIS7

I am running PHP5 on IIS7 on Windows Server 2008 R2. Check out the below code which writes a string received via a POST request parameter into an XML file. <?php $temp = ""; if($_SERVER['REQUEST_METHOD']=="POST"){ if($_POST["operation"]=="saveLevels"){ $fileHandle = fopen("c:\\inetpub\\wwwroot\\test\\xml\\levels.xml", 'w'); ...

Convert Array to Object PHP

How can i convert an array like this to object? [128] => Array ( [status] => Figure A. Facebook's horizontal scrollbars showing up on a 1024x768 screen resolution. ) [129] => Array ( [status] => The other day at work, I had some spare time ) ) ...

Which is the better client for Solr + PHP?

I have two options http://www.php.net/manual/en/book.solr.php http://code.google.com/p/solr-php-client/ I read it somewhere that that 2) use JSON as output types whereas 1) use XML doc. Isn't that a property of Solr which returns doc both in JSON and XML? What other features do I have to consider before deciding? ...

How to Set timer function

Hi I am doing online Exam Management, I have set a time duration for an exam to 5 min. When student attend this test, timer starts decreasing. I made this timer using javascript. What the problem is if the student refresh the page timer starts from first. How can I make the time to be static if page refreshed. ...

php strtotime is choking on time zone string

<?php echo "Hello?"; $thetime = strtotime("Wed Dec 16 2009 00:00:00 GMT-0500 (Eastern Standard Time)"); var_dump($thetime); ?> This code evaluates to "bool(false)"; however, just removing "(Eastern Standard Time)" allows the strtotime function to evaluate correctly. Any ideas why strtotime is choking on the time zone bit of the str...

PHP: How to detect if a certain class has constructor?

Hello All, How do i detect of a certain class has constructor method in it? eg: function __construct() { } ...