mysql

mysql_num_rows give unexpected result

Hi, I've got the following function: public function already_tweeted($tweet){ return mysql_num_rows(mysql_query("SELECT * FROM `retweeted` WHERE `tweet`='$tweet'")); } Pretty straightforward. It checks whether a tweet already exists in the database. The table had the following records: id user tweet 3 You shou...

InnoDB row size large as compared to MyIsam

I have a table with for columns, a smallint, an integer and two floats. Expected memory for each row is 14bytes (2+4+2*4). I have around 700,000 rows in my table. I've set no primary keys and indices. While the MyIsam type takes around 10MB (average of 15b for each row), the InnoDB type takes more than 30Mb (average of 44b). What am...

Show Authors and excerpt of their last post in a list

Hi All, I've search everywhere but haven't found what I'mlooking for even though I'm convinced there must be a solution floating around since it's obviously such a common request: I want to display a list of authors with a short excerpt of their latest post. I have a list of Authors with their images (using the 'Author Avatars List') ...

How to find similar stories based on keyword matching?

I have a table, story_keywords which contain keywords matched up to a specific story with the following columns: id, story_id, keyword_id. Now what I want to do is grab any story that shares at least two keywords with the primary story I'm outputting from the initial loop of getting all stories for today. // get list of keyword_...

Show SQL script using graphviz

I am looking for software can show SQL scripts (MySQL in my case) in visual way. Example every script is a circle in the diagram. Similar to doxygen but for SQL scripts. ...

Why does Hibernate re-implement functionality that databases already have?

For example: @Table(name = "stock", catalog = "mkyong", uniqueConstraints = { @UniqueConstraint(columnNames = "STOCK_NAME"), @UniqueConstraint(columnNames = "STOCK_CODE") }) or @Column(name = "STOCK_NAME", unique = true, nullable = false, length = 20) Constraints like 'unique', 'nullable', even field length are core database featu...

Accidentally inserted a string into a big int column. Is there any chance of recovering the string?

When parsing and inserting data, I accidentally inserted a string (ip address) into a bigint column in a MySQL table without using the INET_ATON function. Is there any way I can recover the original string? ...

PHP: mysql return value "escapes" textarea

If the return value of a mysql query contains "" and / the content is displayed outside the textarea content = <a href="url">link</a> echo() is used inside the textarea <textarea><?php echo $row['value']; ?></textarea> the textarea displays <a href= and what follows it is displayed outside the textarea How do I contain all html in...

Easiest way for php email verification link.

I already have an advance user login/register system on my website (colemansystems.psm2.co.uk). However, I would like to have a email sent to new users for verification of their email address. If they have not clicked the link they will not be able to access their account. I am semi-experienced with PHP & MySQL, so please explain in dept...

Mysql. Order locations and join listings randomly

I have two tables: locations and listings. locations id title address latitude longitude listings id location info status SELECT locations.title, locations.address, ( 3959 * acos( cos( radians('".$center_lat."') ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians('".$center_lng."') ) + sin( radians...

MySql Join with Sum

Hello, I have a table called RESULTS with this structure : resultid,winner,type And a table called TICKETS with this structure : resultid,ticketid,bet,sum_won,status And I want to show each row from table RESULTS and for each result I want to calculate the totalBet and Sum_won using the values from table TICKETS I tried to make some...

how to get mysql ranking among results with same id

Quick question, I have a table of messages each with a timestamp and a reply_id and a topic_id. Reply_ids can be the same as others, which means those messages are in the same group of replies. When I select a reply_id with the min timestamp, meaning it was the first message of that group, I would also like to know its numbered place wit...

multiple MySQL queries across a web page layout - best way to go about it?

basically i'd like to know if it's preferable to establish a database connection before each database query, and then use mysqli_close() immediately after the relevant section, for every spot in the layout where database information has to be pulled - or if it's better to just open the database connection at the start of the file, and th...

Ruby on Rails, MySQL and Snow Leopard

I have working fine my installation of Ruby on Rails on my Snow Leopard. I've tried for several days install MySQL with Ruby on Rails, all I've got when I run: rake db:create is: (in /Users/naikon/RoR/test2) dyld: lazy symbol binding failed: Symbol not found: _mysql_init Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.4/ex...

MySQL table caching returns stale data

I have query caching disabled (it's disabled by default on my installation) but kept getting outdated data in my application. For example, I would do a SELECT * on my review table, insert a new row and then do another SELECT *, but the new review wouldn't show up (although it would be there if I browsed to the table in phpMyAdmin). I dis...

Codepage related problems with MySQL++

Code: mysqlpp::Query acc_query = connection->query("SELECT * FROM accounts;"); The following code produces: _Gfirst = 0x00c67718 "SELECT * FROM accounts;ээээ««««««««юоюою" As in Visual Studio debugger. It appears to cause my query to fail with weird results. Has anyone else encountered it? ...

How can I load an .xls file to a mysql database in php?

I want the exact opposite of this. I want to load a .xls file full of emails into a database column. What's the simplest way to do this? ...

Porting SQL results into memcached

I have few tables which are accessed frequently by users. The same kind of queries are running again and again which cause extra load on the server. The records do not insert/update frequently, I was thinking to cache the IDs into memcached and then fetch them from database this will reduce the burden of searching/sorting etc. Here is ...

mysql / file hash question

Hi, I'd like to write a script that traverses a file tree, calculates a hash for each file, and inserts the hash into an SQL table together with the file path, such that I can then query and search for files that are identical. What would be the recommended hash function or command like tool to create hashes that are extremely unlikely ...

PHP - PDO mysql backup to remote host?

Welcome, How can i create a full backup of my database (all tables inside) to remote mysql server using PHP PDO ? Is there any easy way ? ...