mysql

mysqli_field_type returns a number

When I call mysqli_field_type it returns a number, which I assume relates to the type. Does anyone have a list of types and their corresponding numbers? I am in particular trying to find out if the data type is numerical or text (if that makes a difference). ...

Is there a free tool to convert mysql dump to postgres

Hi! I am trying to move my site from mysql to postgres, I don't know how to do it. Already dumped my mysql database with compatible option. But it's impossible to import the data directly. I wonder if there is a free tool, with GUI to do it I already tried several perl scripts but they appears to be buggy (no one helped) :( ...

Sudden "MySQL server has gone away" error in PHP site

Today one of my websites started showing Error Number: 2006 MySQL server has gone away It's a low-traffic client site running under Apache 2.2.9 (Debian), PHP 5.2.6-1+lenny3 (using CodeIgniter 1.7.1 framework) and MySQL 5.0.51a. I obviously reasearched about the error but all the possible solutions imply that there are big queries goin...

How do you remove a table COMMENT in MySQL?

We have a MySQL table that was altered with ALTER TABLE t COMMENT 'foo' we later realize that we don't want that comment. Is there a way to delete it? simply saying ALTER TABLE t COMMENT 'NOT foo' simply adds an additional comment, so that when you do a SHOW CREATE TABLE t it shows BOTH comments... ETA: AH, the problem seem...

How to override the attribution of an auto incrementing primary key when inserting a value in a MySQL table?

I have a mySQL table of users whose primary key is an auto-incrementing integer. The table is already populated with records whose key is between 0 and 30.000. Not all records are there, though. Some users have been removed and therefore I have "holes". Now the client has realised they removed a bunch of users by mistake, and they now w...

SQL join that displays left table even if right table doesn't match where

I have 2 tables, defined as such: CREATE TABLE `product` ( `pid` SMALLINT( 5 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR( 50 ) NOT NULL, `description` TEXT, `qty` SMALLINT( 5 ) UNSIGNED NOT NULL DEFAULT '0', `category` ENUM( '1', '2', '3', '4', '5', '6', '7', '8' ) NOT NULL DEFAULT '1', `price` DECIMAL( 7, 2 ) UNSIGNE...

How to save an array of unsigned char to MySQL

Any idea on how to save an array of unsigned char to a field in MySQL database ? I'm considering BLOB, but how can I convert it to QByteArray and convert it back to an array of unsigned char when I want to ? BTW, I'm trying to save fingerprint data. ...

How to create a mysql query for the following?

I have the following query: SELECT m.*, COUNT(c.chapter_nr) as chapters, MAX(c.chapter_nr) as latest_chapter FROM comic_series AS m JOIN chapters as c on c.comic_id = m.id WHERE m.title_en = 'test' This allows to me to find the chapters from a comic book by just giving the name of the comic. The query selects all the columns from the ...

Lost connection to MySQL server during query

I have a huge table and I need to process all rows in it. I'm always getting this Lost connection message and I'm not able to reconnect and restore the cursor to the last position it was. This is basically the code I have here: # import MySQLdb class DB: conn = None def connect(self): self.conn = MySQLdb.connect('hostname', 'u...

MySQL View: How do I set default value of a calculated field to 0?

I use the following statement to create a percentage calculation in a view: round(((Surveys.RejectedAsAdvertising / Surveys.Responses) * 100),0) AS PercentageAdvertising Basically, I divide the number of responses to a certain question (in this case, is something considered to be advertising) by the total number of responses. In the e...

Delete data from all tables in MYSQL

I have 100 tables, 40,000 rows in each table. I want to go into MySQL and delete all rows from all tables. ...in 1 statement, if possible? I want to keep the database and tables. ...

What's the difference between VARCHAR and CHAR?

What's the difference between VARCHAR and CHAR in MySQL? I am trying to store MD5 hashes. ...

Multiple users table VS 1 users table? (mysql and php)

I am in dilemma situation. I am not sure if its a good idea to separate the users table. I notice my game highscores table performances, as the numbers growing, the loading is getting slower and slower. My current users table store all users, which currently about 10k users. I am thinking of splitting the users table (for future) into l...

save user actions?

i want to save logged in users actions so when they visit the page again they don't have to do the same thing again eg. what list values they chose or what page they were on before they logged out. i dont want to save it as cookies because i want them to be unchanged even if he switch computer. should i save these kind of information in...

Getting data is fast, but Flash displaying php data is slow, why?

In my database(mysql), I have a table which has 50k data(rows/records). I do a test using firebug, after playing the game, the call to load_score.php and save_score.php is around 380ms (millisecond). The save_score.php just a normal inserting, nothing much. The load_score.php, I use this query: SELECT name, score FROM `highscores` WH...

How to write an and operation in a SQL statement?

mysql_query("insert into mytable (flow,holderid,amount,operator,ip,product,taskid,comment)values('-1','$memberid','$sum+5','$memberid','$ip','Expertise','$taskid','Publish a problem or task') ")or die(mysql_error()); I get an error about '$sum+5' MySQL doesn't treat it as an and operation, how to resolve this problem? ...

How can I get back my privilege to create a new database in MySQL?

I can not use MySQL. MySQL is on my local computer. Currently I added skip-grant-tables in My.ini so I can use MySQL. But I have no privilege to create a new database. My problem is tough, although I asked related questions on SO, but no answer can resolve my problem. I almost give up. So I lower my expectation. I am developing a website...

php form script

I'm very new to PHP and am having some trouble. I have a form using HTML which is action=.php method=post The form is using text boxes and select options, I'm not sure if it makes a difference in sqldatabase. I've tried about 30 different combinations of this script and can only get a connect successfully message but nothing is posted....

Install rails 2.3.5 mac os 10.6 (snow leopard)

Hi guys, My website is developed with ruby on rails 2.0.2. So I want to update this version to 2.3.5. Unfortunately, the new rails version doesn't include mysql so I install the mysql gem like this tutorial said => install rails But and it's my problem, when I launch my server (webrick), mysql crash (segmentation fault). I don't find ...

self joining a table

Basically when do we need a self join on a table? ...