我已经开始制作一个应用程序,可以从一个网站检索数据到一个应用程序。我创建了一个简单的php文件,但它给出了错误:
解析错误:语法错误,第5行/srv/disk10/2052804/www/poolswag.co.nf/service.php中的意外'$con‘(T_VARIABLE)
我在网上查过了,但是那些犯同样错误的人注意到他们丢失了一个分号,而我的有一个分号。
如能提供任何帮助,将不胜感激。
<?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);
?>发布于 2016-02-07 19:45:03
你在这里看到了”的卷曲/智能引号吗?
("http://www.poolswag.co.nf/","2052804_swag”,”test5350”,”2052804_swag")
^ ^ ^ ^这就是导致错误的原因。
("http://www.poolswag.co.nf/","2052804_swag","test5350","2052804_swag")是两种完全不同的动物。
您可能从网络上复制了一些可能没有正确编码的代码,或者正在使用某种类型的文字处理程序而不是代码“编辑器”。
有关一些代码编辑器的列表和添加的信息,请参阅以下内容:
发布于 2016-02-07 19:45:01
在定义方法的参数时,需要使用"或'字符,但需要使用”。替换错误的字符,一切都应该正常工作。
https://stackoverflow.com/questions/35258149
复制相似问题