Se connecter avec
S'enregistrer | Connectez-vous

PHP for dummies (Here I am)

Dernière réponse : dans Programmation

Hello there!

I'm a young PHP jedi, I work with PHP and MySQL for dummies and I'm stopped on page 30. My problem I've rewrite all the code for testing mysql on my server (PHP test ok)

<?php
/* Programme: 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="helpbusiness.free.fr";
$user="helpbusiness";
$password="c***";

$cxn = mysqli_connect($host,$user,$password);
$sql="SHOW STATUS";
$result = mysqli_query($cxn,$sql);
if($result = false)
{
echo "<h4>Erreur: ".mysqli_error($cxn)."</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>

and when I run the test I've this message

Parse error: syntax error, unexpected '>' in /mnt/149/sdb/2/2/helpbusiness/test-mysql.php on line 28


I need help you could just correct the code because I'm a beginner and I cannot understand any complexe explenation for the moment.

Thanks for all your help.

Pierre, the mad coder

Autres pages sur : php for dummies here

Lassé par la pub ? Créez un compte
Expert Programmation

Hello,
I can spot (at least) two mistakes in your code:
if($result = false) is an assignation; $result will always be assigned the value "false" here. It should be a comparison instead (with the == operator).

echo "<table border='1'>
<tr><th>Nom_Variable</th>
<th>Valeur</th></tr>;
The " quote is opened but never closed.

Also, why are you writing in English? This forum is mostly french speaking (although it appears that there is an automated translation feature that activates itself in some cases).

Ok, bon ben je reparle en français c'est mieux!

Merci pour les infos j'ai réussi à régler le problème en fait le code était pas trop mauvais mais c'est un problème entre mysqli et mysql.

Encore merci je me replonge dans mon bouquin pour les zéros!
Lassé par la pub ? Créez un compte
Tom's guide dans le monde