Jump to content

bindValue() problem


MarioApprentice

Recommended Posts

Hello everybody. I have a problem with an sql query and would be gratefull for some help.

 

I can't get this to work. I tried the INSERT command on the shell and it works just fine but here, it gives me the 1064 error which is a syntax error. To get things wirder, the first call to bindValue(), the one that binds ":table_name" and "korisnicki_podaci" works, but the subsequent don't.

 

Thank you in advance for any kind of help

 

private static $_sqlRegistration = "INSERT INTO :tableName(ime, prezime, nadimak, lozinka, mail, registracija)
							 VALUES(:name, :lastName, :username, :password, :e_mail, CURDATE())";

public static function userRegistration($conn)
{
 try
 {
	 $st = $conn->prepare(self::$_sqlRegistration);
	 $st->bindValue(":tableName", "korisnicki_podaci", PDO::PARAM_STR);
	 $st->bindValue(":name", "Marko", PDO::PARAM_STR);
	 $st->bindValue(":lastName", "Legenda", PDO::PARAM_STR);
	 $st->bindValue(":username", "Kreten", PDO::PARAM_STR);
	 $st->bindValue(":password", "digital", PDO::PARAM_STR);
	 $st->bindValue(":e_mail", "[email protected]", PDO::PARAM_STR);
	 $st->execute();
 }
 catch(PDOException $e)
 {
	 throw new Exception("Statement not executed " . $e->getMessage());
 }
}

Link to comment
https://forums.phpfreaks.com/topic/273836-bindvalue-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.