hi everyone use DBI; $user='xxxx'; $password='xxxx'; $host='localhost'; $db='test'; $dbh = DBI->connect("DBI:mysql:database=$db;host=$host", $user, $password, {RaiseError => 1}); $name = "vrs'z'kf"; $dbh->do("INSERT INTO test (test)VALUES('$name' )"); Code (markup): Here is my code. How i can escape $name string for successfully mysql_query ? //OR// i found SQL syntax error; Thanks all!
I found this in Google buy request Perl function equivalent of PHP’s AddSlashes() sub AddSlashes { $text = shift; ## Make sure to do the backslash first! $text =~ s/\\/\\\\/g; $text =~ s/'/\\'/g; $text =~ s/"/\\"/g; $text =~ s/\\0/\\\\0/g; return $text; }