0

I've just updated to PHP 5.6, and several things are depreciated from 5.3 which I had been using. I know this is simple, but I suppose I want to think it through out loud, and request suggestions for making it better.

My old code looked something like this:


 <?php 
         
         include('req.php');
         include('bank.php');
         
     $query="SELECT * FROM xx WHERE xx IN ('xx')";
        
          $resource=mysql_query($query,$link);
          echo "
        <table id=\"space\" class=\"sortable\" align=\"center\" border=\"0\" width=\"95%\">
        <tr>
        <td><b>Column 1</b></td><td><b>Column 2</b></td><td><b>Column 3</b></td><td><b>Column 4</b></td><td><b>Column 5</b></td><td><b>Column 6</b></td><td><b>Column 3</b></td></tr> ";
while($result=mysql_fetch_array($resource))
    { 
    echo "<tr><td>".$result[1]."  </td><td>".$result[8]."</td><td>".$result[15]."</td><td>".$result[21]."</td><td>".$result[17]."</td><td>".$result[16]."</td><td><a href='/pages/things.php?result=$result[24]'>Link</a></td></tr>";
    } echo "</table>";
     ?></p>

Where bank.php looks like this:

<?php
$link = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql');
mysql_select_db($dbname);
?>

and req.php looks something like this:

<?php
$dbhost = 'db.server.com';
$dbuser = 'xx';
$dbpass = 'xx';
$dbname = 'xx';
?>

I think the right answer is to change bank.php to this:

<?php
$link = mysqli_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql');
mysqli_database($dbname);
?>

But I'm not sure how to phrase the query. Can anyone help here? Many thanks in advance!

0 Answers0