Mysql在特殊字符后剪切文本

时间:2013-10-02 13:29:14

标签: php mysql utf-8

当我尝试使用下面的php脚本插入government-owned时,它只插入government,当我使用PHPmyAdmin时,它完美地运行。我的PHP脚本有问题吗?

class database
  {
     private $config = array(
        'host'      => 'localhost',
        'username'  => 'root',
        'password'  => 'root',
        'dbname'    => 'yelo'
        );


public function dbConnect(){

    $dbcnx = @mysql_connect($this->config['host'], $this->config['username'], $this->config['password'])
    or die("The site database appears to be down.");

    if ($this->config['dbname']!="" and !@mysql_select_db($this->config['dbname']))        
    die("The site database is unavailable.");

    return $dbcnx;
    }

}


$connDb = new database; 
$connDb->dbConnect(); 

// I thought this could eliminate the problem
$business_name = mysql_escape_string($_POST['business_name']);

$query = "INSERT INTO business SET biz_name = '$business_name'" 
$result = mysql_query($query);

感谢您的帮助。

0 个答案:

没有答案
相关问题