How can I read mysql data in a variable

Codes here !

Moderators: macek, egami, gesf

bram
New php-forum User
New php-forum User
Posts: 3
Joined: Thu Jan 02, 2003 1:30 am

How can I read mysql data in a variable

Postby bram » Thu Jan 02, 2003 1:37 am

Dear ,

I have search a lot about a way to read data from a mysql database in a bash variable but find no solution, i hope someone can help me with this?
i connect in bash to mysql:

mysql -uroot -pPassword -DtblTable -e "select groeps from yblTable;"

I need the result of this select query in a variable groeps($groeps).

kind regards,

bram

jemy
New php-forum User
New php-forum User
Posts: 6
Joined: Thu Jan 02, 2003 5:27 am
Location: Munich / Germany

bash variable

Postby jemy » Thu Jan 02, 2003 8:40 am

hi,

is that right?
You are looking for a bash script, which takes a variable out of mysql...
Something like that, maybe:

#!/bin/sh
# database test

test1=(`mysql -uroot -pPassword -DtblTable -e "select groeps from yblTable;"``)
echo
echo "${test1[1]}"
echo

bram
New php-forum User
New php-forum User
Posts: 3
Joined: Thu Jan 02, 2003 1:30 am

Re: bash variable

Postby bram » Thu Jan 02, 2003 9:03 am

:) Thanks Jamy!

It works!

kind regards,

bram


Return to “mySQL & php coding”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest