<?php
/* Program: mysql_up.php
* Desc: Connects to MySQL Server and outputs settings.
* Testing Mysql -- page 35
*/
// Starting page generation
echo "<html>
<head><title>test MySQL</title></head>
<body>\n";
// SQL Credentials
$database = "database";
$host = "host";
$user = "mysqlaccount";
$password = "mysqlpassword";
// Connecting to the database
$cxn = mysql_connect($host, $user, $password);
$sql = "SHOW GLOBAL STATUS";
$result = mysql_query($sql, $cxn);
// Checking for errors
if($result == false)
{
echo "<h4>error: " . mysql_error($cxn) . "</h4>";
}
else
{
//* Displaying the table
echo "<table border='1'>
<tr><th>variable_name</th></tr>\n";
for($i = 0; $i < mysql_num_rows($result); $i++)
{
echo "<tr>\n";
$row_array = mysql_fetch_row($result);
for($j = 0; $j < mysql_num_fields($result); $j++)
{
echo "<td>{$row_array[$j]}</td>\n";
}
echo "</tr>\n";
}
echo "</table>";
}
?>
</body></html>
- <?php
- /* Program: mysql_up.php
- * Desc: Connects to MySQL Server and outputs settings.
- * Testing Mysql -- page 35
- */
-
- // Starting page generation
- echo "<html>
- <head><title>test MySQL</title></head>
- <body>\n";
-
- // SQL Credentials
- $database = "database";
- $host = "host";
- $user = "mysqlaccount";
- $password = "mysqlpassword";
-
- // Connecting to the database
- $cxn = mysql_connect($host, $user, $password);
- $sql = "SHOW GLOBAL STATUS";
- $result = mysql_query($sql, $cxn);
-
- // Checking for errors
- if($result == false)
- {
- echo "<h4>error: " . mysql_error($cxn) . "</h4>";
- }
- else
- {
-
- //* Displaying the table
- echo "<table border='1'>
- <tr><th>variable_name</th></tr>\n";
- for($i = 0; $i < mysql_num_rows($result); $i++)
- {
- echo "<tr>\n";
- $row_array = mysql_fetch_row($result);
- for($j = 0; $j < mysql_num_fields($result); $j++)
- {
- echo "<td>{$row_array[$j]}</td>\n";
- }
- echo "</tr>\n";
- }
- echo "</table>";
- }
- ?>
- </body></html>
Todo lo que se había errores de ortografía en las funciones y un booleano. A pocos indicios de falta de dólar ($) que indica una variable...un fuera de lugar </ tr>...
Incluso el formato del código para usted gif "alt = =":)" título" Smile ">
Aquí, en vez de darle el código fijo, la enfermedad se ejecuta a través del código que envió y le dirá exactamente donde salió mal
<?php
/* Program: mysql_up.php
* Desc: Connects to MySQL Server and outputs settings.
* Testing Mysql -- page 35
*/
echo "<html>
<head> <title>test MySQL</title></head>
<body>";
$database = "database";
$mysql_user = "mysqluser";
$password = "mysqlpassowrd";
$host="host";
$user="mysqlaccount";
$password="mysqlpasssowrd";
- <?php
- /* Program: mysql_up.php
- * Desc: Connects to MySQL Server and outputs settings.
- * Testing Mysql -- page 35
- */
- echo "<html>
- <head> <title>test MySQL</title></head>
- <body>";
- $database = "database";
- $mysql_user = "mysqluser";
- $password = "mysqlpassowrd";
- $host="host";
- $user="mysqlaccount";
- $password="mysqlpasssowrd";
Eso no tiene nada de malo en ello...tal vez podría tener el formato un poco mejor. Lo único que veo es que tienes dos variables clave en allí ($ contraseña)
$cxn = mysqli_connect($host, $user. $password);
$sql ="SHOW GLOBAL STATUS";
$result = mysql_query ($cxn,$sql);
- $cxn = mysqli_connect($host, $user. $password);
- $sql ="SHOW GLOBAL STATUS";
- $result = mysql_query ($cxn,$sql);
Usted está utilizando mysql
i _connect pero mysql_query...eliminar esa "i" de mysqli_connect y usted debe ser bueno.
Otra de las cosas...poner el identificador de enlace ($ CXN) en primer lugar...contrariamente a lo que puso, el $ sql debe ser el primer argumento pasado a mysql_query (mysql (
cxn $ sql, $ ))
Que se supone que es
falsos ...no
flase
echo "<h4>error: ".mysqli_eror(cxn)."</h4>";
}
- echo "<h4>error: ".mysqli_eror(cxn)."</h4>";
- }
Aquí es un lugar donde se perdió el signo de dólar...que
else
{
//* Table that displays
echo "<table border='1'>
<tr><th>variable_name</tr>";
- else
- {
- //* Table that displays
-
- echo "<table border='1'>
- <tr><th>variable_name</tr>";
Le falta un </ th> justo antes de que </ tr> (Wouldnt lanzar un error de PHP...el código HTML puede tener un aspecto funky sin embargo.
for($i = 0; $i < mydwli_num_rows($result); $i++)
{
- for($i = 0; $i < mydwli_num_rows($result); $i++)
- {
Yo nunca he oído hablar de un mydwli_num_rows función...a menos que usted declaró que la función en alguna parte, su supone que
mysql_num_rows Probablemente escribiendo demasiado rápido gif "alt = =":)" título" Smile ">
echo "<tr>";
$row_array = mysqli_fetch_row($result);
for($j = 0;$j < mysqli_num_feilds($result);$j++)
{
- echo "<tr>";
- $row_array = mysqli_fetch_row($result);
- for($j = 0;$j < mysqli_num_feilds($result);$j++)
- {
Los
mysqli_ * debe ser
mysql_ * (Mysql_fetch_row ($ resultado) y mysql_num_fields ($ resultado)
También mal escrito campos...que deletreó feilds. Escribiendo demasiado rápido otra vez (creo).
echo "<td>".row_array[$j]."</td>\n";
}
}
echo "</table>";
}
?>
</body></html>
- echo "<td>".row_array[$j]."</td>\n";
- }
-
- }
- echo "</table>";
- }
- ?>
- </body></html>
Otro caso en el que se olvidó de que signo de dólar...que
row_array [$ j] deberían tener el derecho signo de dólar frente a ella. Por lo tanto, debe ser
$ Row_array [$ j] ...el hecho de que la variable es una matriz no cambia nada.
Esa línea puede ser escrito un poco mejor también...mediante llaves.
echo "<td>{$row_array[$j]}</td>\n";
Esto ahorra un poco de espacio
