title: angle bracket mysql php
body: <p>I have troubles fetching data from a MySQL database when the text inside a VARCHAR field is surrounded by angle brackets ('&lt;' and '>' characters).</p>
  
  <p>Let me be more specific. This is the table from which I'm fetching data:</p>
  
  <pre>
  
      mysql> describe msgs;
      +---------------+---------------------+------+-----+---------+-------+
      | Field         | Type                | Null | Key | Default | Extra |
      +---------------+---------------------+------+-----+---------+-------+
      | partition_tag | int(11)             | NO   | PRI | 0       |       |
      | mail_id       | varbinary(16)       | NO   | PRI | NULL    |       |
      | secret_id     | varbinary(16)       | YES  |     |         |       |
      | am_id         | varchar(20)         | NO   |     | NULL    |       |
      | time_num      | int(10) unsigned    | NO   | MUL | NULL    |       |
      | time_iso      | char(16)            | NO   |     | NULL    |       |
      | sid           | bigint(20) unsigned | NO   | MUL | NULL    |       |
      | policy        | varchar(255)        | YES  |     |         |       |
      | client_addr   | varchar(255)        | YES  |     |         |       |
      | size          | int(10) unsigned    | NO   |     | NULL    |       |
      | originating   | char(1)             | NO   |     |         |       |
      | content       | char(1)             | YES  |     | NULL    |       |
      | quar_type     | char(1)             | YES  |     | NULL    |       |
      | quar_loc      | varbinary(255)      | YES  |     |         |       |
      | dsn_sent      | char(1)             | YES  |     | NULL    |       |
      | spam_level    | float               | YES  |     | NULL    |       |
      | message_id    | varchar(255)        | YES  | MUL |         |       |
      | from_addr     | varchar(255)        | YES  |     | NULL    |       |
      | subject       | varchar(255)        | YES  |     |         |       |
      | host          | varchar(255)        | NO   |     | NULL    |       |
      +---------------+---------------------+------+-----+---------+-------+
  
      mysql> select * from msgs LIMIT 1;
      +---------------+--------------+--------------+----------+------------+------------------+-----+--------+--------------+------+-------------+---------+-----------+--------------+----------+------------+-------------------------------+----------------------------------------+---------+--------------------+
      | partition_tag | mail_id      | secret_id    | am_id    | time_num   | time_iso         | sid | policy | client_addr  | size | originating | content | quar_type | quar_loc     | dsn_sent | spam_level | message_id                    | from_addr                              | subject | host               |
      +---------------+--------------+--------------+----------+------------+------------------+-----+--------+--------------+------+-------------+---------+-----------+--------------+----------+------------+-------------------------------+----------------------------------------+---------+--------------------+
      |             0 | 0qJcjCXZM8K3 | 7a8Q1_crCzuj | 02085-01 | 1365578237 | 20130410T071717Z |   4 | MYNETS | 172.31.255.5 | 1246 | Y           | V       | Q         | 0qJcjCXZM8K3 | N        |         -1 | &lt;51651189.9080705@test.it&gt;    | User Name &lt;test@test.it&gt;               |  test   |  localhost         |
      +---------------+--------------+--------------+----------+------------+------------------+-----+--------+--------------+------+-------------+---------+-----------+--------------+----------+------------+-------------------------------+----------------------------------------+---------+--------------------+
  
  </pre>
  
  <p>When executing a query via PHP MySQLi interface (eg: SELECT * from msgs), the from_addr field show only the first part (in this case "User Name") but <em>not</em> the text inside the angle brackets ("test@test.it", in this case).</p>
  
  <p>At the moment, I worked around it by using a REPLACE statement inside mysql query, substituting the angle brackets with square brackets. However, I would like to know how to correctly query text inside angle brackets.</p>
  
  <p>Thank you all.</p>