File "mysql.php"
Full Path: /home/analogde/www/Design/fileman/Fusion/Picker/mysql.php
File size: 2.58 KB
MIME-type: text/x-php
Charset: utf-8
<?php
$site = $_SERVER["SERVER_NAME"];
if( ($site == "localhost") || ($site == "127.0.0.1") )
{
echo "Mode local";
echo "<br>";
$hostdb = "localhost";
$userdb = "root";
$passdb = "";
$namedb = "task_manager";
}
else
{
echo "Hebergeur";
echo "<br>";
$hostdb = "analogdepat.mysql.db";
$userdb = "analogdepat";
$passdb = "Un92pac007";
$namedb = "analogdepat";
}
// connexion
$conn = new mysqli($hostdb, $userdb, $passdb, $namedb);
// gestion erreur de connexion
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
/********************************************/
// OK - liste toutes les tables de la DB
$allTables = array();
$showtables= mysqli_query($conn, "SHOW TABLES FROM $namedb");
while($table = mysqli_fetch_array($showtables))
{
echo($table[0] . "<br>");
$allTables[] = $table[0];
}
/********************************************/
// OK - nombre d'enregistrement dans la DB
$sql = "SELECT * from appli_table_jeu";
if ($result = mysqli_query($conn, $sql))
{
// Return the number of rows in result set
$rowcount = mysqli_num_rows( $result );
// Display result
printf("Total rows in this table : %d\n", $rowcount);
}
/********************************************/
$exists = "wp62_wfco_connectors";
$exists = "client";
$row = mysql_query($conn, 'SELECT COUNT(*) FROM appli_table_jeu');
$query = "SELECT * FROM appli_table_jeu";
$row = mysql_query($conn, $query);
echo " +++++ " .$query ." " .$row;
echo "<br>";
if (in_array( $exists, $allTables))
{
echo "Bingo";
}
$query = "SELECT * FROM $exists";
echo " ---->>>> " .$query;
echo "<br>";
// execute query
$result = mysqli_query($conn, $query) or die ("Error in query: $query. ".mysql_error());
if (mysql_num_rows($result) > 0) {
echo "Table is not Empty";
}
else echo "Table is Empty";
/*
// SQL query
$sql = "SHOW TABLES IN $hostdb";
// perform the query and store the result
$result = $conn->query($sql);
// if the $result not False, and contains at least one row
if($result !== false)
{
// if at least one table in result
if($result->num_rows > 0)
{
// traverse the $result and output the name of the table(s)
while($row = $result->fetch_assoc())
{
echo '<br />'. $row['Tables_in_tests'];
}
}
else
{
echo 'There is no table in "tests"';
}
}
else
{
echo 'Unable to check the "tests", error - '. $conn->error;
}
$conn->close();
*/
?>