常规错误:1366错误的字符串值:'\ xE0 \ xAE \ x95 \ xE0 \ xAF \ x8A ...'用于Laravel中的列'占用'

时间:2017-06-07 10:30:34

标签: php laravel laravel-5 utf-8 laravel-5.4

我在Laravel进行基于泰米尔语言的计费Web应用程序。当我将tamil Unicode数据存储在数据库中时,它会显示错误。

<form action="newimage.php" method="POST">

  <div class="row">
    <div class="col-md-6 col-sm-6 col-xs-12">

      <div class="form-group">
        <input type="file" name="pic" id="pic">
      </div>


      <button type="submit" class="btn btn-success">Submit</button>
    </div>

  </div>
</form>

如何解决此问题。我将db config更改为

<?php
  $mysqli = new mysqli("localhost", "root", "", "homepage");
 
  if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
  }

  $name = "somethinghere";

  #do upload
  $target_dir = "uploads";
  $temp = explode(".", $_FILES["pic"]["name"]);
  $newfilename = $target_dir . '/Foto-' . $name . '.' . end($temp);

  if (move_uploaded_file($_FILES['pic']['tmp_name'], $newfilename) ) {
    $productimage = 'Foto-' . $name . '.' . end($temp);
  }
  else
  {
    $productimage = '';
  }


  $sql = "INSERT INTO galeria_front (image_name) VALUES ('$productimage')";

  if ($mysqli->query($sql) === TRUE) {
      header("Location: galery.php");
  } else {
      echo "Error: " . $sql . "<br>" . $mysqli->error;
  }

  $mysqli->close();
?>

并在页面头部

中定义了字符串到utf-8

enter image description here

0 个答案:

没有答案