mysql

Using a class within a class?

I built myself a MySQL class which I use in all my projects. I'm about to start a project that is heavily based on user accounts and I plan on building my own class for this aswell. The thing is, a lot of the methods in the user class will be MySQL queries and methods from the MySQL class. For example, I have a method in my user class t...

How can I add file locations to a database after they are uploaded using a Perl CGI script?

I have a CGI program I have written using Perl. One of its functions is to upload pics to the server. All of it is working well, including adding all kinds of info to a MySQL db. My question is: How can I get the uploaded pic files location and names added to the db? I would rather that instead of changing the script to actually uploa...

How to get database table header information into an CSV File.

I am trying to connect to the database and get current state of a table and update that information into csv file, with below mentioned piece of code, am able to get data information into csv file but am not able to get header information from database table into csv file. So my questions is How can I get Database Table Header informat...

How to upgrade self-hosted wordpress and installed plugins of live site to latest availalbe versions without facing any trouble?

I have to upgrade a running wordpress site's wordpress CMS and some installed plugins.and some plugins which i want to upgrade has been modified before to achieve something. http://is.gd/b5j9h How to upgrade Wordpress to latest without loosing anything, any post, comments? What precautions should i take? How should i take backup of al...

MySQL: Storage of multiple text fields for a record

An inexperienced question: I need to store about 10 unknown-length text fields per record into a MySQL table. I expect no more than 50K rows in total for this table but speed is important. The database actions will be solely SELECTs for all practical purposes (and searches will be done using an integer PK id only). I'm using InnoDB. In...

Dreamweaver recordset filter - Display all records as default

I am trying to create a simple search form to filter the results in the dynamic table. The search form is on the same pages as the results and posts to itself. I get the search string from the post variable. It is working, but I can't figure out how to set the default value to display all results. Dreamweaver automatically sets the...

Regex for mysql query to match html entities.

I understand PCRE pretty well, but MySQL's regular expression flavor seems to get the best of me. Can someone help me correct this expression? The PCRE equivalent would be &\w+; I'm guessing something like: select body from email where body rlike '&[[:alpha:]]+;%' Bonus: MySQL's docs on their regex flavor seem kinda sparse. Does any...

Preventing SQL injecting in a database class

I'm building a database class and thought it'd be a good idea to incorporate some form of SQL injection prevention (duh!). Here's the method that runs a database query: class DB { var $db_host = 'localhost'; var $db_user = 'root'; var $db_passwd = ''; var $db_name = 'whatever'; function query($sql) { ...

how do i load a csv file in rails from a migrate usiing load data local infile ?

Hi All, I have my csv file in my public folder, and i'm trying to load it from a migration, but I get a file not found error using this script : ActiveRecord::Base.connection.execute( "load data local infile '#{RAILS_ROOT}/public/muds_variables.csv' into table muds_variables " + "fields terminated by ',' " + "lines terminated by ...

Mysql SELECT FOR UPDATE - strange issue

Hi, I have a strange issue (at least for me :)) with the MySQL's locking facility. I have a table: Create Table: CREATE TABLE test ( id int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1 With this data: +----+ | id | +----+ | 3 | | 4 | | 5 | | 6...

On form submittal, a tick kills the app. But only in production.

A client just recently moved an application through the stages to production. I set up a testing environment on an "out-of-the-box" LAMP server, and can submit a form with a tick in the textarea. But in production the exact same code dies, but doesn't even execute the "or die();" I mysql_real_escape_string the input, which is why it w...

Unable to access MySQL from MyPHPAdmin after setting root password in EasyPHP{WAMP}

Am a new starter with WAMP and trying to play around my way using the EasyPHP setup. After successful setup on intial launch of MySQL, the page prompted me to set up ROOT password for security reasons. On setting the password, am no longer able to access MySQL. The error is : Error MySQL said: Documentation 1045 - Access denied for us...

auto_increment in MySQL - can I omit it?

I've noticed that PHPmyAdmin creates the following SQL for table creation: CREATE TABLE something ( ... ) auto_increment=1; When I write a database creation script I don't use the auto_increment bit. From reading related questions here I understand that it determines the starting value for auto_increment values. But it is good pra...

Why aren't my MySQL Group By Hours vs Half Hours files Not displaying same data?

I need to be able to display data that I have in 15 minute increments in different display types. I have two queries that are giving me trouble. One shows data by half an hour, the other shows data by hour. The only issue is that the data totals change between queries. It's not counting the data that happens between the time frames,...

How to print messages from MySQL for debugging purposes?

I'm more of a MS-SQL / PostgreSQL guy, but I'm working on a MySQL project. In one of my sprocs (functions) I would like to simply output the value of a variable at runtime for debugging purposes. With PostgreSQL, this is done using RAISE NOTICE. This there an equivalent method in MySQL? ...

How do I see the results of unique records added after adding records to mysql

I'm a PHP noob. I have a database that I will update weekly with a CSV. So far I've managed to upload the file to the server, open the file with PHP, and insert the data in my table. Now I want to return the unique records that were added (on screen or in a file). How do I do this? ...

What is the proper PHP syntax to post a file that exists in a directory that's on the server?

This is a basic post form in PHP that loads from the client PC. What is the proper syntax to load from a directory on the server? <form enctype="multipart/form-data" action="index.php?option=com_productionparse" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="90000000000" /><br /> Choose a file to upload: <input name="f...

Normalise this Table?

Hello all, I am creating a social bookmarking app. I am having a re-thought of the DB design in the middle of development. Should I normalise the bookmarks table and remove the tag columns that I have into a separate table. I have 10 tags per bookmark and therefore 10 columns per record (per bookmark). It seems to me that breaking the...

MySQL & PHP - select/option lists and showing data to users that still allows me to generate queries...

Sorry for the unclear title, an example will clear things up: TABLE: Scenario_victories ID scenid timestamp userid side playdate 1 RtBr001 2010-03-15 17:13:36 7 1 2010-03-10 2 RtBr001 2010-03-15 17:13:36 7 1 2010-03-10 3 RtBr001 2010-03-15 17:13:51 7 2 2010-03-10 ID and timest...

MySQL Collation or PHP side to display accented letters properly

What is the best Collation for the column that can allow to store accented letters and parse them out perfectly without any encoding error, because whenever I add an accented letter such as é, å, it shows out with an encoding problem on the PHP side, but in the MySQL side it's fine... How do I get the accented letters display properly? ...