php

How to sequence events in PHP for uploading files to amazon S3

Hi I am hoping someone can help me to understand why I am getting varied results with some PHP code I have written to upload files to S3 then call an EC2 instance to perform actions on the uploaded file. Here is the order i do things - 1) use S3 class to put file $result = s3 -> putObjectFile($uploadDIR, $bucket, $name, S3::ACL) ...

How to Handle 'Sometimes' Inheritance?

I have a situation utilizing class table inheritance where the base object (which is abstract) is extended by specific types of the object. For example, Person --> User --> Prospect However, in some instances like with Prospect, sometimes it extends User and sometimes it doesn't. I can't reverse the relationship because User !== Prospe...

Automatically link keywords within page texts from word list

My site has a lot of dynamic stats with names of people, places and topics that all have their own associated pages. I want to automatically link each of these to their page based on data I've set up in a MySQL database of 'words' and 'links'. What would be an efficient way of automatically linking 20-50 occurrences of potentially 15-20...

Should Dates be Stored as a Datetime or as an int in SQL?

I store all my dates for post in my forum in datetime (0000-00-00 00:00:00). I see that phpBB, punBB and all popular forums store dates in int? What is better? ...

Assign value from one associative array of php into another array

I have a variable $params which gets data from the database: $params = mssql_fetch_array($result) As far as I know, it is associative array. I want another array $tempParams to hold the value of this array. Can I assign it by using the following statement: $tempParams = $params In addition, do I need one single statement to decla...

What is the best way to select attributes for all members of an AD LDAP group from PHP?

I need to select a number of attributes for all of the users in a particular group from a PHP application. I realize that I could query the 'member' attribute of the group to get the dn of every member and then make a separate LDAP query for the attributes of each member. I am hoping however, that there is a single query that I can perfo...

Timezone Functions Help

Hi all, This might be a too bigger ask, but before I outsource it, I would like to try to understand it first, and do it for myself. I am working on a project that involves an existing database. I am building the site around the existing data, but have run into issues with timestamps. Basically, I am hoping someone can give me a snippe...

Dividing lines between Session Object, User Object, and Login Controller.

I'm developing my own PHP framework, and I'm trying to do things more "by the book". I want to build login system. I have done this plenty of times, but now I just want to confirm/get some feedback on a system. I know we need... A Session Object A User Object A Login Controller What my question is, is who holds what power? Here's ...

Large MySQL Update Query

Hi all, After getting an answer from this thread, it would save me alot of retyping if any readers could refer to it: link text I find that I need to update(within a mysql db) a timezone code, singularly (e.g 10+, 1-, etc) to olsen code (e.g "Europe/London", etc) according to what already exists within the user_timezone column. What wou...

Parse a select tag with regex (php)

I would like to scan a specific select tag for all the option-tags values and content in PHP. So that from this <select> <option value="donald">duck</option> <option value="david">moose</option> </select> <select id="something"> <!--ignore this one --> <option value="sdfas">fs</option> <!-- ignore this one --> ... I would get somethin...

PHP Configuration file won't load IIS7 x64

using Fast CGI I can't get it to read the php.ini file. See my phpinfo below. System Windows NT WIN-PAFTBLXQWYW 6.0 build 6001 Build Date Mar 5 2009 19:43:24 Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--with-snapshot-template=d:\php-sdk\snap_5_2\vc6\x86\template" "--with-php-build...

Divide amount by characters present in string, found via regex

Suggestions for an updated title are welcome, as I'm having trouble easily quantifying what I'm trying to do. This is a web-based form with PHP doing the calculations, though this question probably has an algorithmic or language agnostic answer. Essentially, there is an Amount field and a Charge Code field. The Charge code entered r...

Whats a good way to implement a variable number of custom fields in a CMS?

The implementation used where I work uses about 10 columns in the table: CUSTOMFIELD1, CUSTOMFIELD2 etc. And every time I look at it, I think there must be a better way. Not everyone will use all 10, some will use 0 and so there these empty columns just staring back at me, begging to be used. So if there is a better way... ideally, I t...

How to get the full URL of a Drupal page

Hi all, I need to be grabbing the URL of the current page in a Drupal site. It doesn't matter what content type it is - can be any type of node. I am NOT looking for the path to theme, or the base url, or Drupal's get_destination. I'm looking for a function or variable that will give me: http://mydrupalsite.com/node/number In full. E...

Posting variables in PHP

How do I post a variable in PHP without using a form, and accessing the variable from the next page. What I am really trying to do though, is post a variable like this: $username = "Sam"; $_POST[$username]; and then I am trying to access it from a page that I meta refresh to. Any ideas? ...

Sql Query not working!

INSERT INTO `test` (`x`, `y`) WHERE `id` = `$id` VALUES (`$x`, `$y`) Whats wrong with this query? I run this in a mysql_query() function in a php file. ...

iPhone reverse geolocation help

Hi All, I'm pretty new to iPhone SDK and Coca dev. I'd like to know how to call a web service which will take the lat and long values from my iPhone and feed them to a webservice so I can retrieve the City,State. I already have the phone location stuff squared away. I'm only looking for where I should pass this info to and how I can pars...

Implementing Security on Sessions

How can I secure the data that my session posts so that to reduce injections? Is there perhaps something I need to add when I use $_SESSION[''] = $var; or when I retrieve the data by $var = $_SESSION[''];? ...

Folder security?

Hello, I have a folder named upload which is filled with folders of users uploaded files. Is there any way I can stop people from directly downloading my users files by simply typing the folder names and file name into the address bar? Example: user Jim's folder is stored at HOST/uploads/jim user Jim's important file "myimportantfile....

Capitalise every word of a string in PHP?

As I know, strtolower makes the string all lowercase and ucfirst makes the string's first letter capitalised. I am asking, is it possible to make every word within the string capitalised? Example $string = "hello world" - How can I make this appear "Hello World"? ...