php

getting non-distinct results from a distinct mysql query

Right, another question on queries (there must be a syntax guide more helpful than mySQL's manual, surely?) I have this query (from another helpful answer on SO)... SELECT DATE_FORMAT(`when`, '%e_%c_%Y')date, COUNT(`ip`) AddressCount FROM `Metrics` WHERE `ID` = '1' GROUP BY DATE(`when`) I now want to do a similar query to get unique/...

PHP - Returning the last line in a file?

I'm guessing it's fgets, but I can't find the specific syntax. I'm trying to read out (in a string I'm thinking is easier) the last line added to a log file. ...

Delete rows across multiple databases

I'm using PHP and MySQL. I need to do a query: DELETE FROM db1.players WHERE acc NOT IN (SELECT id FROM db2.accounts) The problem is, that db1 and db2 are located on different servers. What is the fastest solution for such problem? To be precise: I'm using 2 connections, so I think I can't use one query for it. ...

Oddity with PHP tail -n 1 returning multiple results

I had this question... answered and very nice it was too. But, oddity has emerged whereby if the log file has a unique last line, (i.e. the first few words are different to the preceeding lines) it correctly returns that last line with tail -n 1 "file" but if the last few lines are similar to the the last line, it returns all the lines t...

Queue Oracle transactions using PHP oci_pconnect function in a webservice

I have written a webservice using the PHP SOAP classes. It has functions to return XML data from an Oracle database, or to perform insert/update/delete on the database. However, at the moment it is using Autocommit, so any operation is instantly commited. I'm looking at how to queue up the transactions, and then commit the whole lot on...

Error Using PHP for iPhone APNS

I have been getting this error messages from my PHP code used to send message to the APNS...has anyone got faced the same issue? Warning: stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:14094410:SSL routines: SSL3_READ_BYTES:sslv3 alert handshake failure in /Libra...

How to split a string with php

Hi , is there any nice way to split an string after " " or . ? Like $string = "test.test" result = test $string = "test doe" result = test Sure i can use explode two times, but I am sure thats not the best solutions ;) ...

Display image depending on value of a variable

Hi, I cannot work out how to display an image depending on the vaule of a product($idd): foreach ($response['products'] as $product) { if($filter != "all" && $bb[$product['product-id']['value']] && $bb[$product['product-id']['value']][0] != $filter) continue; $r = array(); $idd = 0; $ca = 0; foreach($product as $key=>$val...

What software / tools / services do you use to manage users on your site? Registration, payment, mailing list. Is there a good package for everything?

Hi all, I am scoping out what we need from a user management solution and wondering if anyone knows of a good provider of a service that would be able to : securely manage user registration and logins to our site receive payments and handle billing, reminders for recurring payments etc handle forgotten passwords, handle support ticket...

sending multiple records to MySQL from multiple select box

Hi, I'm trying to insert multiple rows into a MySQL table depending on the number of options selected from a multiple select box. currently it is inserting one row (regardless of how many options are selected) but the 'strategyname' column is empty each time. Any ideas on how to insert multiple rows and why the values of the options ar...

CodeIgniter Session

Hello, I am trying to use a third party script and extract the logged in users userid. I am aware the CodeIgniter uses some sort of encrypted sessions. Can you please suggest how to get the userid. A simple $_SESSION does not seem to work. I am basically running a separate script and i just want the session details i.e. the userid. But...

select multiple options

banging my head against the wall for something seemingly dead simple. Here it is: <html> <head></head> <body> <form method="post" action="action.php"> <div><input type="checkbox" name="test" value="Newspaper"> <span >Newspaper</span></div> <div><input type="checkbox" name="test" value="PC"> <span >PC</span></div> <div><input...

dojo crashes ie6 when using Zend Framework

I'm having issues with a application that I am writing that uses Dojo and Zend Framework. The issue only effects Internet Explorer 6, other versions of IE, ff, chrome and safari work fine with no issues. When IE6 lands on the login page it crashes with the send details to microsoft dialog box. The login script uses dojo to provide som...

File Upload and Unit Testing with Zend Framework

How can one best test a controller action which receives a file upload using Zend_Test_PHPUnit_ControllerTestCase? Ideally, $this->getRequest()->setPost() would take a filename in the data array, but this does not seem to be supported. I would be willing at this stage to bootstrap/run my application on the command line and create a req...

Trimming an image for temporary use in PHP

I want to be able to trim images, many of which are very long vertically...anywhere from 2000 to 4000px, always at 800. So only getting the top part of the image. I then want to output this to a page/report with PHP, without storring the resultant trimmed image. Is $imagepng->trim the best way to do this? ...

Zend Framework ORM-style table data gateway vs. extending Zend_Db_Table_Abstract

In the Zend Framework Quickstart, there has been a change from models that extend Zend_Db_Table_Abstract to the Table Data Gateway pattern. Personally, I have not had much experience with this pattern and I keep hearing this should most likely be used instead of the old way. A short example from the quickstart: Old way: class Default...

calling php from js (w/ ajax)

Hi, I'm building a basic forum where every post contains some text, first and last name, and the date the message was written. I'd like to have the board update with AJAX constantly, and to add new messages on the fly as they are written. I have a file, getlatest.php?date=... that retrieves all messages from the date in the $_GET till N...

Optimize this SQL Query

This SQL query disgusts me. I didn't write it, but it's a massive cause of issues on our servers. I'm willing to split it up into multiple queries and do some of the processing via PHP (like, the RAND()). $sql = "SELECT a.code, a.ad_id, a.position, a.type, a.image, a.url, a.height, a.width FROM " . AD_TABLE ." a, " . USER_GROUP_TABLE ...

Limiting Array results

Hi, I have the following code which currently limits the result into a couple of types (Banana, Orange or all): function selectFromArray($prefix="", $productArray=array()) { if(!strlen($prefix)) return $productArray; return array_filter($productArray, create_function('$element', 'return (stripos($element[1]...

Can PHP store Object state like the following code?

Hi, I am a newbie in PHP and I am asking wether I can initialize once for all data inside an object and use them later <? class Person(){ private $data;//private or public function Person($data){ $this->data['name'] = $data['name']; .... } function save(){ $this->dbconn.executeQuery('insert into ... va...