Phaser Posted May 15, 2011 Share Posted May 15, 2011 Hi GuysI 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 $data2Any ideas? Link to comment Share on other sites More sharing options...
Developers Jos Posted May 15, 2011 Developers Share Posted May 15, 2011 $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 More sharing options...
Phaser Posted May 15, 2011 Author Share Posted May 15, 2011 (edited) 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 May 15, 2011 by Phaser Link to comment Share on other sites More sharing options...
Phaser Posted May 15, 2011 Author Share Posted May 15, 2011 Very strange, if I import the .txt file I get the error, but if I use the mysql tab window and paste the command in there it works any help much appreciated Link to comment Share on other sites More sharing options...
Developers Jos Posted May 15, 2011 Developers Share Posted May 15, 2011 Where does the " come from ...that is HTML. 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 More sharing options...
Phaser Posted May 15, 2011 Author Share Posted May 15, 2011 (edited) 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?EDITOk 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 2OK 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 May 15, 2011 by Phaser Link to comment Share on other sites More sharing options...
smartee Posted May 15, 2011 Share Posted May 15, 2011 Perhaps a semicolon at the end of each SQL statement? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now