title: Get Results from mySQL in PHP
body: <p>I am trying to get result from as table in mySQL in the following code.
  It does not work. I am newbie in PHP.</p>
  
  <p>Maybe someone can help whatws wrong in my code? I think that my SQL sentence is not written well. Is it?</p>
  
  <pre><code>&lt;?php 
  
  header("Content-type: text/html; charset=utf8");
  
  // header('Content-Type:text/html;charset=utf-8');
  
  //1. create connection
  
  $connection=mysql_connect("localhost","user","pass");
  
  if(!$connection){
      die("database connection failed:" . mysql_error());
  }
  
  //2. select database 
  
  $db = mysql_select_db("database",$connection);
  
  if(!db) {
      die("database connection failed:" . mysql_error());
  }
  
  //if i want to work with hebrew databases
  
  mysql_query("SET NAMES 'utf8'",$connection); // reading heberer from phpadmin database - only for hebrew sites 
  
  $MessageNo = $_POST['MsgNo']
  
  //$MessageN0=(int)$MessageNo
  
  $query = mysql_query("SELECT * FROM MessageContent WHERE MsgNo='$MessageNo'");;;
  
  $messages = array();
  
  while ($row = mysql_fetch_array($query)) {
      $messages[] = array('MsgContId' =&gt; $row['MsgContId'], 'MsgNo' =&gt; $row['MsgNo'],'MsgContent' =&gt; $row['MsgContent'], 'AddedBy' =&gt; $row['AddedBy'],'AddedAt'=&gt;$row['AddedAt']);
  }
  
  // echo json_encode(array('users' =&gt; $users));
  
  echo json_encode($messages);
  
  mysql_close($connection);
  
  ?&gt;
  </code></pre>