Code:
$str="james//bond"; $str= mysqli_real_escape_string($con,$str); //insert query
how I can insert exact string? anyone pls help.
$str="james//bond"; $str= mysqli_real_escape_string($con,$str); //insert query
mysql> create table actor(name varchar(40));
Query OK, 0 rows affected (0.40 sec)
mysql> insert into actor values ("James//Bond");
Query OK, 1 row affected (0.07 sec)
mysql> select * from actor;
+-------------+
| name |
+-------------+
| James//Bond |
+-------------+
1 row in set (0.04 sec)
mysql>
<?php
error_reporting(E_ALL);
$m = new mysqli("localhost","test","test","test");
$actor = "Roger//Moore";
$sql = "INSERT INTO actor VALUES ('$actor')";
$result = $m->query($sql);
$sql = "SELECT * FROM actor";
if ($result = $m->query($sql)) {
while ($obj = $result->fetch_object())
{
echo $obj->name."\n";
}
}
$result->close();
?>
luuk@opensuse:~/tmp> php actors.php James//Bond Roger//Moore luuk@opensuse:~/tmp>
<?php
error_reporting(E_ALL);
$m = new mysqli("localhost","test","test","test");
$actor = "Ursula//Andress";
$actor = $m->real_escape_string($actor);
$sql = "INSERT INTO actor VALUES ('$actor')";
$result = $m->query($sql);
$sql = "SELECT * FROM actor";
if ($result = $m->query($sql)) {
while ($obj = $result->fetch_object())
{
echo $obj->name."\n";
}
}
$result->close();
?>
luuk@opensuse:~/tmp> php actors.php James//Bond Roger//Moore Ursula//Andress luuk@opensuse:~/tmp>
<?php
echo "A\\B \n";
echo "A//B \n";
echo "A\B \n";
echo "A/B \n";
?>
A\B A//B A\B A/B
echo "A\\B";
A\B
Comment