title: PHP not able to convert SQL result to string?
body: <pre><code>&lt;?php
  $q = intval($_GET['q']);
  
  $con = mysqli_connect('censored','censored','censored','db');
  if (!$con) {
      die('Could not connect: ' . mysqli_error($con));
  }
  
  mysqli_select_db($con,"db");
  $sql="SELECT message FROM messages WHERE code = '".$q."'";
  $result = mysqli_query($con,$sql);
  $resultstring = (string)$result;
  
  echo $resultstring;
  
  mysqli_close($con);
  ?&gt;
  </code></pre>
  
  <p>I am attempting to echo the result of the query to the user but when this PHP runs through ajax I get this error:</p>
  
  <blockquote>
    <p>Recoverable fatal error: Object of class mysqli_result could not be
    converted to string in D:\xampp\htdocs\getmessage.php on line 12</p>
  </blockquote>
  
  <p>Now I don't understand this because I am already converting $result into a string.. Thanks!</p>