mysql

After mysql_query, no result output

I have a simple mysql_query() update command to update mysql. When a user submits my form, it will jump to an update page to update the data. The problem is that there's supposed to be some data shown after the update, but it comes out blank. My form <form id="form1" method="POST" action="scheduleUpdate.php" > <select name=std1> ...

Wait 30 seconds in order to allow a new action on PHP and MySQL?

In my web page a user fill a form who send information to a MySql database. One of the data inputs sent is a date/time, in the format date('l jS \of F Y h:i:s A'); (I can change the format as needed) So when the user submits the form I want to check if the actual time/date is 30 seconds more than the sent time/date in order to allow or ...

JPA and MySQL transaction isolation level

I have a native query that does a batch insert into a MySQL database: String sql = "insert into t1 (a, b) select x, y from t2 where x = 'foo'"; EntityTransaction tx = entityManager.getTransaction(); try { tx.begin(); int rowCount = entityManager.createNativeQuery(sql).executeUpdate(); tx.commit(); ...

Index a mysql table of 3 integer fields

I have a mysql table of 3 integer fields. None of the fields have a unique value - but the three of them combined are unique. When I query this table, I only search by the first field. Which approach is recommended for indexing such table? Having a multiple-field primary key on the 3 fields, or setting an index on the first field, whic...

MySQL ORDER BY, use column mod_time, but if mod_time is 0, use column create_time

Hi I want to order results based on two columns, mod_time and create_time. I want the most recent to be present. At the moment I have ORDER BY pr.mod_time DESC, pr.create_time DESC This breaks if the item has not modified, in which case mod_time is 0 and only the create_time is set. This effectively puts anything with a mod_time of ...

Rename INDEX Column

Hey All I have a database with around 40 tables and need to rename every index column. IE USER a table has a bunch of fields like user_id | user_username | user_password | etc... I want to rename the ID columns just to id ie id | user_username | user_password | etc... But I keep getting mysql errors on the alter table command ie....

Problem while redirecting user after registration

I am creating a simple website . My situation is like this. After registering an user, I want to redirect the user after say 3 seconds to a main page(if the registration succeeds) . The code I have now is as below $query = "INSERT INTO Privileges VALUES('$user','$password1','$role')"; $result = mysql_query($query, $dbcon) or die('Reg...

Allow users to pull temporary data then delete table data (headers remain)?

I don't know the best way to title this question but am trying to accomplish the following goal: When a client logs into their profile, they are presented with a link to download data from an existing database in CSV format. The process works, however, I would like for this data to be 'fresh' each time they click the link so my plan was...

Best solution to import records from MySQL database to MS SQL (Hourly)

I need to import records stored in a MySQL Database that I do not maintain into my Sql Server 2005 database (x64) We should import the records at an interval basis (probably 1 hour). What would be the best solution to perform the regular import? Windows Service (using reference MySql.data dll) Windows Client (could make it automated)...

MySQL, delete and index hint

I have to delete about 10K rows from a table that has more than 100 million rows based on some criteria. When I execute the query, it takes about 5 minutes. I ran an explain plan (the delete query converted to select * since MySQL does not support explain delete) and found that MySQL uses the wrong index. My question is: is there any wa...

How can I Display an extract from MySQL database entry?

I'm after creating a webpage that includes a blog section and it currently displays the whole post on the homepage. I'd like to set it so that it only displays a certain part of the entry i.e 50 words. I'd then like to be able to set it so that I have a read more button below the post that links to the post id. I currently use post.php?=...

MySQL error - I don't understand what it is saying

Query: INSERT INTO `job_listing_has_employer_details` (`job_listing_id`, `employer_details_id`) VALUES (6, '5') Error: Cannot add or update a child row: a foreign key constraint fails (mydb.job_listing_has_employer_details, CONSTRAINT job_listing_has_employer_details_ibfk_2 FOREIGN KEY (employer_details_id) REFERENCES employer_det...

Database Design and Performance : mySQL and PHP

I have made an image for this question: What is the right design? All site's block inserting in only one table or separate tables? Thanks in advance ...

select now() from table, why do we specify a table?

whats the point of specifying a table if now() is going to be the same for any table.?? ...

MYSQL Optimizing recurring expressions?

Does the Optimizer evaluate the avergae only one time, or two times? SELECT AVG(col1), 1/AVG(col1) FROM table Thanks ...

User role permissions for different modules using bitwise operators

So I have an application that has several modules (think of modules as different pages), each module has a set of permissions; view, add, edit, delete I want each user role to have privileges for each module, for example Role A Permissions Module 1 -> view Module 2 -> add, edit Module 3 -> view, add, edit, delete etc. H...

What is the use of Mysql Index key?

Hi I am a newbie to mysql Here are my questions: What is the use of Mysql Index key? Does it make a difference in mysql queries with defining a Index key and without it? Are all primary keys default Index key? Thanks a million ...

Help with making an SQL query based on some rules

Hello there. I've got this HTML form where I have multiple input elements: text, radio, and so on. These are intended to be options, conditional items to apply in an SQL query in order to pull more specific data from a database. For example, the first input field is a textbox, the second a radio button, and the third a SELECT with two ...

wordpress query custom fields and category

I have a query that creates a table view and then another that queries the view. The results are extremely slow. Here is the code: create or replace view $view_table_name as select * from wp_2_postmeta where post_id IN ( select ID FROM wp_2_posts wposts LEFT...

Create a PHP cache system in MySQL database?

I'm creating a web service that often scrapes data from remote web pages. After scraping this data, I have a simple multidimensional array of information to use. The scraping process is fairly taxing on my server, and the page load takes a while. I was considering adding a simple cache system using a MySQL database, where I create one ro...