php - Can't replace table name with variable in SQL query -


i've little problem. here request ( work ):

 $reponse = $bdd->prepare('select * student username = ? , password = ? ');  $reponse->execute(array($name,$pass)); 

it's work when want replace 'student' php variable it's doesn t works :/ :

 $table="stackoverflow"  $reponse = $bdd->prepare('select * '$table' username = ? , password = ? ');  $reponse->execute(array($name,$pass)); 

have idea ? more simple if can replace table name variable. sorry bad english. time spend me.

in php, join 2 strings or variables period character (.).

therefore, concatenate table name , statements before , after table name, should changing line

$reponse = $bdd->prepare('select * '$table' username = ? , password = ? '); 

to

$reponse = $bdd->prepare('select * '.$table.' username = ? , password = ? '); 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -