php

Aggregate values in Doctrine_RawSql queries

Is it possible to use aggregate values in Doctrine_RawSql query? Here's what I'm trying to do: $q = new Doctrine_RawSql(); $q->select('{q.*}, AVG(a.value) AS avg'); $q->from('-- complex from clause'); $q->addComponent('q', 'Question'); However, SQL created by Doctrine leaves only columns from table question and omits aggregate value a...

Remove zero values from a PHP array

I have a normal array like this Array ( [0] => 0 [1] => 150 [2] => 0 [3] => 100 [4] => 0 [5] => 100 [6] => 0 [7] => 100 [8] => 50 [9] => 100 [10] => 0 [11] => 100 [12] => 0 [13] => 100 [14] => 0 [15] => 100 [16] => 0 [17] => 100 [18] => 0 [19] => 100 [20...

Problem with downloads: slow and/or fails

I have the following script to let a visitor download a file: header( 'Content-Type: application/octet-stream' ); header( 'Content-Transfer-Encoding: binary' ); header( 'Content-Disposition: attachment; filename=' . $fileName ); header( 'Content-Length: ' . filesize( $filePath ) ); header( 'Content-Description: Download' ); header( 'Cac...

DataMapper and Codeigniter - how to fully manage a many-to-many relationship

I have the following relationship CType has many Field Field has many Ctype and of course the tables used are fields, ctypes, and ctypes_fields. Normally, the ctypes_fields table should contain only ids referencing the other two tables. However, i'd like to put there a "options" field that will contain some content for the concrete in...

!db_connect - or die which is better

Hi, really quick question please look at the following example $dbConnect = mysql_connect($host , $username , $password) or die ("BIT OF A PROBLEM PLEASE COME BACK LATER"); is this a good way to do it or should I maybe use $dbConnect = mysql_connect($host , $username , $password); if(!$dbConnect) { echo "COULD N...

AJAX Inline Editing: Add PHP Update to new changes

I’m working on a homepage and will use an AJAX inline editing script for the admin to make it as simple as possible. The script I’ve been using is this and it has almost everything I wanted from an inline editing script. My problem arises when I’m going to capture the new changes and send them to a PHP function which will update my datab...

Search database using LIKE and wildcards

I have four search fields that are used to search a database for book id:s and then echos out the result. Depending on wich field you choose to search from the sql query builds up as you can see in the code below. The title and isbn field are working fine but when I try to use the author or category field nothing gets returned. The relev...

safest place to store php values for msql_connect ?

Hi , Were is the safest place to store my values which will be used in mysql_connect also what is the safest way to call these variable would be better using a require , include or something else ? thanks :) ...

Get a $date between start and end dates on a continuous loop

Trying to figure out a way of achieving the following scenario:- The user creates an initial time period e.g. 01/01/2013 to 01/07/2013 and a renewal period e.g. every 1 month. I'm working on a function that will:- Detect whether the date passed in a function (could be any date) falls a period matching the users requirements. For ex...

how to protect php files

We're making a system as a group, and I'm the lead programmer. And I don't want that one of my group members will be able to steal my code and brag to others that they're the one who made it. Is there any technique that I could employ so that the code will be disarrange or encrypted or anything so that I'm the only one who could read the...

Using Digest Authentication with PHP + Apache

Hello all, im trying to set up DIGEST authentication using PHP & Apache. I have tried doing this using a script i found on the web which gave me an error as it said the method apache_request_headers() didnt exist, which on reading seems that is becuase apache is not set up to pass the headers to php. I tried installing HTTP_Auth using PE...

How do you set the correct Content-Length header when the webserver automatically compresses output?

Following my previous question, in which I think I've narrowed my problem down to the bottleneck: How do I set the correct value for the Content-Length header for a downloadable file, from within PHP, when the webserver (apache) automatically compresses the ouput afterwards? I'm looking for the most robust/generic solution. I'm not wel...

php auto login from one site to another

i have 2 different websites. i want a feature that when a user logs in to site A then he should be automatically logged in to site B. please give me some concepts for that. (eg:- when anyone logs into gmail, he is automatically logged into orkut) ...

Is it possible to view PHP content that is not echoed?

Imagine the following PHP file: <?php $topSecret = "Something important"; ?> If I put this on a server running the standard LAMP setup, how could someone could find out $topSecret? If the variable is not echoed, is it vulnerable? A real application of this might be database credentials stored in the web root of a server. ...

PHP Based Project Management Application (Scrum/Agile)

Hi everyone I've been fiddling with Redmine in the past few days and not 100% happy with the way it organises tasks etc. I need a open source PHP based solution that is like Redmine or even VersionOne to assist our small team of 3 developers with project management. We basically use Scrum, and would love to be able to create projects,...

Why is my recursive function not working?

$startDate = 20130201; $date = 20130505; $aDates = $this->getDates($startDate, $date); public function getDates($startDate, $date) { $tmpStartDate = date("Ymd", strtotime($startDate.'+1 Day')); $tmpEndDate = date("Ymd", strtotime($tmpStartDate.'+1 Month')); if($date >= $tmpStartDate && $date <= $tmpEndDate) { ...

what is the best way to create random mysql ID using PHP

hello. i'm building an application that needs a random unique id for each user not a sequence mysql database ID Username for my unique random ID, what is the best way to do that? ...

Creating a file on another server using PHP file functionality

I have a script on my one server and I want that script to create a file on another server of mine using PHP, NOT VIA FTP? ...

php preg_split error when switching from split to preg_split

Hi, I get this warning from php after the change from split to preg_split for php 5.3 compatibility : PHP Warning: preg_split(): Delimiter must not be alphanumeric or backslash the php code is : $statements = preg_split("\\s*;\\s*", $content); How can I fix the regex to not use anymore \ Thanks! ...

Zend Framework - need to access a GET parameter from a view

HI guys - I'm using the Zend framework and what I need is to construct a url in my view. Normally in regular php code I'd just grab the GET Variable by using the global $_GET. However with Zend I'm setting it to clean URIs so : ?ac=list&filter=works&page=2 Looks like index/ac/list/filter/works/page/2 In my view I'm setting a links cs ...