MySQL Database Help?

Hi my name is Brady and I am sort of a newbie with MySQL. I have been working all night just to get a basic MySGL database to work! I need a system where you insert your own variables and once inserted it emails those variables to an email account… Is there anyway to do this? Can anyone give me some code to help or shoot me a link to a tutorial?

Thanks Guys!

Brady E. Pennington CEO of LongSword Entertainment


http://www.longswordentertainment.com/

Btw here is the code I have so far.

display.setStatusBar( display.HiddenStatusBar )

local halfW = display.viewableContentWidth / 2

local halfH = display.viewableContentHeight / 2

local backgroundPortrait = display.newImage( “bgp.jpg”, halfW, halfH )

local backgroundLandscape = display.newImage( “bgl.jpg”, halfH - 80, halfW + 80 )

backgroundLandscape.isVisible = false

local background = backgroundPortrait

local backgroundOrientation = function( event )

local delta = event.delta

if ( delta ~= 0 ) then

local rotateParams = { rotation=-delta, time=500, delta=true }

if ( delta == 90 or delta == -90 ) then

local src = background

background = ( backgroundLandscape == background and backgroundPortrait ) or backgroundLandscape

background.rotation = src.rotation

transition.dissolve( src, background )

transition.to( src, rotateParams )

else

assert( 180 == delta or -180 == delta )

end

transition.to( background, rotateParams )

end

end

Runtime:addEventListener( “orientation”, backgroundOrientation )

local sqlite3 = require( “sqlite3” )

local path = system.pathForFile( “data.db”, system.DocumentsDirectory )

local db = sqlite3.open( path )   

local function onSystemEvent( event )

    if ( event.type == “applicationExit” ) then              

        db:close()

    end

end

local tablesetup = [[CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, content, content2);]]

print( tablesetup )

db:exec( tablesetup )

local testvalue = {}

testvalue[1] = “Hello”

testvalue[2] = “World”

testvalue[3] = “Lua”

local tablefill = [[INSERT INTO test VALUES (NULL, ‘]]…testvalue[1]…[[’,’]]…testvalue[2]…[[’);]]

local tablefill2 = [[INSERT INTO test VALUES (NULL, ‘]]…testvalue[2]…[[’,’]]…testvalue[1]…[[’);]]

local tablefill3 = [[INSERT INTO test VALUES (NULL, ‘]]…testvalue[1]…[[’,’]]…testvalue[3]…[[’);]]

db:exec( tablefill )

db:exec( tablefill2 )

db:exec( tablefill3 )

print( "SQLite version " … sqlite3.version() )

for row in db:nrows(“SELECT * FROM test”) do

    local text = row.content … " " … row.content2

    local t = display.newText( text, 50, 20*row.id, nil, 16 )

    t:setFillColor( 255, 255, 255 )

end

Runtime:addEventListener( “system”, onSystemEvent )

Btw here is the code I have so far.

display.setStatusBar( display.HiddenStatusBar )

local halfW = display.viewableContentWidth / 2

local halfH = display.viewableContentHeight / 2

local backgroundPortrait = display.newImage( “bgp.jpg”, halfW, halfH )

local backgroundLandscape = display.newImage( “bgl.jpg”, halfH - 80, halfW + 80 )

backgroundLandscape.isVisible = false

local background = backgroundPortrait

local backgroundOrientation = function( event )

local delta = event.delta

if ( delta ~= 0 ) then

local rotateParams = { rotation=-delta, time=500, delta=true }

if ( delta == 90 or delta == -90 ) then

local src = background

background = ( backgroundLandscape == background and backgroundPortrait ) or backgroundLandscape

background.rotation = src.rotation

transition.dissolve( src, background )

transition.to( src, rotateParams )

else

assert( 180 == delta or -180 == delta )

end

transition.to( background, rotateParams )

end

end

Runtime:addEventListener( “orientation”, backgroundOrientation )

local sqlite3 = require( “sqlite3” )

local path = system.pathForFile( “data.db”, system.DocumentsDirectory )

local db = sqlite3.open( path )   

local function onSystemEvent( event )

    if ( event.type == “applicationExit” ) then              

        db:close()

    end

end

local tablesetup = [[CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, content, content2);]]

print( tablesetup )

db:exec( tablesetup )

local testvalue = {}

testvalue[1] = “Hello”

testvalue[2] = “World”

testvalue[3] = “Lua”

local tablefill = [[INSERT INTO test VALUES (NULL, ‘]]…testvalue[1]…[[’,’]]…testvalue[2]…[[’);]]

local tablefill2 = [[INSERT INTO test VALUES (NULL, ‘]]…testvalue[2]…[[’,’]]…testvalue[1]…[[’);]]

local tablefill3 = [[INSERT INTO test VALUES (NULL, ‘]]…testvalue[1]…[[’,’]]…testvalue[3]…[[’);]]

db:exec( tablefill )

db:exec( tablefill2 )

db:exec( tablefill3 )

print( "SQLite version " … sqlite3.version() )

for row in db:nrows(“SELECT * FROM test”) do

    local text = row.content … " " … row.content2

    local t = display.newText( text, 50, 20*row.id, nil, 16 )

    t:setFillColor( 255, 255, 255 )

end

Runtime:addEventListener( “system”, onSystemEvent )