1
SQL 구문에 오류가 있지만 나는 다음과 같은 오류 얻을 :이 내 파이썬 코드는 내가 excute에 할 것입니다파이썬 MySQL의 오류 1064 당신은 내가 MySQL의 쿼리를 excute에 노력하고있어
(1064, 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'C:/wamp/www/dle/uploads/posts/2013-08/1376251255-IMG11111674.jpg" >\n \' at line 3')
을 :
image_p_add = """
<div>
<!--TBegin:%s|-->
<a href=\"%s\" onclick=\"return hs.expand(this)\" >
<img src=\"%s\" alt=\"%s\" title=\"%s\" />
</a>
<!--TEnd-->
</div><br /><br />
""" % (img_fulladd.replace("_", "\_"), img_fulladd.replace("_", "\_"), thumb_fulladd.replace("_", "\_"), post_header[1:-1], post_header[1:-1])
post_shrt_text = "some text" + image_p_add
qu0 = """INSERT INTO dle_post (category, short_story)
VALUES
('1', %s)""" % (post_shrt_text)
cur.execute(qu0)
나는 내 코드를 많이 확인했으며 빠진 따옴표가 거의 없다고 확신했다.
C:/wamp/www/dle/uploads/posts/2013-08/1376251255-IMG11111674.jpg
post_header
따옴표 내가 잘못 일을 할 수있는 어떤
모든 아이디어를 내 헤더의 텍스트입니다 :
img_fulladd
및 thumb_fulladd
같은 일부 이미지 주소는?
코드 예제에 MySQL 호출이 포함되어 있지 않으므로 질문에 누락 된 부분이있는 것 같습니다. 실제로 SQL 쿼리를 실행하는 코드 부분을 보여줄 수 있습니까? 준비된 문장을 사용하면 문제가 해결되는 것처럼 보이지만 이미 가지고있는 코드를 보지 않고 좋은 예를 제시하는 것은 어렵습니다. –
@MartinAtkins는 짧은 코드를 보내고 코드를 완성했습니다. –