Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

205
Vistas
Inserting a variable into MySQL with Go

I have these 2 variables here

name := request.FormValue("username")
pass := request.FormValue("password")

I want to insert those 2 variables into my database

db.Query("INSERT INTO `godb` (`Username`, `Password`) VALUES (   )")

I tried (name,pass) ('name','pass') ($name, $pass) , none of them work.

Hope the question is not stupid, but I've been looking for solutions online but I did't understand them. Thanks !

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

From Using Prepared Statements

Parameter Placeholder Syntax

The syntax for placeholder parameters in prepared statements is database-specific. For example, comparing MySQL, PostgreSQL, and Oracle:

MySQL               PostgreSQL            Oracle
=====               ==========            ======
WHERE col = ?       WHERE col = $1        WHERE col = :col
VALUES(?, ?, ?)     VALUES($1, $2, $3)    VALUES(:val1, :val2, :val3)

You tried PostgreSQL syntax but you use MySQL.

over 4 years ago · Santiago Trujillo Denunciar

0

query should be in this format db.Query("INSERT INTO table ($1, $2) VALUES (column1, column2)", value1, value2) in your case something like that db.Query("INSERT INTO godb ($1, $2) VALUES (username, password)", name, pass)

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda