mysql

How to insert new auto increment ID

Hi - I found the mysql_insert_id function to retrieve the last auto generated ID. Should I be using mysql_insert_id +1 to add a new ID or is there a call for adding a new unique ID? ...

In Ruby on Rails, how to create a record with ID 3 when it was destroyed earlier?

I am trying an experimental Rails project and destroyed record 3 (ID == 3), so now there is record 1, 2, 4, and 5. Is there a way to repopulate this table with record ID from 1 to 5? (this is using mysql) I can use if Item.exists?(i) item = Item.find(i) else item = Item.new end # set some values item.name = "haha" + i item.save...

How do mysql indexes work?

I am really interested on how mysql indexes work that it could not scan the whole table to give us results? It's off-topic, I know, but if there is someone who could explain me that picturesquely I would be very very thankful. Thanks. ...

Are there any tools for automatically moving from testing to production servers?

Are there any tools for automatically moving code from testing to (stage and then to) production? We are running on a LAMP stack and don't want to rely on FTP access? Other than that, is there some BASH or PERL script out there for this same process? Our production servers cannot run SVN or HG which we use for development. ...

How to create a form for clients to deliver files?

It's common that clients have lots of difficulty (and take a long time) to provide their files. Delivering files seems so simple, but it usually adds a bottle neck to any project. As a solution for this... My goal is to make a form that client's can use to deliver all the files needed to build their website, such as: Excel Spreadshee...

MySQL: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource

Hi, I have this bug: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/marlon/domains/webmasterplaats.nl/public_html/edit.php on line 36 This is the code: <?php $ip = $_SERVER['REMOTE_ADDR']; $toegang[] = '86.91.195.26'; $toegang[] = '84.86.189.70'; $valid = true; if(in_ar...

Selecting Sets of Contiguous Events in SQL

Okay so right now I'm working on a program that has a whole bunch of event objects. Each event object has a start time and end time (both full timestamps). A lot of the events are contiguous (one event's endTime is the same as the next event's startTime) showing that the two events happened in succession. If I were to store all my events...

execute one mysql querry on multiple databases

Hi, I have a simple question that keeps me up all night :( . Suppose we have 2 databases on different servers. You can easily create 2 connections and manipulate data in both databases. What if I want to execute one query on both databases? Example : INSERT INTO database1.table1 VALUES ( 'one','two','three') WHERE database1.table1....

Trying to echo a simple money math statement that adds $5 value to every recordset that = "30"?

I have a database/store and here is my simple query : $query_Recordset1 = "SELECT * FROM orders WHERE products = 30"; Now, we want LIVE results of how much total money we donate when people by this product. This product is around $30 dollars (which is irrelevant) but we donate $5 for every purchase to a certain cause and would like to...

How to optimize this low-performance MySQL query?

Hi there, I’m currently using the following query for jsPerf. In the likely case you don’t know jsPerf — there are two tables: pages containing the test cases / revisions, and tests containing the code snippets for the tests inside the test cases. There are currently 937 records in pages and 3817 records in tests. As you can see, it t...

How to create a trigger with multiple actions in MySQL 5.0.45?

I'm working in phpMyAdmin and I'm new to creating MySQL 5.0.45 triggers. I'm trying to create a trigger that will help me validate data by throwing an error when a value it out of range. This works just fine: create trigger t1 before insert on hvi for each row begin declare dummy int; if new.`Moist (dry%)` <1 then select `Moist(dry%) c...

mysql_result() error happening all of a sudden

I recently rebuilt my website and now I'm getting this error: Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/xx/public_html/asdf.com/comsel.php on line 28 Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/xx/public_html/asdf.com/comsel.php on line 29 Warn...

Difference between php timestamp? Or mysql timestamp?

I have two timestamps recorded on a mysql table using php. How can I calculate the difference between these timestamps in hours using php or mysql? ...

Adding a new SQL column with a default value

I am looking for the syntax to add a column to a MYSQL database with a default of 0 and for the life of me i have no idea how to read this Reference ...

How to unset BLOB with php/mysql?

Cuz, I did it unintentionally. After reading wikipedia I understand the "binary large object" is for large media files, and I'm not saving a media file. So how does data get stored this way? What's wrong with this setup to display text as BLOB in phpmyadmin? the MySql field from phpmyadmin, Field = 'first_name' Type = text Collation...

Solution for creating dynamic forms

I'm having some trouble deciding which approach I should take. I want to allow users to create their own html forms by choosing different form elements (textfields, textareas, lists, ratios, etc) I guess something similar to http://wufoo.com/ but much more basic. Should I use database tables or create files? For tables I was thinking to...

Zend Framework: Meta attributes (keywords/description) from database

Hey, I am creating websites via Zend Framework and I've been wondering about this for quite some time now... Imagine that you have created the best articles module and you usually add meta_keywords/meta_description database entries per article, so that when the view renders it populates the meta fields in question with the data entere...

jQuery sortables and how to save the current sorting to mysql

Example I want use this sortables - http://interface.eyecon.ro/demos/sort.html How to save the current layout setting to MySQL? Any clue? ...

concatenate two fields in different tables with mysql ?

It can be concatenate fields in a table. But I want to know if you can concatenate two fields where "a" is in categories table and the "other" is in the products table, bone in different tables with mysql. ...

Is it possible to stem full text match queries in MySql

I'm trying to use wildcards to pass a stem of a word as part of a full text search in MySql. I would prefer to use match...against for the performance benefit instead of a like query. I found this post which makes it sound as though this can be done: http://stackoverflow.com/questions/2062101/mysql-fulltext-with-stems ...but I can't g...