Verbatim PHP code works on current, live site, but not new site (local or live)

118 Views Asked by At

MySQL

Server: mysql.mysite.com via TCP/IP Server version: 5.1.56-log Protocol version: 10 User: username@__.dreamhost.com MySQL charset: UTF-8 Unicode (utf8)

Web server

Apache MySQL client version: 5.1.66 PHP extension: mysql

phpMyAdmin

Version information: 3.3.10.4

I am at wits end right now. The exact code is currently working on the live site, but will not work for the new site I am designing.

<table>
    <tr bgcolor="#CCCCCC">

    <th>###</th>
    <th>Year</th>
    <th>Make</th>
    <th>Model</th>
    <th>Description</th>
    <th>Mileage</th>
    <th>Price</th>
    </tr>
<?

  $host = "mysql.mysite.com";
  $user = "username";
  $pass = "password";
  $dbname = "database";

  $connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
  mysql_select_db($dbname);

  $sql = "SELECT * FROM vehicles WHERE sold='n' ORDER BY year DESC";

  $query = mysql_query($sql);

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

    echo "<tr>
      <td></td>
      <td>",$row['year'],"</td>
      <td>",$row['make'],"</td>
      <td>",$row['model'],"</td>
      <td>",$row['dscrpt'],"</td>
      <td>",$row['miles'],"</td>
      <td>",'$',$row['price'],"</td>
      </tr>";
  }
  ?> 
</table>

I am receiving the following results on the site, both locally & when loaded on the server:

"); mysql_select_db($dbname); $sql = "SELECT * FROM vehicles WHERE sold='n' ORDER BY year DESC"; $query = mysql_query($sql); while ($row = mysql_fetch_array($query)) { echo ""; } ?>

Year Make Model Description Mileage Price ",$row['year']," ",$row['make']," ",$row['model']," ",$row['dscrpt']," ",$row['miles']," ",'$',$row['price'],"

I tried a few other ways including mysqli approach, but they all yield the same results. Nothing has changed with the any of the connections and the current connection/web page still returns data. I'm going crazy looking over the code and using different code with the same results.

1

There are 1 best solutions below

5
On

Use <?php instead of the short open tag <?.