mysql

MySQL Great Circle Distance (Haversine formula)

Hello All, I've got a PHP script that gets Longitude and Latitude values...then inputs them into a MySQL query. I'd really like to make it solely MySQL. Live site can be found at http://MotoListr.com Here's my current PHP Code: if ($distance != "Any" && $customer_zip != "") { //get the great circle distance //get the origin zip ...

How to keep special characters when running ./mysqldump?

How do you keep the special characters when you run mysqldump? On the database it appears correctly when i do a query. But on the file after i export, all special characters look like this: 'R. António Lt1, 1º Dtº' ...

How to create/find a Joomla/Community Builder 'Latest Users' module? Playing with dates in MySQL/Joomla...

A few years ago when Joomla first sprung up and I moved over from Mambo I remember finding a great little component called Community Builder (CB) that extends the user-based interface behind Joomla. Over the last couple of years both Joomla and Community Builder have grown and flourished. I find myself remembering a small module I found...

Calling db rows by id but backwards

I am building a Links voting site, the formula works ok after the link is voted the second time, the problem is that when the link just has 1 vote it shows up backwards, from oldest to newest. What I want is for links with one vote to show from newest to oldest. This is the line that calls the links in the front page: $articles = Arti...

Php serialize

Im trying to save serialized arrays into my mysql database then retrive them and unserilize them but I cant work out how to unserialize them. here is what I have so far: $query = mysql_query("SELECT friends FROM users WHERE id='$myid'"); $friends = mysql_fetch_array($query); unserialize($friends); Stuck here ????? array_push($friend...

Database design issue - multiple scores in different categories

Say I have a database of clothing products. In addition to many other fields, the database needs to store ratings (marks out of 10) on different categories for each product. For example, one category could be 'occasions'. The occasions could be as follows: Wear to the office Wear to a wedding Wear on a date ... Wear to a funeral Each...

unserialize problem

Hi, I have another problem with my scripy now I have made it more advance, first off the count function doesnt work properly and it gives this error. *Warning: array_push() [function.array-push]: First argument should be an array in C:\wamp\www\social\add.php on line 42* Here is my script: $query = mysql_query("SELECT friends FROM use...

How do I select titles from a mysql DB that begin with a specific letter?

I need to make an alphabetical listing of movie titles, so I need to show only items that begin with a chosen letter. To make this slightly more complicated, many titles start with "the" or "a", which needs to be ignored. How would the mysql query look to achieve such a task? I could simply have an extra column with the search letter s...

Windows: How to open a .exe in a shell window that won't close?

I've had this problem for ages, and it's SO ANNOYING. Suppose I want to run mysqldump.exe... here's my process: Start->run, type "cmd" ... dir into directory after directory until I finally get to c:/program files/mysql/bin/then I can FINALLY call "mysqldump.exe" I don't mind using Windows Explorer to get to c:/program files/mysql/bin...

Setting mysql usernames and passwords

Hi I have recently installed easyPHP at home to do some development work with my computer running as the server (Windows XP). easyPHP sets up apache, php and mysql to work on your computer. I am having trouble setting the usernames and passwords for the mysql accounts (sadly, I've only ever done this through cPanel). The easyPHP GUI l...

How do I subtract all prices in a mySQL table with SQL only?

I was playing with the following, but it's not there just yet. ALTER TABLE `product_price` CHANGE `price` = `price` - 20; ...

Using a table to keep the last used ID in a web server farm

I use a table with one row to keep the last used ID (I have my reasons to not use auto_increment), my app should work in a server farm so I wonder how I can update the last inserted ID (ie. increment it) and select the new ID in one step to avoid problems with thread safety (race condition between servers in the server farm). ...

chrooted Apache+MsSQL on openBSD; Could not determine the server's fully qualified domain name

php generates GIFs on the web server using a databases on a second server. The the page shows 20 GIFs, so there is some load for a short time (multiple connections) Some GIFs are loaded but some are not, in /var/www/logs/error_log [Mon Feb 23 10:05:56 2009] [error] PHP Warning: mysql_connect() [function.mysql-connect]: Lost connect...

Truncate Slow Query Log in MySQL

What's the safest way to truncate the MySQL slow query log (under Linux primarily, but Windows would be handy to know) while MySQL is running? By safe I mean: Mustn't cause any permissions problems Mustn't jump back to its original size next time its appended to ...

(MySQL) Alter table in multiple databases

I have a set of databases and each of them contains a table named 'data'. I would like to add a new column to the table 'data' in all databases. Is it possible to do this with a sql statement? And would it work on MySQL 3.x server? ...

PHP file upload

Hi, I am trying to upload files to my server using php to save them into a binary form into my mysql database but I cant get it to work, here is the script I’m using, I believe it has something to do with "$_FILES" because when I take this out "&& $_FILES['userfile']['size'] > 0" the script starts to run but then the variables underneat...

mysql - select pagination chunk that includes a given id

...before the pagination chunks have been determined. I know you can do this in multiple statements, but there must be a better way. my results are returned ordered by date and I want to return the pagination chunk that contains a given id. So I could, for example, select the date of the given id and then select a chunk of results ...

MySQL import/export version incompatibilty

Hi I have taken a dump from my mysql database on my own server (version 5.0.67) and I have tried to import it to my other database (version 5.0.54). However, I get the error: ERROR 1193 (00000) at line 23: Unknown system variable 'character_set_client' I think it refers to this part: SET @saved_cs_client = @@character_set_client...

PHP PDO Buffered query problem

I'm having some serious problems with the PHP Data Object functions. I'm trying to loop through a sizeable result set (~60k rows, ~1gig) using a buffered query to avoid fetching the whole set. No matter what I do, the script just hangs on the PDO::query() - it seems the query is running unbuffered (why else would the change in result se...

SQL Sums in Rows Pulled out into Columns?

I have a search that is very slowly done by finding the primary records then looping in a thread to sum related transactions. I'm trying to make it work in a single statement, have come close but still have records which are alternating debit and credits. I can't work out how to pull the debit and credit rows up into columns so there is...