0

I have moved my site from one server to another and since the move I am getting issues with drop down populated from MySQL database.

   <tr><td>IPad:</td>
  <?
  $sql="SELECT * FROM ipad_list order by asset asc";
  $result=mysql_query($sql);

  while (($row=mysql_fetch_array($result)) 
  {

    $id1=$row["asset"];
    $options1.="<OPTION VALUE=\"$id1\">".$id1.'</option>';
  }
  ?>
  <td>
  <SELECT NAME="asset">
  <OPTION VALUE="0">Choose One</option>
  <? echo $options1 ?>
  </td></tr>

And this is what is displayed...

".$id1."; }

The above is displayed not my populated drop down.

This works fine on my existing LAMP server but not on my new one. I am sure the php installations are of the same version so why when I have moved this does it not work.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Paul M
  • 21
  • 3
  • 1
    you don't have short open tags enabled, so your PHP code isn't being executed, and the raw PHP code is reaching your client. change to ` – Marc B Dec 04 '15 at 21:12
  • 1
    Please [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). [These extensions](http://php.net/manual/en/migration70.removed-exts-sapis.php) have been removed in PHP 7. Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [PDO](http://php.net/manual/en/pdo.prepared-statements.php) and [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) and consider using PDO, [it's really pretty easy](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Dec 04 '15 at 21:48

1 Answers1

0

You are not looping the results into select tag

 <SELECT NAME="asset">
  <OPTION VALUE="0">Choose One</option>
    <?php
      $sql="SELECT * FROM ipad_list order by asset asc";
      $result=mysql_query($sql);

      while (($row=mysql_fetch_array($result)) 
      {

       $id1=$row["asset"];
        echo "<OPTION VALUE=".$id1.">".$id1.'</option>';
      }
      ?>
    </SELECT>
Vas Hanea
  • 120
  • 6