mysql

MySQL query need optimization

Hi all, I got this query: SELECT user_id FROM basic_info WHERE age BETWEEN 18 AND 22 AND gender = 0 ORDER BY rating LIMIT 50 The table looks like (and it contains about 700k rows): CREATE TABLE IF NOT EXISTS `basic_info` ( `user_id` mediumint(8) unsigned NOT NULL auto_increment, `gender` tinyint(1) unsigned NOT NULL d...

Passing a set of user entered data to another area of a form

I create two table. 1 is key in mailing address like mailing street , city and etc. Another table is shipping address and the field is almost same with mailing address. Sometimes, the shipping address is same as the mailing address. How can i just create a radio button and when click it will copy the same think from mailing address to sh...

PHP- inserting binary data in mysql using prepared statements

Hello, I have to insert a row using php's mysql improved library to a table in mysql that has its primary key of type VARBINARY. The contents of this field are a computed sha1 hash. If I run the query the old way it works perfectly: $mysqli->$query("INSERT INTO table (id, field1) VALUES (0x" . $id . ",'" . $field1 . "')"); But when I...

MySql update PHP and JS

Hi I have the following code in my change.php page: $con = mysql_connect("localhost","root","root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("FACT", $con); if($_POST['isChecked']==1) // SEE THIS LINE PLEASE { mysql_query("UPDATE Orc SET CON = 'CHECKED' WHERE UID = '1'"); } ...

JQuery MySql update

Hi, im trying to adapt this little snippet: $("#checkbox_id").change(function(){ /* CODE HERE */ }); I have a series of checkboxes that are dynamically generated and their id's are always like "hug3443" were "hug" is the column in the DB and "3443" is the unique id for each row. My objective would be that every time the checkbo...

.NET application exports data to a remote Linux server.

There is a MySQL database located on my remote Linux server. I have written a .NET Windows application to export data to this MySQL database. I want to know whether there will be any compatibility issues regarding .NET / Linux? ...

Query Caching in MySQL

Ok, I am building a fairly large statistics system, which needs to allow users to requests statistics for a given set of filters (e.g. a date range). e.g. This is a simple query that returns 10 results, including the player_id and amount of kills each player has made: SELECT player_id, SUM(kills) as kills FROM `player_cache` GROUP BY p...

How to Have Search Engines Index Database-Driven Content?

How can I make it so that content from a database is available to search engines, like google, for indexing? Example: Table in mysql has a field named 'Headline' which equals 'BMW M3 2005'. My site name is 'MySite' User enters 'BMW M3 2005 MySite' in google and the record will show up with results? ...

Implement read/unread like in email

Hello Guys i am trying to implemenet something like the read/unread in the email.How can i do so by using jquery , php and mysql. What i want to do in steps: 1- When i click on a row in html table i change the status of the this message in database. 2- And then change the background of this row but also if i logout and relogin the row ...

Mysql. Can't create table errno 150

Hello, I have to create a db with 2 tables in mysql but the script fails with errno 150 (Foreign key problem). I double-checked the foreign key fields to be the same on both tables and I can't find any error. Here is the script: SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS,...

What is the best way to connect to and query a MySQL database using PHP?

Hi , This is a pretty easy question but I would like some clarity on something. I have seen a number of different ways to connect and query a MySql Database using PHP but which is the best way to connect and create a query using php ? Hope this makes sense. Thanks ...

Access against MySQL or Postgres?

I have a (potential) client who has had several a several Access applications previously developed which they want to upgrade to use a database back end. Unfortunately because of costs they don't want to use SQL Server, and SQL Express is likely inappropriate due to licensing restrictions. They have mentioned using MySQL and an option ...

How can I make my mysql database records visible to search engines?

I am creating a classifieds website called 'mySite', and I want whoever searches for honda +mySite in google, to find all ads with the description 'honda' or headline 'honda' from my database. How is this done? (a htm page for every ad? which then loads the 'ad data' when user clicks to open the htm page?) I have an example for yo...

SQL nested query in stored in an array?

I have an sql query pulling a few results from different tables, one of the tables - "orders" - contains customer details with an order_id as a PK, another table - order_products - contains each product ordered, with reference to the order_id and another column as PK. Basically, I need to know how to query the database in such a way tha...

Optimize PHP, MYSQL community website performance

Hi, I own a community website of about 12.000 users (write heavy), 100 concurrent users max on a single VPS with 1Gb ram. The load rarely goes above 3 and response is quite good. Currently a simple file cache is used to store DB query results to ease the load on the DB, but the website still can slow down over 220 concurrent users (loa...

MySql: Why Is this Query running so slow?

OK So I have this list of products that are in the cart. I am trying to retrieve all the related items to the items in the cart without pulling any items that are in the cart. I wrote this query and it pulls exactly what I want, but its taking like 8 seconds to run. SELECT * FROM cart_product WHERE product_id IN( SELECT product_r...

How to check if geocode is close to or on path defined in a KML LineString with PHP or MySQL

Hi, I have a KML file defining several paths/routes (representing actual roads) enclosed in the <LineString><coordinates></coordinates></LineString> tags. Parsing the file to other formats (arrays/MySQL) is already in place, so that's not a problem. Given a point (longitude/latitude) I would like to be able to check if the point is on ...

Working with multiple databases in php/mysql

I am working on a project needing me to work with multiple database connections. From what I have read, I should be able to switch between connections in the query itself, something like: mysql_query("SELECT * FROM user_types", $db_core)or die(mysql_error()); But I receive the error: Table 'db_company.user_types' doesn't exist So I...

No datetime values populated from MySQL using SubSonic 3 Linq

I have a MySQL table with a couple of Datetime columns. The columns are set to allow null and some have default value '0000-00-00 00:00:00'. This is a conversion project from ASP to ASP.NET so the table is full of data, and where some rows still have the default value, so I had to set "Allow Zero Datetime=True" in the connectionstring to...

MySQL BEFORE INSERT Trigger Select Into Multiple Variables?

I'm trying to write a trigger in MySQL and I need to set the values of several variables. The values I need to put into these variables are from a row in an existing table (not worried about multiple rows, there will only be one): DELIMITER | CREATE TRIGGER ins_move_to_hist BEFORE INSERT ON EndOfDay FOR EACH ROW BEGIN DECLARE _RowsMa...