mysql

InnoDB - Two foreign keys on the same column from one table

Hey Guys, i have a project table which has a image_id field and a newsimage_id field. Both are linked to the image table. But InnoDB doesn't allow me to set a foreign key for both fields to the same column (id). Is there a way I can do this or is it not possible? I'm using MySQL through MAMP. Thanks in advance!! ...

How do you query a MySQL table columns highest entry and store it in a variable.

How do you query a MySQL table columns highest entry and store it in a variable. Here is what I have but it is not working. $query = "SELECT MAX(date) FROM Records WHERE ips='$currentip'"; $result = mysql_query($query) or die(mysql_error()); echo $result; Update: <?php $db = mysql_connect("localhost", "123", "123"); mysql_select_db(...

Is this possible with sql?

Is it possible to do something like this: INSERT INTO table(col1, col2) VALUES(something_from_another_table, value); With something_from_another_table being a SQL command? Like, is there something I can do that's equivelant to: INSERT INTO table(col1, col2) VALUES((SELECT value FROM table2 WHERE id = 3), value); ...

Indexing large DB's with Lucene/PHP

Afternoon chaps, Trying to index a 1.7million row table with the Zend port of Lucene. On small tests of a few thousand rows its worked perfectly, but as soon as I try and up the rows to a few tens of thousands, it times out. Obviously, I could increase the time php allows the script to run, but seeing as 360 seconds gets me ~10,000 row...

jquery div container that updates from mysql every 5 min

Can anyone please tell me how to write a small div container in HTML that refreshes its contents from the data in mysql every 5 min. This is similar to twitter updates in some webpages which show updates as and when tweeted. Thanks. ...

Data denormalization and C# objects DB serialization

I'm using a DB table with various different entities. This means that I can't have an arbitrary number of fields in it to save all kinds of different entities. I want instead save just the most important fields (dates, reference IDs - kind of foreign key to various other tables, most important text fields etc.) and an additional text fie...

MySQL Full-text Search Workaround for innoDB tables

I'm designing an internal web application that uses MySQL as its backend database. The integrity of the data is crucial, so I am using the innoDB engine for its foreign key constraint features. I want to do a full-text search of one type of records, and that is not supported natively with innoDB tables. I'm not willing to move to MyISA...

Mysql error in php code

Hello, can't understand mysql error: UPDATE static_pages SET order = " Some new data 222222 "Database error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order = " $query = 'UPDATE someTable SET '.$key.' = "'.$value.'"'; Here ...

Mysql locale session variable ?

Hunting internationalization bugs here. Does mysql has a variable which can be set per session, meaning the each connection will know the timezone of it's client and will act upon that. If such variable does exists I would expect sql statements such as the following will return diffect values, based on connection session locale. selec...

Syntax Error with MySql Workbench and IF Statement

Hey guys, Im migrating from T-SQL to MySql syntax and don't know how to get over this syntax error given by Workbench 5.1.18: -- -------------------------------------------------------------------------------- -- Routine DDL -- -------------------------------------------------------------------------------- DELIMITER // CREATE PROCEDUR...

MySQL - connection and security

Hi, I was wondering if someone could tell me if there is any potential security breeches that could occur by connecting to a sql database that does not reside at 'localhost' i.e. via ip address? Regards, Phil ...

Bad practice to mirror MySQL tables?

Is it bad practice to create a mirrored table (MyISAM) of the records in an InnoDB table for the purposes of doing full-text searches? I figure this way I'm just searching a copy of the data and if anything happens to that data it's not as big of a deal because it can always be re-created. But, it just feels awkward. (MyISAM is the onl...

Serialize checkbox array, also get checkboxes with off-value

Hi, I was wondering if this is possible. The serialize-string will be inserted in a mySQL-database, so it would be fine if all checkboxes would be inserted and not only the ones that is ticked(on). it's possible to make on column in the database for each of the checkboxes, and use this if/else-statement: if(isset($_GET['checkbox'])) {...

Client to access and edit a MySQL database remotely

Hey guys, So I have been given the host, username, and login information for a MySQL Database. I need a client that I can use to log in to the Database remotely and create/update tables and edit all the data. I found the MySQL Administrator client provided by them, but it seems you can do everything BUT edit the actual data with it. I...

Print results of a SELECT query as preformatted text in PHP?

I'm looking for an easy and quick way to print out the results of a MySQL SELECT query in PHP as preformatted text. What I would like is to be able to pass a query object to a function and get a printout of the recordset like the command line MySQL client does when running SELECT statements. Here is an example of how I want it to look ...

sending +-200 emails using php mail() function in a loop

Note: It is worth noting that the mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient. Source: PHP manual What are larger volumes? A 100 or a 1000?? Can I safely make it loop 200 times without much problems? (I ...

(php) date and time

(php) how to get date and time into one string ($moment) and if it works, can mysql do this: SELECT * FROM table ORDER BY moment ASC ? ...

How to limit a users uploaded image size using PHP

I was wondering how would you limit an uploaded image size to 5mb using PHP & MySQL. ...

Insert the lowest possible unique positve integer in an atomic fashion in MySql

Say I have a table with a unique positive integer field. I currently have rows with id's of [1, 2, 3, 4, 5, 8, 12, 35]. Is there a insert query that I could write that would assign the id field to the lowest unique positive integer (in this case 6)? It would have to do this atomically so there isn't the possibility of concurrent inserts ...

Joining two similar tables in MySQL

Hello, I have two tables with similar columns - let's say table A with column LABEL_A and table B with column LABEL_B. The data types of LABEL_A and LABEL_B are same. How can I select LABELs from both tables in a single query? (So the the result of the query contains single column LABEL containing data from LABEL columns of both tables...