|
|
|
|
Bonjour,
je me lance dans l'apprentissage de MySQL et PHP, j'ai acheter un livre... j'ai suivi de prêt leur exemple, j'ai chercher mon erreur, regarder sur le net ce qui se faisait... bref je ne comprend toujours pas mon erreur. Je sollicite votre aide. Toutes suggestions sont les bienvenues. Merci d'avance.
<?php
/* Progamme: mysql_up.php
* desc: Se connecte au serveur MySQL et
* affiche les paramètres.
*/
echo "<html>
<head><title>Test de MySQL5 avec PHP5</title></head>
<body>";
$host="localhost";
$user="";
$password="";
$cxn=mysqli_connect($host,$user,$password);
$sql="SHOW STATUS";
$result=mysql_query($cxn,$sql);
if($result == false)
{
echo "<h4>Erreur: ".mysql_error($cxn). "</h4>;
}
else
{
/* Tableau affichant les résultats */
echo "<table border='l'>
<tr><th>Nom_Variable</th>
th>Valeur</th></tr>";
for($i = 0; $i < mysqli_num_row($result); $i++)
{
echo "<tr>";
$row_array = mysqli_fetch_row($result);
for($j = 0;$j < mysqli_num_fields($result);$j++)
{
echo "<td>".$row_array[$j]."</td>\n";
}
}
echo "</table>";
}
?>
</body>
</html>
-->Parse error: parse error, expecting `','' or `';'' in C:\Program Files\EasyPHP 3.0\www\test-mysql.php on line 23
Configuration: Windows XP Firefox 3.0.8 Easyphp 3
Bonsoir, essaie ceci :
<html>
<head><title>Test de MySQL5 avec PHP5</title></head>
<body>
<?php
$host="localhost";
$user="";
$password="";
$cxn=mysqli_connect($host,$user,$password);
$sql="SHOW STATUS";
$result=mysql_query($cxn,$sql);
if($result == false)
{
echo "<h4>Erreur: ".mysql_error($cxn). "</h4>";
}
else
{
/* Tableau affichant les résultats */
echo "<table border='l'>
<tr><th>Nom_Variable</th>
th>Valeur</th></tr>";
for($i = 0; $i < mysqli_num_row($result); $i++)
{
echo "<tr>";
$row_array = mysqli_fetch_row($result);
for($j = 0;$j < mysqli_num_fields($result);$j++)
{
echo "<td>".$row_array[$j]."</td>\n";
}
}
echo "</table>";
}
?>
</body>
</html> |
Répondre à Adenora
|
<?php
|
Programme:
|
<?php
|
J'ai testé avec MySQL (j'ai changé pour mettre en MySQLite après)
<?php
/* Progamme: mysql_up.php
* desc: Se connecte au serveur MySQL et
* affiche les paramètres.
*/
echo "<html>
<head><title>Test de MySQL5 avec PHP5</title></head>
<body>";
$host="localhost";
$user="root"; // A voir
$password="";
$database=""; // Base de données
$cxn=mysqli_connect($host,$user,$password) or die(mysql_error());
$result=mysqli_query("SHOW TABLE STATUS FROM $database") or die(mysql_error()); // Requête que tu veux faire ?
if($result == false)
{
echo "<h4>Erreur: ".mysql_error($cnx). "</h4>";
}
else
{
/* Tableau affichant les résultats */
echo "<table border='1'>
<tr><th>$Nom_Variable</th>
<th>Valeur</th></tr>";
for($i = 0; $i < mysqli_num_rows($result); $i++)
{
echo "<tr>";
$row_array = mysqli_fetch_row($result);
for($j = 0;$j < mysqli_num_fields($result);$j++)
{
echo "<td>".$row_array[$j]."</td>\n";
}
echo "</tr>";
}
echo "</table>";
}
?>
</body>
</html> |
---> le programme a l'air de fonctionner, plus de beug ligne 13 15 18
|
As-tu regardé ici -> http://www.manuelphp.com/php/function.mysqli-connect.php
|
<?php
|
-----> Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\Program Files\EasyPHP 3.0\www\test mySQL 222.php on line 15
|