Answer the question
In order to leave comments, you need to log in
How to insert a variable in mysql query, which value is text?
Hello. My site sends the word " lux " to the php file.
Its php meets it like this:
$nnomer = $_POST['nnomer']; // то самое слово lux
$query = "SELECT datestart, dateend FROM main WHERE namenomer = '$nnomer'";
Answer the question
In order to leave comments, you need to log in
You should never write queries this way, because it is a direct road to SQL injection . It would be better to arrange something like
$pdo = new PDO( /* параметры соединения с БД */ );
$result = $pdo->prepare( 'SELECT datestart, dateend FROM main WHERE namenomer = :namenomer' );
$result->execute( array(
':namenomer' => empty( $_POST[ 'nnomer' ] ) ? '' : $_POST[ 'nnomer' ]
) );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question