Data collection with php using mysqli_escape_string() function -
this question has answer here:
- php parse/syntax errors; , how solve them? 12 answers
i trying collect data user still getting error.
syntax error, unexpected 'name' (t_string).
here line of code producing error;
$name = mysqli_escape_string("$_post['name']");
$name = mysqli_escape_string("$_post['name']");
there 2 issues here.
first, function requires db connection passed first parameter, , other being quotes.
here proper syntax, , assuming indeed using mysqli_
connect with.
$name = mysqli_escape_string($connection, $_post['name']);
if not, use mysql_
equivalent
$name = mysql_escape_string($_post['name']);
or
$name = mysql_escape_string($_post['name'], $connection);
mysqli_escape_string
alias of mysqli_real_escape_string
may need change that, or mysql_real_escape_string
if db connection mysql_
or mysqlireal_escape_string
if connecting using mysqli_
.
- different mysql apis not intermix.
read documentation:
mysqli_escape_string — alias of mysqli_real_escape_string()
this function alias of: mysqli_real_escape_string().
string mysqli_real_escape_string ( mysqli $link , string $escapestr )
Comments
Post a Comment