mysql

XML Error: Only one top level element is allowed...

Hello, I recieve XML error: "Only one top level element is allowed in an XML document." when I try to run my sitemap script in PHP: $num_rows = mysql_num_rows(mysql_query("SELECT * FROM pages_content WHERE date < CURRENT_TIMESTAMP")); $result = mysql_query("SELECT * FROM pages_content WHERE date < CURRENT_TIMESTAMP ORDER BY id DESC")...

Is there an optimal number of records OR data size I can insert in one request?

Using the Mysql multi insert statement (Inserting several records in one INSERT statement). Is there an optimal number for the number of records I can insert in one go, Or to the data size (bytes)? ...

mysql remote connection issues ? How to connect using php?

hi, I am trying to connect remote mysql i am having typical issue. $conn = mysql_connect('xxx.xxx.xxx.xxx', 'username', 'password') or die(mysql_error()); Let my system host name is my.host.com and remote one is remote.host.com I tryed using both IP xxx.xxx.xxx.xxx and remote.host.com it is saying that Access denied for user 'usern...

MySQL query with equality and please all results...

Hello, I am quite new to MySQL and it is great in reducing data through queries. However, it seems to be hard to get both records, if you want records containing duplicates. The table looks like: ID Value more columns.. 1 4 1 4 1 5 2 4 3 5 3 5 4 4 4 5 I want both(!) records with duplicate values, li...

Count posts with php or store in database

Hi I have these tables: forum id name description posts id forumID body What I wonder is should I create a field in forum where i store the number of posts that been made in that forum? Update it every time someone makes a post. or should I count them with php? Is it a huge performance difference? ...

Should I always prefer MySQL InnoDB over MyISAM?

Someone just told me that InnoDB is much better than MyISAM. So when I create a table, should I always try to use InnoDB Engine instead of MyISAM? Or do both have it's big benefits? ...

Can I use InnoDB and MyISAM tables in ONE database?

Obviously both have their benefits. MyISAM is fast but may get currupted easily, InnoDB is slow but is more stable thanks to transactions and foreign keys. So it could be good to mix both engines in one database. If that's possible? ...

Getting the last 7 rows from MySQL in PHP

I'm trying to get the last 7 records from a table whose records were entered by the user Here is my query: $database->setQuery("SELECT * FROM #__mytable WHERE (user_id = '$uid')"); $dberr=""; if (!$database->query()) { $dberr = $database->getErrorMsg(); } if(!$dberr==""){ echo($dberr."<br>"); }else{ $rows = $database->loadOb...

How much faster is MyISAM compared to InnoDB?

People say InnoDB is not so fast like MyISAM. But how much slower? Just as a rule of thumb in the wind, of course. I mean... is it usually 0.5x as fast as MyISAM? or even worse? Or does the average visitor not recognize any temporal difference when surfing an MyISAM platform vs. same thing with InnoDB? ...

logging failed queries

I can log all the mysql queries by enabling the general log. But it does not show the failed queries. Is there a way to save failed queries as well? ...

How to select from joined MySQL tables?

I basically have two tables: A(id int, name varchar(10), info varchar(10)) B(id int, item varchar(10)) A 1 A Hello 2 B World 3 C Foo B 1 apple 1 orange 1 hammer 2 glass 2 cup Using the following query... mysql> SELECT a.id, a.name, a.info, group_concat(b.item SEPARATOR ' ') FROM a LEFT OUTER JOIN b ON (a.id=b.id) ...

I am confused with join.

I have two tables, omc_categories and omc_products. I want to pull out categories name where omc_proudcts.category_id is equal to omc_categories.id. I created the following sql but I am not sure which is right one. SELECT C.Name AS CatName FROM omc_categories AS C LEFT JOIN omc_products AS P ON C.id = P.category_id WHERE...

mySQL error when inserting too long varchar, when was it introduced?

There was a version jump in mySQL, I don't know whether it was from 4 from 5 or a number within 4.x, that the default behaviour when dealing with too long input was changed. Before, strings that didn't fit into their varchar column they were silently cut off. After, an error was raised. I'm having a hard time finding anything in the doc...

Store html entities in database? Or convert when retrieved?

Quick question, is it a better idea to call htmlentities() (or htmlspecialchars()) before or after inserting data into the database? Before: The new longer string will cause me to have to change the database to hold longer values in the field. (maxlength="800" could change to a 804 char string) After: This will require a lot more serve...

How to handle mass email

Hi there, I'm about ready to unveil a "coming soon" page and one thing I need is a way for users to enter their email address for me to email once the site goes live. What is the best way to do this? Should I store the emails in a DB and then run a PHP script to email them from my web host? Should I have the emails just kind of be coll...

MySQL Benchmark

Hi Everyone, I am trying to use MySQL benchmark to test some queries. But, I am running to an error. SELECT benchmark (10000, (select title from user)); and in return I get this error; ERROR 1242 (21000): Subquery returns more than 1 row Does anyone know how to benchmark a query? Thanks ...

ST_Buffer equivalent for Circle based searches in MySQL?

I need to search for a row with a point that is within a specified circle using MySQL GIS. Pseudocode example query is: select * from gistable g where isInCircle(g.point, circleCenterPT, radius) It appears that PostGIS can do this via the ST_Buffer function. Does MySQL GIS offer similar functionality? ...

Google-like search functions

I asked this question about a year ago on another site but never got the answers I was looking for. And I've been wondering about it ever since. I'd like to impliment some search functions similar to Google's (inurl:foo, site:bar.com) So if you entered a normal query, with none of these functions included, it would search one column. ...

Optimizing my mysql query to use index for sorting

Dears, I need your help to optimize the query below. Let us assume we have a web application for articles. The software use two table;one is the article table and the second one is the users table. The article table hold the date when the article is created,the id,the body,the title & the section. Let us assume that we have one section ...

How can I have a primary key in a VIEW (a key that doesn't depend on source tables)

Hello. I'm creating a VIEW out of 3 TABLES. Each TABLE has it's primary key. However, in the VIEW in order to have a primary key, I'll have to use a composite primary key (combination of primary keys of 3 TABLES). I would however like to add a column in the VIEW as a primary key that is created just for the purpose of the VIEW. As par...