table is long but only looking at two fields here
UserID int unsigned not null auto_increment
CurrentDB char(50)
LoginHash char(50)
userinfo is a struct with two fields:
type user struct {
UserID int `json:"userid"`
CurrentDB NullString `json:"currentdb"`
}
Code that works:
var1 := req.URL.Query().Get("hash")
query := "select UserID, CurrentDB from optUsers where LoginHash='" + var1 + "'"
row := db.QueryRow( query );
row.Scan(&userinfo.UserID, &userinfo.CurrentDB)
Code that doesn’t work:
queryuser, err = db.Prepare("select UserID, CurrentDB from optUsers where LoginHash = ?")
var1 := req.URL.Query().Get("hash")
row := queryuser.QueryRow( var1 )
row.Scan(&userinfo.UserID, &userinfo.CurrentDB)
There is no real purpose in this call btw: Just trying to write a simple test in go to get my head wrapped around all the processes. I’m considering writing a huge PHP application in go in the future and just using this program to work out the details.