mysql

delete from two tables in one query

hi , i have two tables in mysql #messages table : messageid messagetitle . . #usersmessages table usersmessageid messageid userid . . now i want to delete from messages table it's ok . but when i delete message with messageid='1' for example it's still exists on usersmessage i have to delete from this two tables at once ; s...

Connection Lifetime=0 in MySql connection string

What exactly does Connection Lifetime=0 mean in a connection string? ...

What is the best way to "clean" information to be stored in a SQL database?

Scenario: I have a blog that I want to make a post to. I have a form set up where I can write out a blog post and submit it to a seperate php page that then stores it in a database (after it confirms it is me posting) where it will be read from and displayed on the home page. How can I easily escape any quotes or anything that will inte...

MySQL INSERT INTO ... SELECT #1054 ERROR

Can anybody please help.. SELECT on its own works INSERT on its own with VALUES works also. note: products_similar has 2 columns VARCHARS get_cheaper() - stored routine returning VARCHAR I never ever had problems with INSERT INTO ... SELECT. But when I combine them I get error below: SQL query: Documentation INSERT INTO `produ...

PHP Variable Passing not working in database call.

This works. function get_distinct_size_for_bracelets() { $sql = "SELECT DISTINCT size FROM mytable WHERE id = 27 AND type='plastic' ORDER BY size"; } This does not work and stops php dead with no error reporting. function get_distinct_size_for_bracelets($myvalue) { $sql = "SELECT DISTINCT size FROM mytable WHERE id = 27 AND ...

MySqlHelper class + asp.net

Hai Guys, Like DataAccessApplicationBlock for .net with sql server,Is there any thing for MySql with .net... If so please let me know.... ...

Django admin crashes after Save and Continue redirects to None instead of id of the primary key. Help?

I installed Django for the first time yesterday and trying it out in earnest today. I'm only planning to use it for the beautiful admin interface, Zend Framework for the rest. I imported an existing table event into the admin. There's no join needed. But the primary key is not 'id' it's called "event" (following this naming convention)....

Retrieving values from several tables in a MySQL database

Hello, I have a MySQL database called "bookfeather" with several tables that contain list books. Under each table, each book has a given number of votes. The PHP code below allows the user to enter in a book title ($entry), and then returns the total number of votes that book has in all tables ($sum). How could I use PHP to make a 2-...

Connecting through MySQL socket with Zend Framework

I have recently started using Zend Framework. I started developing on my local XAMPP server which went fine but when I uploaded to my 1and1 account, I keep getting the following error: Message: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) I have tried changing the...

Need help with mysql/php outputting data

Okay, so, I have a list table with 2 columns: codes and dates. I want to display the LATEST 25 AND tell the user how long ago they were submitted. So, for example: ABCDEF (1 Second Ago) CCDEE (12 Seconds Ago) 329492 (45 Minutes Ago) I've gotten this far: $result = mysql_query("SELECT `code` FROM `fc` ORDER by datetime LIMIT 25") or...

What is a good way to handle returned data from MySQL and C# ?

Just a quick questions, since most blogs and tutorials I found are about the very basic elements of MySQL and C#. I am using the MySQL ADO Connector. I have everything setup and I can retrieve data from the table. But I want to create a method that simplifies things for me. So I can set a query string (either in the method or the objec...

Stored function in MySQL doesn't like user supplied dates?

I have a stored function in MySQL: CREATE FUNCTION `login_count`(o INT, start_date DATE, end_date DATE) RETURNS INT READS SQL DATA BEGIN DECLARE total_count INT; SELECT COUNT(*) INTO total_count FROM logins as l WHERE `order_id` = o && modified BETWEEN start_date AND end_date; RETURN total_count; END Pretty basic, takes an id, start...

mysql query with group by and order by

I have a table like this: .--------------------------------. | Name | XX | Date | .--------------------------------. | N1 | 5 | 2009-05-01 | | N1 | 10 | 2008-01-08 | | N2 | 8 | 2009-02-02 | .________________________________. My result should be this: .------------. | Name | XX | .-------...

Outputting Time - a DateTime entry

Related: This is a continuation from my earlier question, Wrong Logic in If Statement? $repeat_times = mysql_real_escape_string($repeat_times); $result = mysql_query("SELECT `code`,`datetime` FROM `fc` ORDER by datetime desc LIMIT 25") or die(mysql_error()); $output .=""; $seconds = time() - strtotime($fetch_array["datetime"]); ...

Load only once the tables when you update their views in VS2005

I'm using two tables from a MySQL db (let's call them db1, db2) and I have to display different views for them that are linked with each other with nested relations (using VS2005 + ADO.NET Connector). What I have been doing till now was adding new table adapters for each different view, many of which contain a lot of IF statement and gen...

Wrong logic in If Statement?

$repeat_times = mysql_real_escape_string($repeat_times); $result = mysql_query("SELECT `code`,`datetime` FROM `fc` ORDER by datetime desc LIMIT 25") or die(mysql_error()); $output .=""; $seconds = time() - strtotime($fetch_array["datetime"]); if($seconds < 60) $interval = "$seconds seconds"; else if($seconds < 3600) $interval ...

Summing a field from all tables in a database

Hello, I have a MySQL database called "bookfeather." It contains 56 tables. Each table has the following structure: id site votes_up votes_down The value for "site" is a book title. The value for "votes_up" is an integer. Sometimes a unique value for "site" appears in more than one table. For each unique value "site" in the enti...

Is there an efficient and free method of migrating a 6GB Interbase DB to MySql?

That's about it. I can always just dump it to csv and read it in, but I was hoping to avoid that. ...

Allowing users to bump an input they submitted every hour?

So, I want people to be able to "bump" what they've wrote in my database but at the same time only allow the input to be in the table ONCE at a time. For Example: Jim's code is 5555. Jim enters his code and it shoots to the very bottom of the table. After 34 minutes he tries to enter his code in again (Because various other people h...

How can I ensure my user's data is valid in PHP and MySQL?

I have a web form that takes 2 string values and 2 integer values from a user and stores them in a database. How can I ensure that the ints are actually ints and sanitze input so that Bobby Tables doesn't pay me a visit? Here is my forms code: if(isset($_POST['submit'])) { $formTitle = $_POST['title']; $formAuthor = $_POST['au...