Failure to write to SQL

When I send a query statement with mysql_query(), I get the following error.
To my surprise, the number of digits in the room_id was limited to 30 characters in the database.
The characters you are trying to include are 40 characters, so the room_id does not match the room_id error! Fix character limit.

Still, it's important to make errors appear this way.
$result=mysql_query($sql)or die("query failed".mysql_error());

bool(true) query failed You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE room_id = f2ae6f83b81ac0ed3d0102717fd738c47ad912ab' at line 1
Other things like. Forgetting to remove the
http://d.hatena.ne.jp/rockstar2007/20081113/1226590064

moreover
Unknown column 'where clause'.
The solution was here:http://blog.v7a.net/archives/453
This place was different:http://colo-ri.jp/develop/2009/09/mysql5unknown_column_in_on_clause.html