OSDN Git Service

Fixed CLang warning messages and other
[opengatem/opengatem.git] / phpsrc / showtable.php
index 263347f..6c86044 100644 (file)
 
 <?php
 
-  // check basic auth
-  if(getenv('REMOTE_USER')=='')  die('Cannot get auth');
-
   // no table is indicated 
   if(!isset($_GET['table']))return;
 
   // connect and access to MySql DB
-  $link = mysql_connect('localhost', 'root', '');
-  if (!$link) die('Cannot connect DB'.mysql_error());
+  $link = mysqli_connect('localhost', 'root', '');
+  if (!$link) die('Cannot connect DB'.mysqli_error());
 
-  $db_selected = mysql_select_db('opengatem', $link);
-  if (!$db_selected) die('Cannot select DB'.mysql_error());
+  $db_selected = mysqli_select_db($link, 'opengatem');
+  if (!$db_selected) die('Cannot select DB'.mysqli_error());
 
-  mysql_set_charset('utf8');
+  mysqli_set_charset($link, 'utf8');
 
-  $result = mysql_query('SELECT * FROM '.$_GET['table'].' limit 1000');
-  if (!$result) die('Fail query'.mysql_error());
+  $result = mysqli_query($link, 'SELECT * FROM '.$_GET['table'].' limit 1000');
+  if (!$result) die('Fail query'.mysqli_error());
 
   // print header
   print("<table border=1>");
   print('<tr>');
   $count=0;
-  while ($field = mysql_fetch_field($result)) {
+  while ($field = mysqli_fetch_field($result)) {
     print('<td>'.$field->name.'</td>');
     $count++;
   }
   print('</tr>');
 
   // print rows
-  while ($row = mysql_fetch_row($result)) {
+  while ($row = mysqli_fetch_row($result)) {
     print('<tr>');
     for($i=0; $i<$count; $i++){
       print('<td>'.$row[$i].'</td>');
@@ -52,7 +49,7 @@
     print('</tr>');
   }
   print("</table>");
-  $close_flag = mysql_close($link);
+  $close_flag = mysqli_close($link);
 
 ?>