mysql

Change of mysql db password brings down website

Hello, Each time I change the MySQL db password, and update the dbconfig file, the website is down. I also flush privileges Any idea why? ...

Mysql: Take column value if not null else take another column value

I have 2 columns in mysql table: a and b. a is allways string value and b is sometimes a string value and sometimes it is null. How to construct a mysql SELECT so that the b would be taken if it is not null and a would be taken otherwise. I tried to make some magic with concat and if...then with no success... Please help Jerry UPDAT...

How to update column with the data from the columns in the same row in MYSQL?

I have a table house with fields price and area, now I want to add one more column named 'average_price'. How could I set the average_price according to the price and area in MYSQL? ...

MySQL find crossovers in a table for different profiles for a same user

I have two tables one is table Profile and other is table Profile_location (stores the relation of a profile and a location). Problem: A user can have multiple profiles, each profile has different locations. I want to find crossover of locations between each profile of a given user. In other words, evaluate all the profiles of a given u...

Store "password is ok" in php Session variable?

Is it safe to store a password in a sessions variable? For example, usage would be in a form which is submitted to itself. For example a change classifieds page, where users first enter a password, and then if pass=ok, show the form to change the classified. All on same php-page. But Whenever a picture is uploaded in the "change" part...

HTML form with spanish characters displayed wrong in MySQL database

So I'm sending data to my MySQL database through a HTML form. When I send a word with special characters like "ñ" or accents "á, é, í.." and when I check the result in the tables those characters are displayed as "ã±". I tried pretty much everything: my html form page header has <meta http-equiv="Content-Type" content="text/html;cha...

Ruby on Rails Incorrect Primary Key Names

Hi I'm using RadRails to create my MYSQL databsase tables. This is migration task: class CreateEvents < ActiveRecord::Migration def self.up create_table :events do |t| t.string :eventname t.string :evententryurl t.string :eventurl t.timestamps end end def self.down drop_table :events end e...

One query to retrieve from two tables?

Let's say I have two tables: one stores links and contains a link_id column, and the other stores info on how many times a particular link has been clicked and it contains a count column and the link_id column. What would be the query to the table in order to retrieve all the links along with the info? ...

How to do a within-group aggregate query in MySQL?

I am trying to get the latest modified "posts", from a group of "posts", that all have the same parent_id. I already learned today that grouping is not the answer, and that I should either use an inner subquery, or a "within-group aggregate", thanks to this site >> Aggregates >> Within-group aggregates. I chose to go with the latest, as...

php mysql bit fields

Strange, i am using apache + php with windows. php processed mysql bit fields as number: it's work correct; $b = $row['bit_field'] if ($b == 1) { echo 'ok'; } with centos and php 5.3.3 './configure' '--with-mysql' '--with-mcrypt' '--enable-mbstring' '--with-imap' '--with-kerberos' '--with-imap-ssl' '--with-libjpeg' '--with-libpng' ...

how to cache latest inserted data in MySQL?

Is it possible to cache recently inserted data in MySQL database internally? I looked at query cache etc (http://dev.mysql.com/doc/refman/5.1/en/query-cache.html) but thats not what I am looking for. I know that 'SELECT' query will be cached. Details: I am inserting lots of data to MySQL DB every second. I have two kind of users for ...

MySql error in C# after reading 100 lines from serial port.

Hi, I have a program that reads from a serial port. the program works fine but, after reading 100 lines from the serial port i get the following error. An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll Additional information: error connecting: Timeout expired. The timeout period elapsed...

Is a master table with only one column necessary in this mysql example?

I have a mysql DB with a table that holds version information for multiple other tables. In order to link to the same family of versions I have a version_master table that holds a primary key to the family of versions that the link refers to. I was wondering if there was a more elegant solution without the need for a version_master table...

PHP mssql_init('mydb') failing. Stuck trying to call trivial Stored Proc from PHP

Is there any way to turn on driver logging for PHP/MySQL 5? Is there a log that shows internally what's going on... like all database activity? Lower-level errors? I'm trying to get a trivial PHP page to call a trivial stored proc on Windows 7. mysql_error isn't returning any error message when the mssql_init() fails. Thinking it mi...

Retrieve individual values along with their sum?

I have a table that contains link_ids that relate to another table; and this table has column titled ammount that stores values typed int. To retreive some total ammount along with individual values I query it as follows: SELECT ip, ammount, (SELECT SUM(ammount) FROM stats WHERE link_id = $link_id) as total_ammount FROM stats WHERE link...

Ajax retrieve data from Mysql - Not working properly

I am learning AJAX and I am trying to recreate this fairly simple example: http://www.w3schools.com/php/php_ajax_database.asp I created this database: So now to recreate the example I just basically copied and pasted the code: index.html <html> <head> <script type="text/javascript"> function showUser(str) { if (str=="") { do...

Full text search - tag system problem

I store tags in 255 varchar area, like this type; ",keyword1,keyword2,keyword3,key word 324,",keyword1234, (keyword must start and end comma (commakeyword123comma)) - I can find a keyword3 like this sql query; select * from table where keyword like = '%,keyword3,%' CREATE TABLE IF NOT EXISTS `table1` ( `id` mediumint(8) u...

IF NOT EXISTS for adding mysql column ?!

hey guys i need to run this mysql code on my sites and i suspect some of them to have already this column is there anything such if not exists for the bellow code ?! ALTER TABLE `comments` ADD COLUMN `active` int(1) NOT NULL DEFAULT '0' after `sid`, im concerning this to prevent getting the duplicated column error ! ...

MySql in cluster environment

Does MySql support for cluster environment? Whether Community edition support for clustering? I want to know more details about it. Please guide me where can I get details? ...

PHP MySql query to delete rows doesn't work.

I have this php script: foreach (get_all_topics () as $topic_id => $topic_info) { $result = mysql_query("DELETE FROM marks WHERE user_id = $user_id AND topic_id = $topic_id", $db); echo "DELETE FROM marks WHERE user_id = $user_id AND topic_id = $to...