php

Write to error log with local time information and a line break at the end

I need to write the local time information , the exception message to a php log file. I don't know why I can't get the format correct. The script I use is this: error_log('['.date("F j, Y, g:i a").']'.$msg." <br>", 3, $phperrorPath); There are two problem with this: The date is not written in local time, instead it's default to t...

Automatic Return By Reference in PHP

For some reason I have always assumed that most of the time a variable returned from a method would be returned by reference - after all on return; most methods would destroy the return value and it seems silly to make a copy, return it, then destroy the originals. Does the above ever apply, or is it worth going through and making funct...

Performance implications of mysql_data_seek

I've started to use mysql_data_seek () as an easy way to roll pagination transparently into my database class by shifting the pointer and reading the current 'page'. What are the performance implications of doing this? I am only reading the data I need into PHP itself, but in most cases the SELECT covers the whole table - is this bad...

Installing PDO_MYSQL on PHP 5.1.6 using PECL OS: UBUNTU

I'm having real problems getting PDO_MYSQL working. I started by just trying to install the PDO_MYSQL driver via PECL, however when this didnt work I looked round to see if there where any issues reported. It seems that there may be a conflict between the embedded version of PDO and PDO_MYSQL. To that end i decided to reinstall all it'...

Php router, extracting keys from uri

Hey folks! I need some help with regular expressions/etc. I need to extract virtual keys from url, some sort of router in application. Here are the params: Rule: /books/:category/:id/:keyname Data: /books/php/12345/this-is-a-test-keyname Output should be something like that: array( 'category' => 'php', 'id' => '12345', 'keyname...

Finding events in a transaction file where more than 5 serial numbers appear in sequence within 100 transactions.

I've had an unusual client request in regard to fraud detection in an online raffle which I'm trying to build as efficently as possible by pushing as much of the task into SQL as possible. The structure is thus: table: codes raffle_code | ticket_type | sequence A00000001 Red 1 A00000002 Red 2 ... A0000...

php reload page without posting data

Hi, I'm trying to refresh a page without sending POST from the previous time. I've tried window.open("postme.php?r=t","_self"); Which appends a ?r=t to the end but it doesn't appear to refresh the page as the page displays a number of file s in a directory which hasn't change even though I have moved or deleted them. Can you specify...

Clearing content of text file using php

I have a filelist.txt file and i create clear.php file to clear the content of filelist in index.html i put a button to call clear.php to clear Can anyone help me out regarding: What php code should i write in clear.php How to code a button to call clear.php and then return back to index.html showing the result that it has been clea...

File Body Search

Hello, Can anyone recommend a good tool for searching though the body of files (office, powerpoint ect). It needs to be integrated as part of a PHP site. Alternatively, any server side applications that could be used for creating indexes of the search terms. thanks ...

Ordering a column in a two dimensional array

Hi, new here so thanks for taking the time to read my question. I am running some PHP code that compares the numbers enter on the screen with those in a database. The problem I am having is ordering the two dimensional array after manipulating each line. It looks as though the array id numbers are being removed. I would like to order th...

Preg Match circumflex ^ in php

I cant quite get my head around what the ^ is doing in my preg_match. if (preg_match('~^(\d\d\d\d)(-(\d{1,2})(-(\d{1,2}))?)?$~', trim($date), $dateParts)) { echo the $dateparts and do some magic with them } else { tell me the date is formatted wrong } As I see it this is looking to see if the $date matches the format which I ...

How to generate 63 million prize codes

Hiya All, I am trying to come up with a "smart" and "secure" way of generating about 63million unique codes to be used in a competition. The codes will be about 10 characters long. Has anyone done anything similar or aware of any "hurdles" that might arise from this issues? How do we minimize the probability of someone being able to gu...

Why is my MySQL date displaying as blank in PHP?

One of the fields in my database is of 'DATE' Type (field-name = 'post_date'). after fetching an array $record = mysql_fetch_array($queryResult); if I do echo $record['post_date']; I do not get any output (blank). What should I do to properly handle the date type? ...

array_push() vs. $array[] = .... Which is fastest?

Hi all I need to add values received from MySQL into an array [PHP], here is what I've got: $players = array(); while ($homePlayerRow = mysql_fetch_array($homePlayerResult)) { $players[] = $homePlayerRow['player_id']; } Is this the only way of doing it? Also, is the following faster/better? $players = array(); while ($homePlay...

Why am I getting an "unexpected T_STRING error"

I'm trying to get Zend Amf working on my hosting services (Lunarpages, if that matters). I can get it working on my local machine, but after changing a few directories and posting the code, I keep getting this error: Parse error: syntax error, unexpected T_STRING, expecting '{' in /home/user_name/public_html/library/Zend/Amf/Server.php...

Find every Sunday between two dates

I have $fromdate and $todate variables. I want a function that can calculate the dates of each Sunday existing in between $fromdate and $todate in PHP. ...

PHP recursive search and replace array elements

Hi all, I want to recursively search and replace elements in an array. The array is tree based so looks like Object Children Object type A Object type B Object Children Object type A Object etc. I want to be able to replace certain items with other items, so for example, I want to replace all entries in the ...

Zend Framework Layout

Hi everyone, I'm beginning with Zend Framework and I would like to understand Bootstrap file. I've learned all _init methods are executed by default but it seems confusing to me. Anyway that is not what I would like to ask. A came around the $this->bootstrap('layout'); action and I'm not sure if I understand this. Is this the resource....

How do I create subset words for an anagram application (php) ?

I created an anagram creating application, by creating an anagram field in my database, with a lower cased alphabetically stored string. For example, suction becomes cinostu, ear becomes aer, and so on. What I want to do now is create sub words from the original anagram searched for. Example: How would you go about pulling the subset ...

Calculate the difference between date/times in PHP

I have a Date object ( from Pear) and want to subtract another Date object to get the time difference in seconds. I have tried a few things but the first just gave me the difference in days, and the second would allow me to convert one fixed time to unix timestamp but not the Date object. $now = new Date(); $tzone = ne...