Jump to content

concatenation


Recommended Posts

Hi Guys

I am writing certain elements of an array to a text file, the text file is creating a mysql insert command like this

$line = "insert into tablename values('', '" & $data1 & "','" & $data2 & "')"

All works fine so far BUT mysql has some reserved words 'die' is one of them, the word it picked up on my data was diesel, so now I need to set the $data2 var to instead of being surrounded by 'data' it needs to be written from autoit like this "data" when its printed out, but as autoit uses "" for text and so does mysql I have a conflict, so I tried

$line = "insert into tablename values('', '" & $data1 & "',"" & $data2 & "")"

but autoit now sees the " as the end of its text, the data2 var is just printing $data2

Any ideas?

Link to comment
Share on other sites

  • Developers

$line = "insert into tablename values('', '" & $data1 & "',""" & $data2 & """)"
Or
$line = 'insert into tablename values("", "' & $data1 & '","' & $data2 & '")'

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thanks very much mate, works fine now in printing it out BUT just tried to import the contents to mysql and get this error

,"Di'

the word is Diesel_Powered

Any other way?

Edited by Phaser
Link to comment
Share on other sites

Where does the " come from ...that is HTML.

Yes I know, it doesn't pick it up when I copy and paste the Autoit output into the mysql command text box to insert it but when I try to just import from the Autoit txt file (same created command) it errors like that, obviousley it would be too time consuming to copy n paste its much easier to upload the txt file content into mysql, its looking more like a mysql issue than autoit, but thought someone here may know both languages, anyone?

EDIT

Ok just found something else, maybe my line of text is missing something, if I paste 1 entry into mysql it works if I copy 2 or more it fails, should my Autoit output file have something at the end that mysql is looking for so it know its the next line? what does it need?

EDIT 2

OK sorted, it needs to add ; at the end of the mysql insert command, I should have known that one though, thanks for the help anyway

Edited by Phaser
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...