mysql

MySql Error will not let me connect to DB

(HY000/2002): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock Does anyone know of a solution to this problem? ...

MySQL epoch time between two column epochs

Hi all, Sorry if this has been asked but can't find anything. I have a table that has two epoch timestamps (one is start of a session, other is end of a session), I want to find if a variable is in between column x and column y. I've used between to see if a column is between two variables but can't really think of the syntax for the ot...

How to sort ENUM column in MySQL database ?

I have color column in MySQL table which type is ENUM('RED', 'YELLOW', 'MY_COLOR', 'BLACK'), and another name column which type is VARCHAR(30). I would like to get all table rows in the following order: YELLOW rows first, sorted by name RED rows last, sorted by name In the middle, all other rows, sorted by name Is that possible to m...

MySQL Set NULLABLE Unique Field

Hi there, I've a case where I need to store twitter username, email, and some other field to be unique. However, I can only set twitter username later. Not on registration process. How can I handle this in SQL? Here's my current SQL structure: CREATE TABLE `kios_users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(32) NO...

Generate html files from MySQL data with file names as function paramater names from MySQL categories?

Hi all. So building on my question posted here http://stackoverflow.com/questions/3951716/using-python-to-write-to-html-file-with-mysql-data-as-source I have worked out how to do that although a bit different to the answers. Now my question is related to how to create html files from the data stored in MySQL, using the Category names fro...

How to store Log in database ?

My application let users to send files to each other. Regular users can edit their contacts, change password, etc. In addition, admin users can add/remove users and view the log of what happened. My question is how to store this log in MySQL database ? I thought to store the log like this: log_id time user_id action_type ...

PHP MySQL? Problem

I am using a simple PHP script for the activation part of one of my applications. The applications posts one variable to the page (http://validate.zbrowntechnology.info/WebLock.php?method=validate). The variable is the serial number, posted as 'Serial'. Each time I post to this page, it returns Invalid. Here is the code: <?php $serial...

PHP + MySQL: Get result from fetch array and convert to variables automatically?

I was wondering. I always do fetch and then create variables when I do loop. Is there a way to do this more efficient? Like as in automatically? Maybe something like convert_to_variable("name","description","etc") and it'll automatically set variables for me without having to do each manually? Or maybe a single command like convert_to_...

Create a function in Python which creates a mySQL database

Hi, I've created a program in python and mySQL which creates a database and imports the data from text files and puts them into 4 different columns. The code works but I want to change the code and create functions. Can anyone please help me create a function that creates a mySQL database? Here is the code I have at the moment. Thanks ...

Please help identify MySQL performance bottlenecks in my app

I have a facebook app that I have written in PHP/MYSQL and FBJS/AJAX. The app is Rails Across Europe, which may be found at http://apps.facebook.com/rails_across_europe (please note that it does require access to your FB data). If you would like to view a screencast of the app's operation, you may do so at http://screenr.com/TZR and http...

Conditional Foreign Key to multiple tables

I have a table which contains two type of data, either for Company or Employee. Identifying that data by either 'C' or 'E' & a column storing primary key of it. So how can I give foreign key depending on data contained & maintain referential integrity dynamically. id | referenceid | documenttype ------------------------------- 1 | ...

mysqladmin -s status FAILS to return anything when cpu is 100%?

So,we have a script which monitors mysql every 70 seconds. First it checks for the pidof mysql and then if it finds the pid, it runs mysqladmin -s status -p<password> Now recently we observed mysqld going to 100% cpu load. What I want to know is, will mysqladmin itself FAIL or stall or whatever when the cpu load is 100%? ...

Echoing out a field and a value from one row while running a query that ranks all rows

Hello, I have a MySQL query called $sqlStr5 that ranks rows by a metric called totalScore2. One of the fields that $sqlStr5 returns is called username. I would like to echo out the rank and the value of totalScore2 where username equals a variable called $u. How can I do this? Below is what I have so far. Thanks in advance, John...

How to update 400k rows on a production MySQL db and don't kill it

On our production server we need to split 900k images into different dirs and update 400k rows (MySQL with InnoDB engine). I wrote a python script which goes through next steps: Select small chunk of data from db (10 rows) Make new dirs Copy files to the created dirs and rename it Update db (there are some triggers on update which will...

Replace a word in BLOB text by MySQL.

Hello! I've got a huge mysql table (called tcountriesnew) and a column (called slogen, blob type). In each of those slogen blobs I'd like to replace a word, for example: banana to apple. Unfortunately I tried to print all the rows with word banana, and it did not work. select * from tcountriesnew where slogen like '%banana%'; Please ...

Search a text with single quote

For example I have a list of words: men's package, moment, immensely How can I search in mysql sample text: "men's" and return only "men's package" I'm using this $str = str_replace("s", "%s", $str); If I search for "men's", it will only show: men's package but when I search for "mens" it will also show: men's package, moment, immense...

How do I select a row in MySQL that contains multiple values?

I have a MySQL table that looks like this: Table: Designer id: integer name: String gallery: string The gallery row can contain a string value like 23,36,45 Now I want to do a query similar to this: SELECT * FROM Designer WHERE gallery = '36' I know I kan use LIKE, but that is not precices enough. That could return bot...

MySQL Join with 3 tables and empty rows

I'm giving up for now with my JOIN creating a view for search reasons - I need help :/ Here are my tables: Profiles id company user_id 1 ACME 2 2 Joe 4 3 Wolf 5 Users id role_id online 2 4 2010-10-08 4 2 2010-10-08 5 4 2010-10-08 Rubrics id title 1 Stee...

How to differentiate between 0 and null in an INT column in MySQL

If there is a null value stored in a MySQL INT column, it will return 0 when accessed by technoligies like JPA. If 0 value also stored in the column, how can I differentiate between null and 0? ...

[C] check input for UTF-8, count characters, use regular expressions

Hi, I want to write a C-programm that gets some strings from input. I want to save them in a MySQL database. For security I would like to check, if the input is a (possible) UTF-8 string, count the number of characters and also use some regular expressions to validate the input. So my question is the following: Is there a library that ...