mysql

Turning On General Query Logging FOR WINDOWS in MySQL.

I want to view the actual SQL resulting from a php call to mysqli->prepare, and apparently the only way to do that is by logging all queries. However, I can't seem to manage to turn on query logging in mysql for windows. Help? ...

Creating dynamic icons based on data entered into database from django forms

So I'm using Django to create a projects page with multiple forms for each project. Let's call them form 1, 2, 3, and 4. Once you create a project you can fill out any of these forms. I want to create "buttons" or links for each one of the forms that would show up on the main page. Now this is the part I need help with: Step 1. I want i...

List all links in a mySQL table, multiple links per row

I have a CMS. I'd like to get a list of all the links in all of the content. If pages.content is my table.field, then I can get pages that have A link: SELECT id, content FROM pages WHERE lower(content) RLIKE '<a href="[^"]+">[^<]+</a>' That's as far as I get before I get stumped, though. How to return only the link and handle mu...

Dealing with a badly formatted CSV file

I have an exceptionally bad CSV file. Although I "solved" the problem in the end by manually writing scripts to process and reprocess this specific file I wanted to know if there were any other solutions out there. You have a CSV file that has all the fields terminated by | (pipe) characters. Running a quick check shows you that there a...

MySQL UNION query from one table + ORDER BY

I have one table with two queries and I need to sort it with descending type using ORDER BY. Here is my MySQL query that does not work properly: (SELECT `text` FROM `comments` WHERE user_fr='".$user."' && archive='1' ORDER BY `is_new_fr` DESC) UNION (SELECT `text` FROM `message` WHERE user_to='".$user."' && archive='1' ORDER B...

Extend precision of MySQL's double datatype?

I am trying to save the value "6.714285714285714" into a DOUBLE datatype field. Unfortunately it does not fit at all and is cutted by one char. Storing larger numbers becomes less precise. Already searched in the mysql manual and it seems to be that double is the most precise data type available. Anyone knows a practicable workaround? ...

ImportError with Pylons/SQLAlchemy and MySQL

Firstly, I should say I'm completely new to Pylons, trying to learn web development with Python after coming from a PHP/MySQL background. I've seen similar questions to this problem, but mine is kind of a reverse version. I've been following the Pylons book (pylonsbook.com) to setup my application and get the following error: ImportErr...

Possible to sort via two time stamps and display same row twice.

I'm looking at creating a time table solution. I have a task sheet that looks like Area 1 item 1 startTime endTime Area 1 item1 startTime endTime I wish to create a display where I can view what even is happening next, either endTime or startTime i.e. Newcastle reel 16:45 18:45 Newcastle reel2 17:45 19:45 would outpu...

How to use Python list comprehension (or such) for retrieving rows when using MySQLdb?

Hey all, I use MySQLdb a lot when dealing with my webserver. I often find myself repeating the lines: row = cursor.fetchone() while row: do_processing(row) row = cursor.fetchone() Somehow this strikes me as somewhat un-pythonic. Is there a better, one-line way to accomplish the same thing, along the lines of inline assignme...

Open-source generic web service to database interface?

I'm looking for a thin, generic layer (probably written in PHP) that sits between a database (probably MySQL) and web service clients (which could be anything). I imagine there would be config files of some sort that tell it how to map web service requests to database queries (or other DB commands). It would also need to handle authent...

SQL: Limit rows linked to each joined row

Hello, I've certain situation that requires certain result set from MySQL query, let's see the current query first & then ask my question: SELECT thread.dateline AS tdateline, post.dateline AS pdateline, MIN(post.dateline) FROM thread AS thread LEFT JOIN post AS post ON(thread.threadid = post.threadid) LEFT JOI...

MySQL: Matching inexact values using "ON"

I'm way out of my league here... I have a mapping table (table1) to assign particular values (value) to a whole number (map_nu). My second table (table2), is a collection of averages (avg) for each user (user_id). (I couldn't figure out how to properly make a markdown table, please feel free to edit!) table1: table2: (value)...

Average rating script

I need to know how to make a rating script for a site. I have a form that submits a rating out of ten to mysql. How would you get the average rating to be displayed from the mysqk column? ---using PHP with mysql ...

how relate one table to another for future records

I have a games table which holds the data about a game. Then another table which holds the data about news. So far so good. First I thought about creating a junction table for game_news so I could relate news to games. This way works as intended when the game exists. So whenever I insert a news I can relate it to a game using the junc...

MySQL "IS IN" equivalent?

A while ago I worked on a MS-SQL project and I remember a "IS IN" thing. I tried it on a MySQL project and it did not work. Is there an equivalent? Workaround? Here is the full query I am trying to run: SELECT * FROM product_product, product_viewhistory, product_xref WHERE ( (product_viewhistory.productId = product_xref.product_id_1 ...

Populating fields in modal form using PHP, jQuery

I have a form that adds links to a database, deletes them, and -- soon -- allows the user to edit details. I am using jQuery and Ajax heavily on this project and would like to keep all control in the same page. In the past, to handle editing something like details about another website (link entry), I would have sent the user to another ...

MYSQL: Error: Cannot add or update a child row: a foreign key constraint fails

Hi all, Using MySQL on Windows OS, and am getting an error upon attempting to create a foreign key between two tables: CREATE TABLE tf_traffic_stats ( domain_name char(100) NOT NULL, session_count int(11) NULL, search_count int(11) NULL, click_count int(11) NULL, revenue float NULL, rpm float NULL, c...

Convert SQL Server Varbinary field to MYSQL, keeping data intact

I was given the daunting task of converting a ASP website to PHP and SQL Server to MySQL, and I ran into an issue that hopefully somebody can help I have a user table which has a password field with datatype Varbinary(128), are using pwdencrypt to encrypt the password. Is there a way to transfer that over to MySQL, and somehow i need t...

PHP & MySQL username submit problem

I want to allow users to either have there username field empty at any time but I get the username error message Your username is unavailable! how can I correct this problem? Here is the PHP code. if(isset($_POST['username'])) { $u = "SELECT * FROM users WHERE username = '$username' AND user_id <> ...

php import to mysql hosted on godaddy

Yeah, I know! It's not my choice. I am doing a large data import using a PHP script into a mysql DB hosted on godaddy. It seems their mysql connection gets killed every few hours regardless of what work it's doing. Their tech support is useless, and I've exhausted myself writing attempted workarounds. Right now, I'm trying to do a mysq...