php - 通过php将希伯来语插入mySql数据库

标签 php mysql hebrew

我试图将希伯来语字母插入到我的数据库中,但这样做时出现语法错误。

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near...

我的表和列在 utf8_general_ci 中。

我只是想不通为什么我会一遍又一遍地收到错误!!!

这是我插入日期的连接和代码:

//Connect DB via function.php
function connectSQL(){
    mysql_connect(LOCALHOST, DB_USER, DB_PASS) or die("MySQL Error: " . mysql_error());
    mysql_select_db(DB_DATE) or die("MySQL Error: " . mysql_error());
}
connectSQL();

页面日期:

$sql = mysql_query("INSERT INTO resourses (
                            title, url_title, seo_key, seo_dec, img, time, content, cat) 
                        VALUES(
                            '$title','$url_title','$seo_key','$seo_dec','$img',now(),'$content','$cat'
                        )") or die (mysql_error());

最佳答案

确保将连接字符集设置为 utf8:

mysql_connect($host, $user, $pass);
mysql_select_db($db);
mysql_set_charset("utf8");

并清理了你的字符串:

$string = mysql_real_escape_string($string);

关于php - 通过php将希伯来语插入mySql数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34614227/

相关文章:

php - 将 Laravel 模型扩展多于一层是一种好习惯吗?

php - 包含日期的复杂查询

MYSQL TINYBLOB和LONGBLOB

JavaScript:作为关联数组键的希伯来字母不起作用

javascript - phonegap-cordova - javascript,字符串的希伯来语值未正确编码

iphone - UITableView 从右到左对齐

php - 选择 Yii 作为我的 PHP 框架是正确的选择吗?

php - 如何将全局变量注入(inject)所有模板?

mysql - 将数据从远程 MySQL 服务器迁移到 Rails App

mysql - 如何在 VB.NET 中的 select count() 查询中设置异常