Re: mysql test and error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Feb 24, 2008 at 5:00 PM, hE <thelonelynomad@xxxxxxxxx> wrote:
> The following program gave the error:
>
>   "Parse error: parse error in C:\apache\htdocs\mysqltest.php on line 10"

    Look at this part of the code:

$result = mysql_query($sql);
if ($result == 0)
echo '<b>Error ' . mysql_errno() . ': '. mysql_error() . '</b>';
else
{

    The error message gave you the answer.  You don't have the proper
curly brackets for your if/else statements.  Replace the above with
this:

$result = mysql_query($sql);
if ($result == 0) {
    echo '<b>Error ' . mysql_errno() . ': '. mysql_error() . '</b>';
} else {



>
>
>
>  <html>
>  <head><title>Test MySQL</title></head>
>  <body>
>  <!-- mysql_up.php -->
>  <?php
>
> $host="localhost";
>  $user="root";
>  $password="";
>  mysql_connect($host,$user,$password);
>  $sql="show status";
>  $result = mysql_query($sql);
>
> if ($result == 0)
>  echo '<b>Error ' . mysql_errno() . ': '. mysql_error() . '</b>';
>  else
>  {
>  ?>
>  <!-- Table that displays the results -->
>  <table border="1">
>  <tr><td><b>Variable_name</b></td><td><b>Value</b>
>  </td></tr>
>
> <?php
>  for ($i = 0; $i < mysql_num_rows($result); $i++) {
>  echo '<TR>';
>  $row_array = mysql_fetch_row($result);
>  for ($j = 0; $j < mysql_num_fields($result); $j++)
>  {
>  echo '<TD>'. $row_array[$j] . '</td>';
>  }
>  echo '</tr>';
>  }
>  ?>
>  </table>
>  </body></html>
>
>  what is the reason?
>
>
>
>  --
>  PHP General Mailing List (http://www.php.net/)
>  To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux