about escape string store in mysql

Y

ylj798

this string from web by the Regular Expression$B!$(B
$B!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!](B
href="#" onClick="ConvertURL2FG('Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMDA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ==&233','',
233)" oncontextmenu="Flashget_SetHref(this)" fg="Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMDA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ==&233"
$B!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!](B
my code:

******************************************************************************
# -*- coding: utf8 -*-
#!/usr/bin/python

import MySQLdb
conn=MySQLdb.connect
(host="localhost",user="root",passwd="ylj",db="net", charset="utf8")
cur = conn.cursor()
s="""href="#" onClick="ConvertURL2FG('Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMDA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ==&233','',
233)" oncontextmenu="Flashget_SetHref(this)" fg="Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMDA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ==&233""""
s=mysqldb.escape_string(s)
sql='insert into download(lines) values(%s)'
cur.execute(sql, s)

************************************************************

when I used the mysqldb.escape_string(),but eric gave me a error,tell
me that my sql strings have escape string.
how can i put the strings in database.
 
M

MRAB

this string from web by the Regular Expression$B!$(B
$B!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!](B
href="#" onClick="ConvertURL2FG('Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMDA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ==&233','',
233)" oncontextmenu="Flashget_SetHref(this)" fg="Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMDA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ==&233"
$B!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!](B
my code:

******************************************************************************
# -*- coding: utf8 -*-
#!/usr/bin/python

import MySQLdb
conn=MySQLdb.connect
(host="localhost",user="root",passwd="ylj",db="net", charset="utf8")
cur = conn.cursor()
s="""href="#" onClick="ConvertURL2FG('Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMDA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ==&233','',
233)" oncontextmenu="Flashget_SetHref(this)" fg="Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMDA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ==&233""""
s=mysqldb.escape_string(s)
sql='insert into download(lines) values(%s)'
cur.execute(sql, s)

************************************************************

when I used the mysqldb.escape_string(),but eric gave me a error,tell
me that my sql strings have escape string.
how can i put the strings in database.

The string that you're trying to put into the database ends ...=&233",
so when you triple-quote it you get ...=&233"""". Python sees this
as ...=&233""" (triple quotes end the triple-quoted string) followed
by " and then the end of the line.

Try escaping the quote after ...=&233, ie ...=&233\"""".
 
S

Steve Holden

MRAB said:
this string from web by the Regular Expression$B!$(B
$B!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!](B
href="#" onClick="ConvertURL2FG('Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMDA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ==&233','',
233)" oncontextmenu="Flashget_SetHref(this)" fg="Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMDA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ==&233"
$B!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!](B
my code:

******************************************************************************
# -*- coding: utf8 -*-
#!/usr/bin/python

import MySQLdb
conn=MySQLdb.connect
(host="localhost",user="root",passwd="ylj",db="net", charset="utf8")
cur = conn.cursor()
s="""href="#" onClick="ConvertURL2FG('Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMDA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ==&233','',
233)" oncontextmenu="Flashget_SetHref(this)" fg="Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMDA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ==&233""""
s=mysqldb.escape_string(s)
sql='insert into download(lines) values(%s)'
cur.execute(sql, s)

************************************************************

when I used the mysqldb.escape_string(),but eric gave me a error,tell
me that my sql strings have escape string.
how can i put the strings in database.

The string that you're trying to put into the database ends ...=&233",
so when you triple-quote it you get ...=&233"""". Python sees this
as ...=&233""" (triple quotes end the triple-quoted string) followed
by " and then the end of the line.

Try escaping the quote after ...=&233, ie ...=&233\"""".

Or. simpler, use tripled single quotes as your string delimiters.

regards
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top