php - Pass the variable in regular expression within heredoc (MYSQL) -



php - Pass the variable in regular expression within heredoc (MYSQL) -

i got parse error. passed variable in regular look within heredoc mysql query expression?

$sql = <<<sql select name, full_code m_category full_code regexp '^00'.$var.'[0-9][0-9][0-9]$' order full_code asc sql;

originally code was

$sql = " select name, full_code m_category full_code regexp '^00".$var."[0-9][0-9][0-9]$' order full_code asc";

$sql = <<<sql select name, full_code m_category full_code regexp '^00{$var}[0-9][0-9][0-9]$' order full_code asc sql;

please, read heredoc: http://php.net/manual/ru/language.types.string.php#language.types.string.syntax.heredoc

php mysql

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -