How does {} affect a MySQL Query in PHP?

后端 未结 3 1671
孤独总比滥情好
孤独总比滥情好 2020-12-05 15:34

What is the difference between the following 2 queries?

mysql_query(\"UPDATE table SET name = \'$name\'\");

mysql_query(\"UPDATE table SET name = \'{$name}\         


        
3条回答
  •  粉色の甜心
    2020-12-05 16:08

    The curly braces "escape" the PHP variable and are not passed to MySQL. With a simple variable like $name it doesn't make a difference but with something like $user['name'] it does. So there is nothing different between the two queries you have posted in your question.

提交回复
热议问题