comparison thule_fit_kits/index.php @ 105:3afe26a1d000

thule_fit_fits: use non-deprecated mysqli module
author paulo
date Mon, 23 Dec 2019 01:13:03 -0800
parents 8689ba61e0e0
children
comparison
equal deleted inserted replaced
4:3acdc823b5dc 5:2158ff4eee9a
33 <?php 33 <?php
34 34
35 include('../../login.php'); 35 include('../../login.php');
36 $database = 'pauloang_fitkits'; 36 $database = 'pauloang_fitkits';
37 37
38 $link = mysql_connect('localhost', $username, $password); 38 $mysqli = mysqli_connect('localhost', $username, $password, $database);
39 if (!$link) 39 if (mysqli_connect_errno())
40 die('Could not connect to MySQL server: ' . mysql_error()); 40 die('Could not connect to MySQL server/database: ' . mysqli_connect_error());
41
42 $db_selected = mysql_select_db($database, $link);
43 if (!$db_selected)
44 die('Could not select database: ' . mysql_error());
45 41
46 $query = 'SELECT * FROM Thule ORDER BY kit_id'; 42 $query = 'SELECT * FROM Thule ORDER BY kit_id';
47 $results = mysql_query($query); 43 $results = mysqli_query($mysqli, $query);
48 44
49 while ($row = mysql_fetch_assoc($results)) { 45 while ($row = mysqli_fetch_assoc($results)) {
50 echo '<TR><TD><DIV class="kit_id">'; 46 echo '<TR><TD><DIV class="kit_id">';
51 $pdf_filename = 'pdf/thule-fit-kit-' . $row['kit_id']. '-instructions.pdf'; 47 $pdf_filename = 'pdf/thule-fit-kit-' . $row['kit_id']. '-instructions.pdf';
52 if (file_exists($pdf_filename)) 48 if (file_exists($pdf_filename))
53 echo '<A HREF="'. $pdf_filename . '">' . $row['kit_id'] . '</A>'; 49 echo '<A HREF="'. $pdf_filename . '">' . $row['kit_id'] . '</A>';
54 else 50 else
74 } 70 }
75 echo '</TD>'; 71 echo '</TD>';
76 echo '</TR>' . "\n"; 72 echo '</TR>' . "\n";
77 } 73 }
78 74
79 mysql_free_result($results); 75 mysqli_free_result($results);
80 mysql_close($link); 76 mysqli_close($mysqli);
81 77
82 ?> 78 ?>
83 79
84 </TABLE> 80 </TABLE>
85 </DIV> 81 </DIV>