title: Comparing data types between MySQL and PHP
body: <p>For example:
  I have variable $name and I like to save it to my database to table $table and column name. But before I want to vefiry that it has the same data type as the database column (for varchar, char, text, ... it must be string). </p>
  
  <p>How can I do this?</p>
  
  <p>To select MySQL data type:</p>
  
  <pre><code>$query = mysql_query("SELECT data_type
                 FROM information_schema.columns
                 WHERE table_schema = '".$dbName."'
                 AND table_name = '".$table."'
                 AND column_name = '".$column."' ");
  </code></pre>
  
  <p>Getting PHP type:</p>
  
  <pre><code> gettype($variable);
  </code></pre>
  
  <p>But how can I compare the data types (varchar, char, text to string)?</p>
  
  <p>Thank you very much!</p>