MarioApprentice Posted January 30, 2013 Share Posted January 30, 2013 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", "izmisljeni_mail@gmail.com", PDO::PARAM_STR); $st->execute(); } catch(PDOException $e) { throw new Exception("Statement not executed " . $e->getMessage()); } } Quote Link to comment https://forums.phpfreaks.com/topic/273836-bindvalue-problem/ Share on other sites More sharing options...
kicken Posted January 30, 2013 Share Posted January 30, 2013 You can't use parameters for table names. Parameters are only valid for values. Quote Link to comment https://forums.phpfreaks.com/topic/273836-bindvalue-problem/#findComment-1409198 Share on other sites More sharing options...
MarioApprentice Posted January 30, 2013 Author Share Posted January 30, 2013 thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/273836-bindvalue-problem/#findComment-1409199 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.