I have the following code in an action script (mouse clicked) in a list box.
If I use it as is, I see the correct string in SQLTag TempTag2. However, if I use “index1” rather than “index2” in the “query = …” statement, I get an error.
Selected_Index is an integer dynamic property containing the Selected Index property from a list box.
TempTag1 and TempTag2 are string tags.
It appears that the “indexX” value is getting cast to string when it goes through TempTag1, but not cast correctly if it goes directly to the “query =…” instruction.
Is this the correct conclusion, or is something else going on? Thanks.
Your conclusion was spot-on. You can’t use the “+” operator to concatenate a string and an integer in Python. You could have cast the int to a string to make the concatenation work, like this:
Also notice that I switched the double-quotes inside your SQL query to single quotes. You don’t use double quotes to quote literal strings in SQL. MySQL might let you get away with it, but its a habit that will come back to haunt you if you ever switch databases.