mysql

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...

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...

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 ...

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...

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...

Can't get the database to update last login time using PHP and MysQL?

Here is my last login part that dosen't seem to work here it is. I think I messed up somewhere? // Query the database: $q = "SELECT user_id, first_name, user_level FROM users WHERE (email='$e' AND pass=SHA1('$p')) AND active IS NULL"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysq...

Can i view tables which are under Partition in my sql

Can i view tables which are under Partition in my sql??? How to view such tables??? ...

How to manually set seed value as 1000 in MySQL

I am using MySQL 5. I need to set the seed value as 1000 for my auto increment field. How can I set it? ...

MySQL query execution return value?

Hi, I'm constructing an adapter for MySQL in PHP and I was wondering what should MySQL query execution method return? Should it return a result set? Or the last id / affected rows? ...

Pear DB_DataObject and input cleaning

I normally use a function of my own to clean input before adding the values inside a query to prevent sql-injections. I also use pear DB_DataObject. I read somehere that DB_DataObject cleans the input itself. Is this true? Can i assign uncleaned input to a DB_DataObject object? (What about mysql_real_escape_string?, i get an error usi...

Check already made query for distinct field values but without making other query

Hi all, I am trying to make menu with multiple submenus.I need to make query that takes the result of preceding query and leaves only distinct results of some field.If i make new query each time the server bugs because the query searches through veri big database. So in short something like that :select distinct(field) form(already made...

Getting multiple records on year wise.

Hi All, I have a Patient information table with ~50 million records. I need to check some samples for each year which may be in any order. Here are the sample date available in database "20090722", "20080817", ... "19980301". Also i have a primary-key column called "PID". My requirement is to get 2 or 3 samples for each year with a...

Issue calling a MySQL stored procedure (with params) via a linked server (SQL Server 2005) using OPENQUERY syntax

Hello, I'm having issues when trying to call a MySQL (5.0.77) stored procedure with parameters, via a linked server (SQL Server 2005) using the OPENQUERY syntax. The MySQL stored procedure returns a result set, and when I use the 'EXEC ... AT ...' syntax the call works fine, e.g... EXEC('CALL my_stored_proc(''2009-10-07'',''2009-10-07...

mysql_fetch_array, mysql_fetch_assoc, mysql_fetch_object

The functions are all very similar: mysql_fetch_array(), mysql_fetch_assoc(), mysql_fetch_object() I have recently started using mysql_fetch_object as I am doing alot more OOP with PHP. But what are peoples opinions on which one is best to use and why, and maybe which scenario they are best to be used in. Thanks for your thoughts! ...

[SQL] Retreive/update rows with a minimal deviation in a certain column value

I have a database table with one column being dates. However, some of the rows should share the same date but due to lag on insertion there's a one second difference between them. The insert part has been fixed already but the current data in the table needs to be fixed as well. As an example the following data is present: 2008-10-08 1...

Zend Framework Cardinality violation: 1241 Operand should contain 1 column(s)

Hi guys, I have a sql problem and i don't know how to fix it, I have tried a few things but..you know.So here is my query: /** * Returns a list with all the months for the archive * * @return array */ public function Archive() { $q = "SELECT DISTINCT MONTH(`data`) AS `month`,YEAR(`data`) AS `year` FROM `posts` ORDER BY `data` D...

How to handle foreign key while partitioning

Hello, I am working on fleet managment.I am having large amount of writes on a location table with following coloums 1>date 2>time 3>vehicle no. $>long 5>latitude 6>speed 7>userid (which is foreign key...) Here this table is going to have write operation every 3 sec.Hence there will be millions of record in it. So to ret...

Is there any table changes tracking tool for mysql which will log all changes into other table?

Hi, I am working on a Project management system on PHP (CodeIgniter framework), Mysql, AJAX, XAMPP, JQUERY. I need a customizable table changes tracking tool which will log all changes into another table in same database for mysql. Basically I need to have a table which will have log details of updates, inserts and deletes on a database...

MySQL Group By with top N number of each kind

I have a table like this: Rank Letter 1 A 2 A 3 B 4 A 5 C 6 A 7 C 8 C 9 B 10 C And I need the top 2 of each letter ordered by ascending rank: Rank Letter 1 A 2 A 3 B 5 C 7 C 9 B How would I do ...