mysql

Java Threads and MySQL

Hello all, I have a threaded chat server application which requires MySQL authencation. Is the best way to have 1 class create the MySQL connection, keep that connection open and let every thread use that connection but use own Query handler? Or is it better to have all threads make a seperate connection to MySQL to authencate? Or i...

insert entries in multiple tables in php

I found this tutorial at tizag.com. But It is for displaying entries from different tables. How can I do an insert? <?php // Make a MySQL Connection // Construct our join query $query = "SELECT family.Position, food.Meal ". "FROM family, food ". "WHERE family.Position = food.Position"; $result = mysql_...

datatype for checkboxes in php

What should be the data type that will be entered in phpmyadmin if I plan to use a checkbox as an input? ...

mysql return table name

let's say i have this mysql table structure: table : articles ---------------- id content table : news ------------ id news is there a way to search for a string in this two tables and then if the string occurs to return the table's name and the row id ? ...

LIKE Statement in PHP

What will be the syntax if I want to list a person with an address like the one inputted by the user?Here is my code, please help. The form input would be address. I want to do something like this: http://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html <?php $con = mysql_connect("localhost","root",""); if (!$con) ...

MySQL Brackets?

Latelly I've seen a lot of PHP/MySQL questions that enclose SQL values within {}, for instance: SELECT * FROM table WHERE field LIKE '{$value}'; What's up with that? Is it even valid? Why do so many people use this weird (at least for me) syntax? ...

mysql time type display 12:00 AM as default value

$s=00:00:00 ( default value in time type filed in database) if i do $sp=date('g:i A',strtotime($s)); then it return 12:00 AM i want that if there is a default value in database then it doesn't display any time or make it blank for further use ...

Sql Query for Different result

Hello Friends, I am using mysql for database. I have to find the distinct latest result for a customer having different values for ContentPrvdr field. I am using following sql query: SELECT distinct ContentPrvdr,LocalDatabaseId,Website,BusID,LastUpdated, UserCat1Rank_Local,UserCat1Count_Local,Citations,PhotoCount, VideoCount,Cat_Count...

Is there a text based mysql UI?

I don't mean the standard mysql-client CLI, but rather something similar to what midnight commander is to filesystem management. The simple command history of the basic cli is not bad but really doesn't cut it when testing more complex query, and the layout of the data isn't that great. PHPMyAdmin is useful and all, but it's ugly and req...

What timezone does MySQL TIMESTAMP columns use ON UPDATE?

Does it use the server timezone or UNIX_TIMESTAMP (UTC) ? And how do I get the current time in PHP, in the same timezone as MySQL's TIMESTAMP columns? ...

How to connect XAMPP MySQL local DB using JDBC?

I have this Tetris game written in Java, which uses DB to record high scores. It worked ok as long as I was using remote MySQL DB, but now I'm trying to set up localhost DB using XAMPP MySQL and it keeps going like "SQLException: Communications link failure" at command: con = java.sql.DriverManager.getConnection("jdbc:mysql://localhost/...

Implementing parts of rfc4226 (HOTP) in mysql

Like the title says, I'm trying to implement the programmatic parts of RFC4226 "HOTP: An HMAC-Based One-Time Password Algorithm" in SQL. I think I've got a version that works (in that for a small test sample, it produces the same result as the Java version in the code), but it contains a nested pair of hex(unhex()) calls, which I feel ca...

Mysql - Alter a column to be AUTO_INCREMENT

I'm trying to modify a table to make it's primary key column AUTO_INCREMENT after the fact. I have tried the following sql, but got a syntax error: ALTER TABLE document ALTER COLUMN document_id AUTO_INCREMENT Am I doing something wrong or is this not possible? +--------------------+ | VERSION() | +--------------------+ | 5...

Must-have features for F/OSS SQL analyzer/optimizer

Hi all, I like MySQL's Query Analyzer...but not the price tag. I think I can write something myself to do analysis on slow query logs, indexes, table status fields, etc. and offer it as an alternative, F/OSS solution. What would be your top-requested features for such a solution? ...

search by category with php mysql

hello im using this code to do search <form action="arama.php" method="get"> <input type="text" name="lol"> <select name='kategori'> <option value="tum">Tum kategoriler</option> <? while ($kat = mysql_fetch_array($kategori_isim)) { echo " <option value=".$kat[kategori_isim].">".$kat[kategori_isim]."</option>"; } ?> </select> <inpu...

Importing _mysql in MySQLdb

Why is _mysql in the MySQLdb module a C file? When the module tries to import it, I get an import error. What should I do? ...

Is it safe to move a MySQL instance by copying the log file onto a snapshot?

My MySQL database is outgrowing the drive that it is one. I'm on EC2 so I can create snapshots easily. Therefore I propose the following process: prune the log files snapshot restore to a bigger volume at a new mount point stop the server copy the log files swap the drive mount points restart the server -- it should read from the binar...

How to insert form data into MySQL database table

So I have this registration script: The HTML: <form action="register.php" method="POST"> <label>Username:</label> <input type="text" name="username" /><br /> <label>Password:</label> <input type="text" name="password" /><br /> <label>Gender:</label> <select name="gender"> <optgroup label="genderset"> <opt...

Are integer queries on MySQL DATE or TIME columns slow?

Is it more efficient for me to store dates as INTs and convert to and fro a string representation such as "2010-01-30" or is it alright to store dates as DATE when needing to perform very frequent integer queries such as WHERE Date < 20100130... Are dates internally stored as strings or integers? ...

[SQL] Is it possible to update a fields value with the value of the field in the previous row?

I have a table from which I would like the update the value of a certain colum of fields. Basicly moving one value down and those under it should inherit the previous value of the one about them. I wonder if this action is possible using a single SQL query. My table: CREATE TABLE `menu` ( `slot_index` int(2) NOT NULL, `language_...