首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >php文件分析错误

php文件分析错误
EN

Stack Overflow用户
提问于 2016-02-07 19:39:16
回答 2查看 52关注 0票数 1

我已经开始制作一个应用程序,可以从一个网站检索数据到一个应用程序。我创建了一个简单的php文件,但它给出了错误:

解析错误:语法错误,第5行/srv/disk10/2052804/www/poolswag.co.nf/service.php中的意外'$con‘(T_VARIABLE)

我在网上查过了,但是那些犯同样错误的人注意到他们丢失了一个分号,而我的有一个分号。

如能提供任何帮助,将不胜感激。

代码语言:javascript
复制
    <?php
     
    // Create connection
   -----> line 5 $con=mysqli_connect("http://www.poolswag.co.nf/","2052804_swag”,”test5350”,”2052804_swag");
     
    // Check connection
    if (mysqli_connect_errno())
    {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
     
    // This SQL statement selects ALL from the table 'Locations'
    $sql = "SELECT * FROM PoolInfo";
     
    // Check if there are results
    if ($result = mysqli_query($con, $sql))
    {
        // If so, then create a results array and a temporary one
        // to hold the data
        $resultArray = array();
        $tempArray = array();
     
        // Loop through each row in the result set
        while($row = $result->fetch_object())
        {
            // Add each row into our results array
            $tempArray = $row;
            array_push($resultArray, $tempArray);
        }
     
        // Finally, encode the array to JSON and output the results
        echo json_encode($resultArray);
    }
     
    // Close connections
    mysqli_close($con);
    ?>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-02-07 19:45:03

你在这里看到了的卷曲/智能引号吗?

代码语言:javascript
复制
("http://www.poolswag.co.nf/","2052804_swag”,”test5350”,”2052804_swag")
                                           ^ ^        ^ ^

这就是导致错误的原因。

代码语言:javascript
复制
("http://www.poolswag.co.nf/","2052804_swag","test5350","2052804_swag")

是两种完全不同的动物。

您可能从网络上复制了一些可能没有正确编码的代码,或者正在使用某种类型的文字处理程序而不是代码“编辑器”。

有关一些代码编辑器的列表和添加的信息,请参阅以下内容:

票数 3
EN

Stack Overflow用户

发布于 2016-02-07 19:45:01

在定义方法的参数时,需要使用"'字符,但需要使用。替换错误的字符,一切都应该正常工作。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35258149

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档