variable into mysql

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Theoleen
Posts: 2
Joined: Tue May 20, 2014 4:09 pm

variable into mysql

Post by Theoleen » Wed May 21, 2014 8:00 am

I am a newby so
i want to update or search a record in mysql.
if i put in something like SELECT * FROM table WHERE score=12 or name="theo" it works ; score and name are columns in mysql
But i want to ask the input first, put it into a variable, how do i put the content of that variable in mysql?

theo

Klaus
Posts: 14205
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: variable into mysql

Post by Klaus » Wed May 21, 2014 10:47 am

Hi Theo,

1. welcome to the forum! :D

2. You need to build the correct string!
Example:
...
put 12 into tNumber
put "SELECT * FROM table WHERE score=" & tNumber into tSQL
...
Check this thread about exactly this topic:
http://forums.runrev.com/phpBB2/viewtop ... 12&t=20360


Best

Klaus

Theoleen
Posts: 2
Joined: Tue May 20, 2014 4:09 pm

Re: variable into mysql

Post by Theoleen » Tue May 27, 2014 8:24 pm

Thanks for your reply
That works with a digit into tNumber but not if i put a text into tNumber.
I want to search for a record of a person by asking his name. Then search for the record.


theo

Klaus
Posts: 14205
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: variable into mysql

Post by Klaus » Tue May 27, 2014 8:43 pm

Hi Theo,

why did you not take a look at the thread I posted? :shock:
You really should do!

This is what I wrote there:
...
put field "saisie" into champsaisie
put "INSERT into informations_table VALUES ('" & champsaisie & "');" into tSQL
...

This is just an example, but I am sure you can change this to the SELECT statement
for your needs 8)


Best

Klaus

Post Reply