mysql

Database design challenge

Hi Guys, I'm creating an virtual stamp card program for the iphone and have run into an issue with implementing my database. The program essentially has a main points system that can be utitlized through all merchants (sort've like air miles), but i also want to keep track of how many times you've been to EACH merchant So far, i have ...

Complex mysql query, please help.

I have a table of banners. Banners are marked with size id and slot id(position on page) I need to pick 8 banners of one size, 1 for each slot between 11-18(slot id) and keep randomness each page view, so that each time banners were different if there any different for required slot. The only solution i have found is this: SELECT * FR...

PHP: redis, predis vs. MySQL

I've been looking at Redis. It looks very interesting. But from a practical perspective, in what cases would it be better to use Redis over MySQL? ...

How to call store procedure in MySQL uisng PHP and display the value return by the store procedure?

Hi I got stuck not knowing how to create API in PHP. I have store procedure that I created in the MySQL and want the PHP to call that store procedure and use the value return from the store procedure as return value of the API. There might be many ways to do it and I would like to know all of them and want to know how they are differen...

How to JSON data using $.getJSON from a php file ?

I have a php file that receives data from mySQL table. The mySQL table 'user_spec' has only one field 'options' that it returns. Then I convert returned data into JSON, under is code doing that. <?php $username = "user"; $password = "********"; $hostname = "localhost"; $dbh = mysql_connect($hostname, $username, $password) or die...

select second largest from a table without limit

How we can select the second largest mark or whatever from a table without using the LIMIT ? I know it is possible using LIMIT, but is it possible without using that? suppose we have the columns id and marks. ...

MySQL multiple ways to see columns of a table. Why?

The following commands produce the same output describe tablename show columns from tablename show fields from tablename explain tablename Why are there so many different commands? ...

stop/compile/run = "Unable to connect to any of the specified MySQL hosts." + crash, why?

In visual studios while debugging my asp.net project i see a change i'd like to make. I cant change code dynamically like i may in a winform app so 100% of the time i stop the app. Write my code and run. Now randomly, a good % of the time i get the error Unable to connect to any of the specified MySQL hosts. with a crash shortly aft...

simple update of foreign key in php mysql website

hi i cannot update a table which has foreign keys on it. in this table, instead of displaying the primary keys of the foreign key, i choose to display their names: this is a simple diagram: Here are my foreign tables: Size Table: sId sName 1 1x1 2 2x2 Brand Table: bId bName 1 brand1 2 brand2 Supplier Table: sId sNa...

Converting utf8_general_ci tables and fields to utf8_unicode_ci

Hi Everyone, I have made a mistake when designing my application database several years ago and collation settings of my tables and table fields are mixed. Some of them are utf8_general_ci and some of them are utf8_unicode_ci. This causes problems when joining tables with different collations. Now, I am planning to change collation set...

CakePHP: No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)

hi, I have had a cakephp app running fine on my local machine (mac osx) for a while and then suddently I realise that I can't connect to mysql.sock. I'm getting this error: Warning (2): mysql_connect() [http://php.net/function.mysql-connect]: [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) [CORE/...

mysql alphabetical order

hi i am trying to sort mysql data with alphabeticaly like A | B | C | D when i click on B this query runs select name from user order by 'b' but result showing all records starting with a or c or d i want to show records only starting with b thanks for help ...

Parsing HTML / Javascript into a MySQL database

I'm looking for suggestions as to the best way to parse the following calendar... http://www.ucd.ie/events/calendar . I can't detect any well known framework being used nor can I find it in RSS/XML/JSON format. The only possible way to parse the following that I see is to parse the raw HTML which is far from ideal especially since many...

Easiest way to transform mysql table "as is" into xml document ?

Interested how to do it programmatically, not export table data once (there are tools for sure). easiest way to transform mysql table "as is" into xml document ? table contains say 2 rows: id name 1 "John Travolta" 2 "Mary Lynch" ideally we'd need a class that's gonna eat login/passw/host of a database and Goo...

error during Adding data through CSV file.

while I am adding details in database through CSV file I am getting error- Access denied for user 'user'@'%' (using password: YES) . I have checked database username and password. even if I add product one by one(without csv) it is workin fine. It means my database connectivity is correct. Do I need to make some change in my database hos...

php code displaying on web page instead of working behind the scene

Hi, I have an index.html in my wampserver www directory. On this html, there is a link for a user to upload file. When I hit the link, I select files to upload but instead of the uploadmanager.php which i have tested in my eclipse debugg environment to work, it displays the some part of the code on the web page without doing anything t...

Trouble connecting Heroku App with Amazon RDS Instance

I'm using Amazon RDS for the first time ever and I've been following the heroku docs to get my app using the RDS instance. So far I've created an instance and I have setup the addon using the format: $ heroku addons:add amazon_rds url=mysql://user:[email protected]/databasename After running heroku rake db:migrate I got ...

How can I grant MySQL permissions from inside PHP?

what is the syntax to execute this statement in php page- grant file on *.* to kentest@localhost identified by 'kentest1'; ...

extract only text or image from blob (php mysql)

Hi, I have BLOB field in MySql table with text and image inside, is there any way to extract out only text or only images? $query = "SELECT id, date, blob, FROM table ORDER BY id DESC "; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { echo "<div class=all> "<ul class=id>{$row['id...

How to select from two tables in MySQL even if not all rows in one table have corespondents in the other?

I have two tables for an online shop: one for categories: id, title one for products: id, ownerid, title, price (ownerid is the id of the parent category) I want to select all the categories and also select the minimum and maximum price in each, hence the following query: SELECT sc.*, MIN(s.price) AS minp, MAX(s.price) AS maxp FROM ...