php

Best Method: Parsing CSV file and Passing back to front end using AJAX

Hello all, I have a CSV file that is uplaoded to my server where a PHP script will parse and return output to JavaScript via AJAX. The CSV file is made up of two rows. First row contains the column names and the second row contains the data. I am trying to write a script that will parse it in a form that will be usable by Javascript to...

CakePHP inefficient database queries: can they be avoided?

My table structure: boxes (id, boxname) boxes_items (id, box_id, item_id) I was looking at the SQL logs for the "delete box" action, and am slightly horrified. SELECT COUNT(*) AS count FROM boxes Box WHERE Box.id = 191 SELECT BoxesItem.id FROM boxes_items BoxesItem WHERE BoxesItem.box_id = 191 SELECT COUNT(*) AS count FROM boxes_item...

selecting results with range + Pythagoras theorem

i have a mysql table for uk people that includes: postcode beginning (i.e. BB2) latitude (int) longitude (int) range (int, in miles, 1-20) http://www.easypeasy.com/guides/article.php?article=64 - theres the article for the sql file i based my table on now it says i can use Pythagoras theorem to calculate distances based on longitude...

Writing Yahoo! Bot: Why can't I fetch a web page on Yahoo! mail with help of PHP?

I want to write a bot that fetches my mail on Yahoo! but my first problem is I can't fetch the web page where login and password have to be filled in. I do it so: <?php $the_url = "http://www.yahoo.com/r/l6"; $ua_s = "Opera/9.62 (Windows NT 5.1; U; En) Presto/2.1.1"; $c = curl_init($the_url); curl_setopt($c, CURLOPT_RETURNTRANSFER, tr...

PHP Ranking System Array Sort

Hi, I develop a ranking system. I got the following array: [1] => Array ( [botarin - Branding und Kommunikation] => 1 [Raiffeisen Kredit 2 Go] => 2 ) [2] => Array ( [Kindersteckdosen] => 1 [Surf lieber mit bob] => 1 [Lafarge Imageinserate] => 1 [MCG Messecongress Graz Inserat...

Login Interupt and Refer Back to Page using PHP/MySQL

Hello, I am currently using PHP/MySQL, and I'd like to know the best way make an unauthenticated user login, and then have them automatically redirected to the page they logged in. For example: 1) User tries to open up secure page. 2) They're re-directed and prompted to login. 3) After they login successfully, they're taken back to t...

PHP's magic method __call on subclasses

My situation is best described with a bit of code: class Foo { function bar () { echo "called Foo::bar()"; } } class SubFoo extends Foo { function __call($func) { if ($func == "bar") { echo "intercepted bar()!"; } } } $subFoo = new SubFoo(); // what actually happens: $subFoo->bar();...

problem saving to mysql database php mysqli

Hi all i'm trying to save data to database and i get an error i never saw before i have a hunch it has something to do with the db collation but I'm not sure whats wrong, here is the query: $query1 = "INSERT INTO scape.url (url,normalizedurl,service,idinservice) VALUES (url, normalizedurl, 4, 45454)"; $query = "INSERT INTO ...

PHP: Is there a way to change request address?

For some reason, if I request a file using a url such as this: http://localhost/proxy.php?url=http%3A//anintranetsite/file.jpg It works! I can get the file. But if I use, http://127.0.0.1/proxy.php?url=http%3A//anintranetsite/file.jpg I cannot get it to work. I am not unnderstanding what is going on... Any thoughts on what co...

PHP - Format date from database?

When I pull the date out of the db, it comes back like this: 2009-10-14T19:00:00 I want to format it in two different ways... The first: F d, Y The second h:m (12 hour format) Everything I try returns December 1969... Help?! I feel so confused... ...

How to write an efficient hit counter for websites

I want to write a hit counter script to keep track of hits on images on a website and the originating IPs. Impressions are upwards of hundreds of thousands per day, so the counters will be incremented many times a second. I'm looking for a simple, self-hosted method (php, python scripts, etc.). I was thinking of using MySQL to keep tra...

Preventing SQL injection: is mysql_real_escape_string() really all I need?

Possible Duplicate: Best way to stop SQL Injection in PHP It seems far too good to be true to me that this simple function does all I need. Yet most of my google searches lead to results that basically say "just use this function and all will be well!". I've seen a couple that briefly, or at too high a level for my own beginner...

Where should form validation occur in a MVC project?

I'm using Kohana, but I think this question is more general. I have been doing form validation in the controller, and it has worked well so far. But lately, I've ran into a problem. I have a comments model, and I send comments from a few different controllers to it. Instead of having a validator in every controller, I placed it in the ...

Getting Zend_GData Feed for a Specific Google Calendar

I had a long detailed question about how to get a specific calendar's event feed, but figured (I think) a solution out before I posted. However, even with the solution I'm left wondering what I'm missing about this process. To get a single calendar's event feed (or to search that feed) I do the following: Authenticate (obviously) Get a...

Java: What data structure to use to imitate PHP's associative arrays?

I want a data structure that allows me to map keys to values, like PHP's associative arrays. Each key can only exist once, but a value can be mapped to any number of keys. What am I looking for? Something in the Google Commons Collections? ...

PHP end date calculation

Hello , i have a situation where i know the start date and the durration of an event in days , how can i calculate the end date ? i found topics on how to calculate the duration between two dates but nothing in my case Thanks in advance . ...

php money_format

i am trying to remove the .00 at the end of the price function getMoney($mon) { setlocale(LC_MONETARY, 'en_US'); return money_format('%.2n', $mon); } Thank You, ...

Help!! MIME error with mail() and attachment

The following script works (almost) just as I want. This project is so near completion with one small problem. In the email message I get the following: "If you can see this MIME then your client doesn't accept MIME types! --jacquie1003" This is being sent through Novell GroupWise. I have included the mail script and the resulting em...

How do you limit PHP memory usage when processing MySQL query results?

So I have a PHP page that allows users to download CSV for what could be a whole bunch of records. The problem is the more results the MySQL query returns, the more memory it uses. That's not really surprising, but it does pose a problem. I tried using mysql_unbuffered_query() but that didn't make any difference, so I need some other wa...

How to build a last login script using PHP?

I was wondering how can I create a last login script using php. ...