mysql

Dropdown select based on database entries

So, I would like a select to auto-populate the dropdown's "Yes" selection, or alternatively, the "No". The returned value from a database query will be used to evaluate which dropdown will be selected. I have thought since it's a true/false auto-population to just write 2 conditionals, but I thought there would be a better (read: less m...

Python: use mysqldb to import a MySQL table as a dictionary?

Anyone know how I can use mysqldb to turn a MySQL table, with lots of rows, into a list of dictionary objects in Python? I mean turning a set of MySQL rows, with columns 'a', 'b', and 'c', into a Python object that that looks like this: data = [ { 'a':'A', 'b':(2, 4), 'c':3.0 }, { 'a':'Q', 'b':(1, 4), 'c':5.0 }, { 'a':'T', 'b':(2, 8),...

PHP timeout during simple connection to MySQL - on win2k8 64bit IIS 7 / FastCGI php - new install

I installed PHP/FastCGI and Mysql on w2k8 64bit IIS7. PHPinfo() loads fine, and MySQL extension is properly installed. PHP displays echo commands. MySQL also works fine through the MySQL Command Line Client. I can create DBs, tables and users. However MySQL does not respond and the PHP script times out when simply connecting with mysq...

PHP/Session/IE: Constant are saved, variable not

I have a very strange problem. Situation: Session handling over MySQL, PHP 5.2.4, wildcard cookies, FF/Opera/Safari/Chrome works, IE7/8 not. When I save a variable into the session, the value is lost. The DB shows after the write action only "N" instead of "123456". Example: $bar = 123456; $_SESSION['foo'] = $bar; But when I save a...

Using Django database layer outside of Django?

I've got a nice database I've created in Django, and I'd like to interface with through some python scripts outside of my website stuff, so I'm curious if it's possible to use the Django database API outside of a Django site, and if so does anyone have any info on how it can be done? Google hasn't yielded many hits for this. ...

Handling large records in a J2EE application

There is a table phonenumbers with two columns: id, and number. There are about half a million entries in the table. Database is MySQL. The requirement is to develop a simple J2EE application, connected to that database, that allows a user to download all numbervalues in comma separated style by following a specific URL. If we get all ...

MYSQL like a join but only need the newest row?

I want to do the following but in one query: $query = mysql_query("SELECT name FROM tbl_users WHERE category = '1'"); while($row = mysql_fetch_assoc($query)) { $query2 = mysql_query("SELECT datecreated FROM tbl_comments ORDER BY datecreated DESC LIMIT 1"); $row2 = mysql_fetch_assoc($query2...

Merging sql queries to get different results by date

I am trying to build a 'recent events' feed and can't seem to get either my query correct, or figure out how to possible merge the results from two queries to sort them by date. One table holds games/, and another table holds the actions of these games/. I am trying to get the recent events to show users 1) the actions taken on game...

MySQL query involving cross join, uniqueness, etc

Thankfully, I haven't had to work with particularly complex SQL queries before. Here's my goal. I have the table hams, which I would like to cross-join with the table eggs - that is, get all ham-egg combinations... to an extent. The eggs table also has an attribute how_cooked, which is defined as ENUM('over-easy','scrambled','poached')...

PHP mysql_real_escape_string() issue

Perplexed here.... This code: $qry = sprintf("INSERT INTO news_sites_homepage_grab VALUES ('', %d, '%s', NOW(), NOW())", $site_id, mysql_real_escape_string($html)); ...is executed in a loop where $html changes every time. This code executes once but the next time, the script simply dies. No ...

MySQL SUM in different ways

I have two tables user_raters: | id(int) | to_id(int) | value(int) | created_at(datetime) |1 | 2 | 1 | 2009-03-01 00:00:00 EDIT: I changed the user_rater_id. history_user_raters.user_rater_id is related to user_raters.id history_user_raters: | id(int) | user_rater_id(int) | value(int) | created_at(datetime...

SELECT limiting to only results based on a CSV list from a separate table

So I have a list of CSVs in one table. (EG: 1,3,19 ) I want to search out all of the usernames from the other table where the ids match any of those. I feel like I should be able to do something like: <? $query = "SELECT player_ids FROM cast_list WHERE game='".$gameid."' "; $result = mysql_query($query) or die(mysql_error()); $player...

How do I set up an inbound mail controller so users can post to unique email address?

Tumblr (the short form blogging platform) has a feature where you are given a unique email address (for example, [email protected]) that you can email text or images and it automatically formats it into a post for you (as long as the sending email address matches your account email address). I'd let to set up something similar, but sol...

mysql template in php

Hi, I come across this sql code in a php software. What does the #section_filter mean? Is that a valid mysql syntax? or just a templating system? $filterid = ac_sql_select_one(" SELECT id FROM #section_filter WHERE userid = '$ary[userid]' AND sectionid = 'article' AND conds =...

How to use a variable name in a mySQL statement?

I'm using R to call a mySQL statement, where I define the variable outside the statement e.g. foo = 23; dbGetQuery(con, "select surname from names WHERE age = '.foo.' ;") But this returns an empty set, I've googled around and tried'.&foo.' ".foo." '".&&foo."' and many different combinations, but none of them work, I think this s...

ADODB to PDO quick switch

Hi! In past i use adodb for mysql in php. Now i wont to use PDO. How can i quick switch from adodb query to pdo using one connection to datebase? ...

How to split comma separated text in MySQL stored procedure

How to split comma separated text (list of IDs) in MySQL stored procedure to use result in SQL "IN" statement. SELECT * FROM table WHERE table.id IN (splitStringFunction(commaSeparatedData, ',')); ...

How to build a 'related questions' engine?

One of our bigger sites has a section where users can send questions to the website owner which get evaluated personally by his staff. When the same question pops up very often they can add this particular question to the Faq. In order to prevent them from receiving dozens of similar questions a day we would like to provide a feature si...

How to show related content using like in mysql?

I currently have a table for products with it's own set of tags and a table for news with it's own set of tags. I wanted to add related news to the products page so I was thinking of using like but since the column tags in the products page is something like (Products) tags- manutd, man utd, football (news) tags - manutd, blah, bruha ...

Quick SQL question! Sort by most occurences of an attribute

Hi guys I have two tables as such: Categories: ID - Name - Desc Items ID - Name - CategoryID - Desc - Price I want a query that returns a list of categories ranked by most occurences in the items table ...