0

解析错误:语法错误,第 4 行 /home/content/00/7882800/html/Connections/dueslogin.php 中的意外 T_VARIABLE

试图连接到 godaddy 数据库并且由于 php 错误而无法连接。

<?php
        //Variables for connecting to your database.
        //These variable values come from your hosting account.
        $hostname = "Squarepants.db.7882800.hostedresource.com";
        $username = "Squarepants";
        $dbname = "Squarepants";

        //These variable values need to be changed by you before deploying
        $password = "***********";
        $usertable = "Spongebob";
        $username = "username";
        $password = "password";

        //Connecting to your database
        mysql_connect($hostname, $username, $password) OR DIE ("Unable to 
        connect to database! Please try again later.");
        mysql_select_db($Squarepants);

        //Fetching from your database table.
        $query = "SELECT * FROM $usertable";
        $result = mysql_query($query);

        if ($result) {
            while($row = mysql_fetch_array($result)) {
                $name = $row["$yourfield"];
                echo "Name: $name<br>";
            }
        }
?>
4

2 回答 2

1

我能够在我的计算机上编译这个脚本而没有任何语法错误。

$ php yourcodecopiedandpasted.php 
$ php -l yourcodecopiedandpasted.php 
No syntax errors detected in foo.php
$ php --version
PHP 5.3.15 with Suhosin-Patch (cli) (built: Jul 31 2012 14:49:18) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
于 2012-10-28T03:46:58.480 回答
1

第 4 行应该来自包含的文件Connections/dueslogin.php

您可能需要发布它,以便我们检查有什么问题。当前文件很好,似乎没有任何错误。

于 2012-10-28T07:17:59.820 回答