- $str="james//bond";
-
$str= mysqli_real_escape_string($con,$str);
-
//insert query
after successful insert in database it value shows as "james/bond"
how I can insert exact string? anyone pls help.
14 10728
try "james"+@"\\Bond"; I think it should work fine.
Try this? -
$str="james\/\/bond";
-
$succ=$mysqli->query($sql);
-
Luuk 1,047
Expert 1GB
That dos not happen here.... - 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>
Luuk 1,047
Expert 1GB
oh wait, I see what I did wrong......
"James Bond" is not an actor..... ;)
Yeah... you also didn't do it in PHP, which doesn't answer his question. Try running the same querying in PHP and you will get the same result as the OP.
Luuk 1,047
Expert 1GB - <?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();
-
?>
-
running this (from the command-line) - luuk@opensuse:~/tmp> php actors.php
-
James//Bond
-
Roger//Moore
-
luuk@opensuse:~/tmp>
-
Luuk 1,047
Expert 1GB
and also if I use real_escape_string - <?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();
-
?>
-
running this: - luuk@opensuse:~/tmp> php actors.php
-
James//Bond
-
Roger//Moore
-
Ursula//Andress
-
luuk@opensuse:~/tmp>
harintfs, were you able to get it to work?
Luuk 1,047
Expert 1GB
MUST I remind you, that the subject of this message is NOT the same as what is tried in the example ?
The subject is about 'backslashes' (a.k.a. '\')
The example is showing 'slashes' (a.k.a. '/')
Next code - <?php
-
echo "A\\B \n";
-
echo "A//B \n";
-
echo "A\B \n";
-
echo "A/B \n";
-
?>
-
will print:
@Luuk, if you look at his code, which I'm sure you did, he just has slashes.
He never mentions "backslashes" in his first post other than the title. Could it be that he misspoke ;-)
Please read the question instead of assuming the question from the title. Since you seem to know exactly what they are asking for, please show me in his first post where he mentions "backslashes" thanks.
Luuk 1,047
Expert 1GB
@computerfox: let's wait for harintfs and what he has to say about slashes and backslashes...
I was reading the question, not the title ,when I gave some working code.
But what harintfs describes is the same as what happens to my example
which produces
so, one should not just read question, but also read title
Depends how you look at it. Usually if we're lucky to have an example, that's what we should go with, but I agree, let's wait for the OP to clarify what they wanted.
but how about to inserting a location file in variable from "LoadFromFile" in MySQL?
You need to escape your backslash : - INSERT INTO gender
-
(sex, date) VALUES (
-
'male are allowed \\ female are not allowed',
-
"2012-10-06")
Sign in to post your reply or Sign up for a free account.
Similar topics
by: usgog |
last post by:
I need to implement a function to return True/false whether String A
contains String B. For example, String A = "This is a test"; String B =
"is is". So it will return TRUE if String A includes two...
|
by: Vincent Texier |
last post by:
Hello,
I want to send 3 chars in hexa code to the serial port.
So I type in a tkinter entry : "\x20\x01\x21"
The string is set in a StringVar().
When I read the stringVar, I get :...
|
by: Christine |
last post by:
I was wondering if it is possible to convert an array that is of type string
to type double so that matrix operations can be performed on it? I have a
string array because I needed to split the...
|
by: Coleen |
last post by:
Hi All :-)
I found the way to get my column sum (Thanks Cor I did it a little different, but the result is what I wanted) I used:
dt_stat_report_3b.Columns.Add(New DataColumn("Sum",...
|
by: Stef Mientki |
last post by:
It looks like sometimes a single backslash is replaced by a double backslash,
but sometimes it's not ???
See the error message below,
the first backslash is somewhere (not explicitly in my code)...
|
by: Milsnips |
last post by:
Hi there,
i'm trying to do a string replace on something like the following
string MyString = myinput;
myinput = myinput.Replace("src="../content/","http://www.site.com/content/")
but, the...
|
by: Waruna |
last post by:
Is there a way to block insert into mysql(5.0) using c api of mysql
db..
i.e.
say there is a table with 2 columns, one contains char other int
then i want to insert 500 records at once,, as i...
|
by: maheshwag |
last post by:
If I have to insert with two sql table and the place of string is as below:
// Single Record Insert
String AA=”Insert into aa(date)values(@date)”;
//Multiple Record Insert with...
|
by: vanitha asokan |
last post by:
how to insert '\' in mysql database using java code
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |