Looking for a solution: Parse error: syntax error, unexpected
箭
2021-01-24 12:49:57
0
1
2787

The following code is saved as wel.php file

<?php

header("content-type:text/html;charset=utf-8");         //设置编码
require 'pdoconfig.php';  //读取公共参数
$dsn = "{$dbType}:host={$host};dbname={$dbName}";  //创建数据源

try{
$pdo = new PDO($dsn,$userName,$password);
$updateTime = time();
$sql = "update grade set name=:name,price=:price,update_time=:update_time where id=10";
$stmt=$pdo ->prepare($sql);
$num = $stmt->execute([':name'=>'php',':price'=>2750,':update_time'=>$updateTime]);
echo '1';

if ($num > 0){
	print '成功的更新了'.$num.'条记录;
}	
}catch (PDOException $e){
	die('操作失败'.$e->getMessage());
}




?>

The following error occurs when running:

Parse error: syntax error, unexpected '操作失败' (T_STRING) in D:\xp.cn\www\wwwroot\admin\localhost_80\wwwroot\pdoupdatepre.php on line 28

Please solve it?

箭

reply all(1)
天蓬老师

The prompt is very clear, syntax error: there is an extra "}" in line 17, delete

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template