Re: syntax question

From: Date: Mon, 26 Mar 2007 15:05:20 +0000
Subject: Re: syntax question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-251371@lists.php.net to get a copy of this message
Ross wrote:
Can I put post values directly into insert statements? $query = "INSERT INTO categories (category_name) VALUES ('$_POST['cat_name'])"; Yes, although this is not recommended.
What is someone puts a single quote in there? Or some other bad characters.... otherwise... 2 options: $query = "INSERT INTO categories (category_name) VALUES ('".$_POST['cat_name']."')"; -or- $query = "INSERT INTO categories (category_name) VALUES ('{$_POST['cat_name']}')"; -Brad

« previous php.general (#251371) next »