mysql

Problem with date, membership expired but it isn't yeat

Hi there, I need to modify my valid notification script (which notify members, before membership expiration, on expiration day and so on), to work on specific way. So my expires column in database (MySQL) is datetime type so value in it for example look like this: 2010-08-08 13:46:38 Here is a thing: Script can be called from backend...

Get a MYSQL Date into a c# String exception

Hi. I'm trying to extract a date field from a mysql db using .NET and MySQL .NET Connector. Whithin the test everything works great except the date, I mean, I can get the varchar fields but the DATE field (called R_DATE) is impossible. My SQL Query is: SELECT * FROM TABLE And, the way I'm trying to read it is: DateTime date = reade...

the mysql query option "between" in "multiple column index"

I will design my mysql tables/columns using "multiple column index". I've checked some articles about "multiple column index". But I can't find information about the option "between" with "multiple column index". http://dev.mysql.com/doc/refman/5.0/en/multiple-column-indexes.html http://www.mysqlfaqs.net/mysql-faqs/Indexes/When-does-m...

What's a good practice to use forms in PHP? Can you use OOP PHP in a form?

Hello people, Right now i been creating a form for a comment section, a Login section, and sending email for a site i'm doing. The code I using was from a tutorial I learned and has too much HTML in it. It was the only way I knew how to create a form and valid the data. I wanted to ask if there was a better way to create forms and if t...

How to setup SQL database connection in Java application ?

I need to make an application in Java , which needs to use SQL database . I wil provide the users with the database file , but that won't run because to setup the database connection we first need to add a User DSN in Windows . Is there a way to add it( User DSN ) automatically when the applcation installs ? ...

CakePHP, do database row DeleteAll where 1 field is equal to something and other field is NOT equal to something

I'm struggling with doing this, I want to basically do a database deleteAll where one field is equal to something and another field must NOT be equal to something.. its for deleting duplicate rows so I want to delete all but one row.. the way I tried below isn't working, I Would appreciate any advice: $conditions = array ( "Prox.prox...

Changing hours to days

Editing the question. I have SQL like this: `table1`.`DateField` >= DATE_SUB(NOW(), INTERVAL {$days} DAY Now 24 hours make a whole day. However, what if I want to do the query for the last 3 hours or so? My table1.DateField is in the format of 2010-03-10 10:05:50. Original post: If I have this 1 hour 2 hours 3 hours .. 24 h...

Grails TimeZone issue, application wise and in Gorm entiteis

Okay, I've the strangest problem that I've just started to experience in a grails application working just fine for 2 months. Application is deployed on Linux/Tomcat 6 and MySQL is the DBMS at back end. When I type date on linux prompt, I get following output: $>date Sun Aug 8 03:52:06 PKT 2010 Where as in Grails application new Da...

sql date hour conversion

I have SQL like this: `table1`.`DateField` >= DATE_SUB(NOW(), INTERVAL {$days} DAY My table1.DateField is in the format of 2010-03-10 10:05:50. The value of {$days} could be 4 hours or 3 days. How can I make the above sql smart enough to know that? Should I use `table1`.`DateField` >= DATE_SUB(NOW(), INTERVAL {$days} DAY_HOUR ...

Get MAX() on column in two tables

I have two tables which both have the column DateTime. How can I get the MAX() DateTime? The shorter/simpler the better, because this is just part of a larger query. ...

MySQL: How to do foreign keys?

I wish to have a foreign key in a table but I have no idea how to do it. I wish have a UserID Column in the "wall" table so that I can link back and get the userid's details etc. How would i go about doing this? Wall Table: Users Table: ...

Python MySQL and Django problem

I am having problems getting python/django to connect to a MySQL database. The error message is basically "Error Loading MySQLDb module: No module named MySQLDb". This is a fresh install right off python.org, so I assumed that it would have the MySQLDb module included, but it does not seem to. I also can't seem to find the module or how...

How do I prevent MySQL from auto-incrementing the Primary Key while using ON DUPLICATE KEY UPDATE when the duplicate is a different unique column?

Consider the following table: +-------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+------------------+------+-----+---------+----------------+ | vendor_id | int(10) unsigned | NO | PRI | NULL | auto_increment | | vendor...

Can't Insert into MySQL Table using PHP

Having trouble inserting new records into a table. Anybody care to help? <?php include('config.php'); ?> <?php if(!empty($_POST['forename']) && !empty($_POST['surname']) && !empty($_POST['email']) && !empty($_POST['emailconfirm']) && !empty($_POST['password'])) { if($_POST['email'] == $_POST['emailconfirm']) { $forename = ...

Lua: How to connect & query MySQL from within Lua?

How can I connect to a MySQL database from using Lua programming language? If a good/popular library exists, what is it? ...

Online highscore for my game

I'm creating a game using c# and I would like an online highscore board. I prefer the highscore to be stored in a MySQL-database but other ways will also work. Please point me to the right direction. Edit, more information: I am using MySQL at localhost, dbname: diggangames. The game I'm creating in C# is a basic console application a...

How do i store a swf file name and location in mySQL database?

Hi, Problem, I cannot pre-view a flash movie in a php.page. Question, How, where, do i store a swf file name and location in mySQL database and then use this data to call it in the application? Thanks for reading Sabby77 ...

How to update phone numbers for an employee in a database using PHP

I've got a form that allows the user to edit an employees information: name, email, technician level, etc. Well this is not hard in itself, I'm trying to find a good method for updating phone numbers for each employee. I have two tables (that are relevant): technicians and phones. My form allows the user to add, remove and edit any amoun...

MySQL BLOB field INSERT syntax

Hi I'm writing a network server program in C++ which receives binary packets from network. Packets are then stored in std::vector< unsigned char > I've used MySQL 5.1 and MySQL Connector/C++ from ubuntu lucid to store packet information (field by field) into a table in a database. However, I also need to store the complete binary form ...

How to convert a date format

Table ID CardDate 001 09/01/2010 002 08/05/2010 DateFormat in the table : (mm/dd/yyyy) I want to make a datediff between cardDate & systemDate Query Select id, datediff(carddate, curdate()) as actualdate group by id from table The above query is showing a null value in actualdate column becuase carddate format is wrong. How to ...