Re: Parse Error

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

 



----- Original Message ----- 
From: "Ray Cantwell" <malbojia@xxxxxxx>
To: <php-general@xxxxxxxxxxxxx>
Sent: Tuesday, February 21, 2006 1:27 PM
Subject:  Parse Error


> Hi all,
> I am a noob and super confused right now. I have some really simple code 
> and i am getting an error that reads:
> *Parse error*: syntax error, unexpected T_VARIABLE in 
> */var/www/mysql_up.php* on line
> 
> here is the code:
> 
> <html>
> <head><title>Test MySQL</title></head>
> <body>
> <!-- mysql_up.php -->
> <?php
> $host="localhost"
> $user="ray"
> $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>
> <?php } ?>
> </body></html>
> 
> I am really confused because i cannot see any obvious errors.
> any help would be appreciated.
> 
> Ray.
> 
> 
> 
>

you need to add a ; to every  variable you assign... 
you had:
$host="localhost"
 $user="ray"
 $password="*****"

it should be:

$host="localhost";
$user="ray";
$password="*****";

also i belive a better way to get the result of your query would be

mysql_connect($host, $user, $pass) or die(mysql_error());

-- 
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