Lithin Kuriachan
Lithin Kuriachan

Reputation: 33

how to insert special characters in mysql DB using 7.0.7

mysql_real_escape_string() was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0 ,So what can I do for insert special characters in mysql DB using php 7.0.7

Upvotes: 0

Views: 538

Answers (2)

Mani
Mani

Reputation: 2655

use addslashes instead of mysql_real_escape_string()

Upvotes: 0

Chonchol Mahmud
Chonchol Mahmud

Reputation: 2735

You can insert special character with PDO.Lets take a look with example:

<?php
$conn = new PDO('mysql:host=localhost;dbname=form', $username, $password);

/* Complex string */
$string = "Co'mpl''ex \"st'\"ring";
print "Unquoted string: $string\n";
print "Quoted string: " . $conn->quote($string) . "\n";
?>

Upvotes: 0

Related Questions