【问题标题】:Parse error: syntax error, unexpected 'mysqli_set_charset' (T_STRING) in /home/csgoxdne/public_html/set.php on line 4 [duplicate]解析错误:语法错误,第 4 行 /home/csgoxdne/public_html/set.php 中的意外 'mysqli_set_charset' (T_STRING) [重复]
【发布时间】:2023-03-30 04:38:01
【问题描述】:

我收到此错误:解析错误:语法错误,第 4 行 /home/csgoxdne/public_html/set.php 中的意外 'mysqli_set_charset' (T_STRING)

代码如下:

<?php
$mysqli = new mysqli("localhost:3306", "csgoxdnet", "secretpassword");
  if ($mysqli->error) print ("Error connecting! Message: ".$mysqli->error) 
mysqli_set_charset($mysqli, 'utf8');

function fetchinfo($rowname,$tablename,$finder,$findervalue)
  {($finder == "1");
      $query ="SELECT * FROM $tablename WHERE rowname = '$rowname'";
      $result = mysqli_query($mysqli, $query); 
}
else
    {
         $query = "SELECT * FROM $tablename WHERE `$finder`='$findervalue'"
         if (!$query)   {die    ('Invalid query: '.$mysqli->error)}
         $result = mysqli_query($mysqli, $query);
 }
 return $result;

老实说,我无法修复错误。提前感谢您的帮助。

【问题讨论】:

  • 看起来第 3 行缺少分号。

标签: php mysql mysqli


【解决方案1】:

这样用

$mysqli->query("SET CHARACTER SET utf8");

【讨论】:

    猜你喜欢
    • 2014-04-28
    • 2020-04-23
    • 2015-03-03
    • 1970-01-01
    • 2015-02-24
    • 1970-01-01
    • 2017-07-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多