mysql

Write a file header with select into outfile directive ?

Hi, I need to find a way to insert a file header (not column header) and dump my data after that. How would you do that ? Regards, ...

How to insert data only if data doesn't already exist in MYSQL?

This is what I'm doing right now: Execute a query and check if the date to be inserted already exists in a table. If date doesn't exist: Another query will insert the date into the table. How can these two query be combined? ...

How to recover the datas in MYSQL?

Can recover the data in MySql after the updation?I update the field and by mistake i lost the correct data.. ...

Preventing server-side scripting, XSS

Hey all Are there any pre-made scripts that I can use for PHP / MySQL to prevent server-side scripting and JS injections? I know about the typical functions such as htmlentities, special characters, string replace etc. but is there a simple bit of code or a function that is a failsafe for everything? Any ideas would be great. Many tha...

Select log lines from today in mysql

I never remember how to do this properly - can you help me fix this query? SELECT * from log where now() - EventTime < '1 day' Note - this question seems identical but there's no solution there for mysql. ...

Drupal Views pulling Data Fields

I'm a little new to drupal but have been using things like devel module and theme developer to speed up the learning process. My question, is it possible to theme an entire views BLOCK from a single views tpl.php page OR even a preprocess? When I'm grabbing the $view object I can see results $node->result, it has all of the results, bu...

Will this encoding be a problem in the future?

I have this function inside a php file: mysql_query("SET NAMES 'utf8'") or die(mysql_error()); mysql_query("SET CHARACTER SET 'utf8'") or die(mysql_error()); some stuff happening here, rename($src, $dest.$cat); Thats on the server, and is the setup I have today which works (atleast on my browsers). Now, on my local machine (my...

Any harm in setting php.ini, my.cnf and httpd.conf (apache2.conf) charsets?

I am thinking about setting the php.ini, my.cnf and httpd.conf default charsets=UTF-8 The website is in swedish lang only. I have some folders with special chars in them, also some files. Is there any harm by doing this? Is it cross-browser safe? Thanks ...

Check mysql_query results if DELETE query worked?

I have a DELETE query which deletes a record from a mysql db. is there any way to make sure if the delete was performed or not? I mean, for a query to FIND stuff you do $res=mysql_query($var); $nr=mysql_num_rows($res); and you get nr of rows returned. Is there any similiar method for deletion of records? Thanks ...

Displaying records up to a certain 'age' - MySQL query syntax?

Quite a simple question, but I haven't been able to find any useful resources to help with this. Basically, I want to query my SQL database table, of which one of the fields is of type 'date'. Currently, the webpage outputs the three most recent records dependent on this date field. Ideally, I want to display all records which are under...

SQL time issue - need it 6 hours forward!

Possible Duplicate: Add 2 hours to current time in MySQL? My server is currently based on us eastern time, and as I am in the UK, i need to move this forward 6 hours. When using now() in mysql, i am getting the wrong time, is there anything i can add to now() to bring it forward 6 hours? Thanks ...

PHP mysqli error return time

Hello. Can i ask a fundamental question. Why when I try to create a new mysqli object in php with invalid database infomation (say an incorrect database name) does it not return an error intstantly? I usually program server stuff in Java and something like this would throw back an error strait away, not after 20 seconds or so. For ex...

I can't delete records from MySql

I have two tables. table a references table b I believe. When I try to delete the package alltogether like this: $query="DELETE a, b FROM classified as a, $sql_table as b WHERE a.ad_id = '$id' AND a.classified_id = b.classified_id AND a.poster_password='$pass'"; b MUST be deleted first I guess. Even in PhpMyAdmin I cant delete a if ...

Problem in Union Join For MySQL Query

hey guys i managed to select from a table that saves my latest posts but i need to have double condition in selection here is my code : $sql_query = "SELECT b.*,u.username AS MY_Sender FROM TABLE_users u,TABLE_blogs b Where b.reciever = '0' AND u.user_id = b.sender UNION SELECT b.*,u.username AS MY_reciever FROM TABLE_users u,TABL...

PHP: need more decimal places for sinus calculation

Hi volks, to calculate some longitude and latitude values I need more decimal places like mysql is possible to do. For instance with mysql I get this result: cos( RADIANS( 47.685618 ) ) = 0.67319814951254 With PHP 5.2 I only get: cos( deg2rad( 47.685618 ) ) = 0.673198149513 Two decimal places shorter but I need them. I know I a...

How to fix MySQL CREATE FUNCTION query?

I want to add mysql function: CREATE FUNCTION `chf_get_translation`(translation_id INT, site_lang INT) RETURNS text CHARSET utf8 BEGIN DECLARE translation TEXT; SELECT title INTO translation FROM chf_translations WHERE key_id = translation_id AND lang_id = site_lang; RETURN translation; END But get error...

Error No 150 mySQL

Hi all. This is making me sweat - I am getting error 150 when I try and create a table in mySQL. I've scoured the forums to no avail. The statement uses foreign key constraints - both tables are InnoDB, all relevant columns have the same data type and both tables have the same charset and collation. Here's the CREATE TABLE and the origin...

locking save button for some time

hi, i am using php,mysql,jquery. When a user clicks on save i go to back end and save data and show the response. once show the success i need to disable the save button for say 1 min. how do i do it.? here is ma code $(document).ready(function() { if ($.cookie('<?php echo $userId ?><?php echo $product ?><?php echo $alias ?>a...

hibernate criteria filtering on a set of enum values

Hi I'm using Hibernate 3.2 with a 1.6 JDK and Mysql 5.0 I'm trying to use the criteria api to put together a dynamic filter. However when I add a Restriction on a Set of Enums that is a property of my Criteria object I get a org.hibernate.exception.GenericJDBCException. my code is like this: public class FollowUp { ... public...

Transformation of records 1 column 3 row -> 1 row 3 column

First look at below query SELECT COUNT(id) AS total_record, id, modeller, MONTHNAME(completed_date) AS current_month, QUARTER(completed_date) AS current_quarter, Difficulty, YEAR(completed_date) AS current_year FROM model WHERE modeller != '' AND completed_date BETWEEN '2010-04-01' AND '2010-05-31' AND Difficulty != '' GROUP...