mysql

SQL not updating multiple databases...whats wrong with my sql?

I'm trying to run one SQL command to update multiple databases. If I copy 'n paste sql code below directly into PHPMYADMIN it executes just fine, but when I run the sql through php it doesn't update? If I run the updates for each database separately via my php script they both update fine, so I'm confused? What am I doing wrong? SQ...

JOINS in MYSQL and missing rows

I have a query like this one : SELECT DISTINCT `a`.*, `b`.*, `c`.* FROM `a` INNER JOIN `b` ON (`b`.`a_id` = `a`.`id` ) INNER JOIN `c` ON (`c`.`id` = `b`.`c_id`) WHERE ( (`a`.`id` = 12345) AND (`b`.`foo`= "bar") ) Basically, this takes the row from a with id=12345, and the rows from b that ...

Add 6 hours to now() function

Hello, I dont know if this is possible. I have researched it and cant find anything. I want to add 6 hours onto the value now() will return. At the moment it comes back in a datetime format in the database. Is there another function where i can add 6 hours onto the current time? Thankyou ...

Problem looping through usernames

I am trying to loop through an array of usernames and for each username, execute a mysql_query on each. <?php for ($i = 0; $i < count($u); $i++) { $j = $i + 1; $s = $database->checkUserPlayedRecent($u); if (mysql_num_rows($s)...

Sort mySQL table's fields

So lets say I have a table (lets say 50 rows, 50 columns) that I occasionally have to make tiny edits to. While I realize I could be (maybe some of you will tell me I should be) using the query to do this, I like using a database management program (like Sequel Pro) to make changes by hand. So I have two questions: When you do a query ...

MySQL (MyISAM) - update field to greatest of two fields from different tables

I have two tables, t1 and t2 with two columns each - id_user and age. How do I update t1.age to the greatest of t1.age and t2.age for matching ID's and leave t1.age unchanged if there is no matching ID in t2. Before update: t1 +-------+---+ |id_user|age| +-------+---+ | 1| 5| +-------+---+ | 2| 10| +-----...

How should I handle when a friend ignores someone in a PHP/MySQL app?

I have a table like friends(friendship_id, fid1, fid2, ENUM('pending', 'accepted', 'ignored'). When a user ignores someone's friend request, I want to make sure that they don't get a message saying, "You've been ignored!", but I also want that data logged. Any suggestions on how to approach this? ...

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

Happy Friday All, I'm working on a custom CMS, made changes to the DB schema and presentation layer. I'm getting an error relative to mysql_num_fields and mysql_num_rows using the following section of code. Can someone give me an idea of why these errors are being raised? Thanks, Sid public function viewTableData($db_name,$table_nam...

Most affordable, portable, battery-powered hardware for running a LAMP setup for development?

I will be flying to Australia (~15 hr. flight) and I'd like to continue work on my current project while on the airplane. My project (website on CakePHP framework) requires a LAMP bundle so I'm looking for a very portable, reasonably affordable device that can accommodate a LAMP installation, and also could retain battery life througho...

Sending Email to Multiple Recipients from MySql Recordset

I want to send an email to multiple recipients using PHP mail() function. The email message is simply a reminder that a membership is due to expire so email addresses will come from MySql database query. There would anywhere from 2-10 at any given time. I found the following code but it generate errors. The problem is not with my que...

MySQL Keyword Search Across Multiple Tables

I have three tables in a MySQL database used in a music library application: The Genre table has columns: id title (string) The Album table has columns: id genre_id (foreign key to Genre.id) title (string) artist (string) and the Track table has columns: id album_id (foreign key to Album.id) title (string) Each Album can hav...

Sql where id = total ids

Hello.. Is it possible to execute a select query where the id column is within the last 50 rows? So like WHERE id > total id - 50. Something like that? Not sure of the syntax! Cheers ...

MySQL syntax problem in "SELECT * FROM INTO FILE"

I'm trying to move tables between two databases and I'm using this command that is given by MySQL : SELECT * INTO OUTFILE '/tmp/result.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM test_table; As it is written in the MySQL Dev Manual. I'm using MySQL 5.1. Error : Error Code:...

Upgrading Wampserver

Hi, I looked for a specific answer to this question, but couldn't find it -- even on the WAMPSERVER site. I'm sure I overlooked it. I have Wampserver 2.0, with MySQL 5.0.51b, PHP 5.2.6, and Apache 2.2.8. Would it be correct to install Wampserver 2.0i (MySQL 5.1.36, PHP 5.3, and Apache 2.2.11) over the older installation? Would I los...

How do I set the first entry of a combo box to empty? PHP/MySQL

My code is retrieving player names from a database and outputting them into a combo box. However I want the first entry of the combo box to be empty, how can I achieve this? If it helps, here is my code. Please note I only have 1 option box code in HTML as I'm editing phpBB. The <-- BEGIN clubplayer --> is a loop. ...

MySQL - Check if a string contains numbers

Hello, how do I check if a string in a MySQL field contains a number then delete them? Example table: tbl_tags ------------- | id | tag | ------------- | 1 | hello | | 2 | hello2 | | 3 | 2hello | | 4 | hel3lo | ------------- The only way I can think of is to do each number individually and use LIKE '%1%' OR LIKE '%2%' etc....

Concatenated range descriptions in MySQL

I have data in a table looking like this: +---+----+ | a | b | +---+----+ | a | 1 | | a | 2 | | a | 4 | | a | 5 | | b | 1 | | b | 3 | | b | 5 | | c | 5 | | c | 4 | | c | 3 | | c | 2 | | c | 1 | +---+----+ I'd like to produce a SQL query which outputs data like this: +---+-----------+ | a | 1-2, 4-5 | | b | 1,3,5 | |...

syntax error 'select a,b,c,d,e,f from'

INSERT INTO abc VALUES ( a, b, c, d, e, f ) SELECT a, b, c, d, e,f FROM bcd when i execute this iam getting synatx errors .how do i get rid of the synatx error ...

cant figure this error out

Can you guys see any obvious error in this query? The error im getting is: `Unknown column 003ADF50 in field list. 003ADF50 wtf? query << "UPDATE `record` SET `record` = " << lastRecord << ", `time` = " << time; ...

Catalyst create schema can't connect but I can

So I can connect with (obviously I replaced all the real values) mysql -u username -p -h db.dbhostname.com dbname But when I run Catalyt's create script I get ./script/dasgift_create.pl model DB DBIC::Schema MyApp::Schema create=static components=TimeStamp dbi:mysql:dbname:db.dbhostname.com username p@55w0rd DBIx::Class::Schema::Load...