hi :)
I need some help for this script
I have
--------------------

cursor = conn.cursor()
cursor.execute("select * from playlist limit 5")
result = cursor.fetchall()
# iterate through resultset
playlist_txt = ''
for record in result:
 mp3id = record[0]
 mp3_title = record[1]
 mp3_artist = record[2]
 playlist_txt += mp3id + mp3_title + mp3_artist
 #print mp3id , " - ", mp3_title , ' - ', mp3_artist , "<br />"
cursor.close()
conn.close()

------------------
#and want to print this out of "for record in result:"

print playlist_txt

#but there is an error in

playlist_txt += mp3id + mp3_title + mp3_artist

10x in advance :)))

Can you give us the error message and a little more of your code?

Without that info, I don't know what your resultset looks like. I can only assume that mp3id could be an integer and needs to be converted to a string to work with the + concatination. In this case mp3id = str(record[0]) would do the trick.

10x for the help
I try with this and it work perfect :))

playlist_txt += str(mp3id) +  str(mp3_title) + str(mp3_artist) + '<br>'
#playlist_txt += "%s %s %s <br>" % (mp3id, mp3_title, mp3_artist)

Edited 3 Years Ago by Dani: Formatting fixed

This question has already been answered. Start a new discussion instead.