mysql

Ways I can protect my site excluding XSS and Sql injection?

Hi,So, members of my website can post topics, replies, comments, edit them and so on. I always use htmlspecialchars and addslashes for html inputs to protect my site against XSS and SQL injection attacks. Is it enough or is there something more I miss? Thanks. ...

Getting a 1064 Error in MySQL but query still completes? Not sure why!!

Hi there, I am trying to insert a lot of fields into a MySQL database, some are failing, so I am adding some code into my PHP script to try and track down what is occurring. The replace seems to work as I can see the fields being populated in mysql, but I get this error: 1064:You have an error in your SQL syntax; check the manual...

Any way to install myodbc 2.50.39-nt on a 64bit windows 7 computer?

Is there anyway to install myodbc 2.50.39-nt on a 64bit windows 7 computer? (it says 'the version of this file is not compatable with the version of windows that you are running') I have a few old VB6 programs that use it (almost all of it has been moved to a private intranet) If it isn't possible, it looks like the newer version of myo...

Pound symbol not displaying on web page

Hello I have a mysql database table to store country name and currency symbol - the CHARSET has correctly set to UTF8. This is example data inserted into the table insert into country ( country_name, currency_name, currency_code, currency_symbol) values ('UK','Pounds','GBP','£'); When I look in the database - the pound symbol appea...

How can I set a default sort for tables in PHPMyAdmin (i.e. always "Primary key - Descending")

Even though its obnoxious in a lot of ways I use PHPMyAdmin all the time to debug database issues while writing PHP. By default it sorts tables by primary key ascending. 99% of the time I would rather have the newest data (my test data) shown at the top by default rather than the useless first few records ever saved. Is there a way to ...

How to get count of another table in a left join

I have multiple tables post id Name 1 post-name1 2 post-name2 user id username 1 user1 2 user2 post_user post_id user_id 1 1 2 1 post_comments post_id comment_id 1 1 1 2 1 3 I am using a query like this: SELECT post.id, post....

Archiving rows dynamically

I was wondering what would be the best solution to dynamically archive rows. For instance when a user marks a task as completed, that task needs to be archived yet still accessible. What would be the best practices for achieving this? Should I just leave it all in the same table and leave out completed tasks from the queries? I'm afraid...

Regarding Database data deletion from tables in mysql

Hi All, I'm new to mysql. My Requirement is I have a database "sample" and there are 20 tables in it with some sample data. I want to remove all the data from all tables of that database without deleting tables or recreating them So please help me with a solutions. Regards Chandu. ...

INSERT 0..n records into table 'A' based on content of table 'B' in MySql 5

Using MySql 5, I have a task where I need to update one table based on the contents of another table. For example, I need to add 'A1' to table 'A' if table 'B' contains 'B1'. I need to add 'A2a' and 'A2b' to table 'A' if table 'B' contains 'B2', etc.. In our case, the value in table 'B' we're interested is an enum. Right now I have a...

mysqli_multi_query and mysql transactions

I'm experimenting with transactions for the first time in mySQL. I am wondering if it is safe to use mysqli_multi_query for this purpose. That is, can I assume that if any of the SQL statements fails, everything will be rolled back? $query = " START TRANSACTION; (a bunch of SQL statements) COMMIT; "; ...

MySql ODBC connection in VB6 on WinXP VERY slow. Other machines on same network are fast.

Hi All, I have a VB6 application that has been performing very well. Recently, we upgraded our server to a Windows 2003 server. Migration of the databases and shares went well and we experienced no problems. Except one. And it has happened at multiple sites. I use the MySQL ODBC 5.1 connector to point to my MySQL database. On identical...

Get the previous date in Mysql

I have a table formatted similar to this: Date | ID | Value | Difference I need to get the difference between a record's value column, and the previous record's value column based off of the date. I.E 2 days ago | cow | 1 | Null Yesterday | cow | 2 | Null Today | cow | 3 | Null Yesterdays difference would be 1, and today's differe...

MySQLi - declaring variable after bind_param?

This may be a completely dumb question, but I've seen a couple examples declaring the variables AFTER putting them in bind_param: http://devzone.zend.com/article/686 I've never seen this done before and all my programming knowledge says I should define them before hand. Is this a valid/preferred way? ...

MySQLi - Should every statement be prepared?

I know its supposed to improve performance and clean strings, but lets say there are no variables? Might just be a SELECT COUNT( `column` ) AS count FROM `table` Should that be prepared? Is there any case that a SELECT statement should not be prepared? ...

Mysql - Help me alter this search query involving multiple joins and conditions to get the desired results

About the system: We are following tags based search. Tutors create packs - tag relations for tutors stored in tutors_tag_relations and those for packs stored in learning_packs_tag_relations. All tags are stored in tags table. The system has 6 tables - tutors, Users (linked to tutor_details), learning_packs, learning_packs_tag_relatio...

MySQL Database Query Problem

I need your help!!!. I need to query a table in my database that has record of goods sold. I want the query to detect a particular product and also calculate the quantity sold. The product are 300 now, but it would increase in the future. Below is a sample of my DB Table ...

Creating a Variable of Present Date Minus a Past Timestamp

Hello, In the code below, "created" is a field in a MySQL table. This field is of the type "timestamp" and the default is set to "CURRENT_TIMESTAMP" of whenever a given row is created. In the query below, I would like to create a new variable that equals the present date minus the timestamp of "created", rounded off to units of days...

Database Formatting for Album Tracks

I would like to store album's track names in a single field in a database. The number of tracks are arbitrary for each album. Each album is one record in the table. Each track must be linked to a specific URL which also should be stored in the database somewhere. Is it possible to do this by storing them in a single field, or is a rel...

C#:checking existing record in database Mysql

HI.I searched this question inform and I found solution to change column property Unique Index.Now If I try to insert same record cmd.ExecuteNonQuery() gives error that record exist ,but how can use this exception to give user a message that record exist and must enter new one ? I am trying to make some thing like if(cmd.ExecuteNonQ...

where to store information like gender and year of birth?

i have users and i need them to specify a gender (male, female) and year of birth (1930, 1931...1999, 2000). i wonder where i should store these values: in the database? in php file? if i store them in the database i have to manually create all entries first. but a good thing is that the user table will have constraints so the gende...