mysql

How to check if mysql entry is empty in PhP?

Hello, here is the description variable I am echoing from my table: $description = mysql_result($result,$i,"description"); sometimes the $i'th record is empty and doesn't have any data in it/no description. What I want to do is echo "No description available" for records that are empty if (isset($description)){ echo "No description ...

MySQL - Create an UNIQUE index on two columns for ON DUPLICATE KEY

I have a table with 4 columns. I want to be able to INSERT or UPDATE the value column on creation (I don't care about indexes row ID's). CREAT TABLE tablename ( id, (primary) user_id, (index) setting_id, (index) value (index) ); Originally I was going to run a "REPLACE INTO..." query each time I wanted to save a value. But then...

Google web toolkit doesn't work with CachedRowSet

I'm trying to creating a web app using GWT. In my application, I use MySQL as database. I tried to use a connection pool to control the number of connections to the database. However, Google web toolkit doesn't support CachedRowSet, which prevent me from closing the connections. Does any one know a walk around for this? (except making a ...

GROUP BY behavior when no aggregate functions are present in the SELECT clause

I have a table emp with following structure and data: name dept salary ----- ----- ----- jack a 2 jill a 1 tom b 2 fred b 1 When I execute the following SQL: SELECT * FROM emp GROUP BY dept I get the following result: name dept salary ----- ----- ----- jill a 1 fred b ...

Macports mysql5 setup under Snow Leopard

I've managed to get my install all screwed up as I'm a newbie and messing up is what I'm good at. 1) Can anyone reference a credible set of setup instructions for this stuff? 2) Can I just uninstall and start from scratch (passwords and all) through macports? I tried and a bunch of mysql directories stuck around after the unistall, WTF...

PHP PDO Prepared Insert Query. Problem with value not being passed.

I am using PDO to do prepared queries in php with MySQL. The query executes with no errors but one parameter does not pass it's value properly. It come sup as a blank field, but not NULL. It's really weird as it seems that I entered the code the same as the others which of course work fine. Really frustrating. $f_name = $_POST['f_name']...

MySQL Migration Script Help

I am working on a site that lists a directory of various restaurants, and currently in the process of switching to a newer CMS. The problem I have is that both CMSes represent the restaurant data differently. Old CMS A Cross Reference Database so it may list an entry for an example like this: ID / FieldID / ItemID / data 3 / 1 / 6 / ...

StackOverflow's Popularity algorithm in MySQL

How would you write SO's Popularity algorithm in MySQL? The algorithm is detailed here: http://stackoverflow.com/questions/32397/popularity-algorithm. thanks! ...

DATE_ADD problem

Hi I am working to add 1 month to date() and save it in my field on database. I use this $query2 = "SELECT * ,DATE_ADD(`date_joined`,INTERVAL 30 DAY) AS expire FROM `set` WHERE ID='$idno'"; $result2 = mysql_query($query2); "expire" is the field i want to save as +30 days. date_joined is current date. but it doesn't work. expire ...

mysql performance

I'm testing MySQL as a replacement for SQL server and I'm running into something really strange. I'm testing both inserts and reads, and maxing out around 50 queries per second either way. My test table looks like: DROP TABLE IF EXISTS `webanalytics`.`test`; CREATE TABLE `webanalytics`.`test` ( `id` int(10) unsigned NOT NULL AUTO_...

How to display multiple values in a MySQL database?

I was wondering how can you display multiple values in a database for example, lets say you have a user who will fill out a form that asks them to type in what types of foods they like for example cookies, candy, apples, bread and so on. How can I store it in the MySQL database under the same field called food? How will the field food ...

mysql gem install can't find ri/rdoc definitions OS X 10.6.1

I installed the ruby gem for mysql and it looks like it installed correctly except for the documentation. I reviewed http://www.rhinocerus.net/forum/lang-ruby/587057-gem-install-mysql-returns-list-no-definition-xyz.html but it didn't help. Some notes, I am running on a 32-bit intel processor. Mac os x 10.6.1 Mac-Shaun:usr shaun$ s...

CakePHP mathematic-calculation field?

(Database structure like http://stackoverflow.com/questions/1545764/cakephp-select-default-value-in-select-input) So, I have two tables in CakePHP: Trees, and Leafs. Every Leaf has a tree_id for its corresponding tree. Every leaf also has a numeric value. The default view that I baked for trees just lists all the trees in a table. I...

Counting rows in multiple tables

I have a mysql database that is tracking hockey stats. What I'd like to do is in one query get the number of goals and assists scored by each player as well as the number of games that they've played in. I'm using Zend Framework and the query that I've build is this: SELECT `p`.*, `pxt`.`jersey_number`, count(pxg.playe...

mysql Varchar size limit

Hi All, Can anyone provide me a quick input on how mysql treat varchar data type size. For Example: - If I have a column in table with field with Varchar(15) and if I try to insert data of length 16, then it gives an error stating "Data too long for column 'testname' at row 1". Does anyone know why varchar fields in mysql take fixed...

Storing multiple dynamic values within one field in mysql.

How can i go about storing multiple values ( numbers and words ) within one field of a mysql database and then extracting them again as and when i need them using mySQL and php? for example: I want to store the dynamic values a user will enter using a form for example 1, 2, foo, tree, and monkey all in the same field in a database. the...

Hibernate cannot recover after socket has timed out

I have an application that uses Hibernate to connect to my MySQL database. I'm just having a weird problem with timeouts. Let's say that the socket timeout in MySQL's configurations is set to one hour. After an hour of inactivity, the socket times out as expected. The problem is that Hibernate doesn't seem to be able to handle the socket...

How to display multiple values using php and mysql?

How can you display multiple values from the same mysql field using php and mysql Here is the code I have already <?php if(!empty($skill) || !empty($years) || !empty($rating)){ if (!empty($skill)) { echo '<p>' . $skill . '</p>'; } if (!empty($years)) { echo '<p>' . $years . '</p>'; } if (!empty($rating)) { echo '<p>' . $r...

How to strengthen Mysql database server Security?

If we were to use server1 for all files (file server), server2 for mysql database (database server). In order for websites in server1 to access to the database in server2, isn't it needed to connect to to ip address of second (mysql server) ? In this case, is remote mysql connection. However, I seen from some people comment on the se...

Performance with php and mysql

Hi, I'm developing a site and I have some doubts about the best approach to query the database. In general, when I load a page, several data has to be fetched from the database. I'm not sure if I'm doing it the best way. So right now and as an example I call the following functions when the page is rendered: (...) (a) -> getAuthorName(...