Jump to content

PDO sterilization


cmb

Recommended Posts

I'm letting the admin users be able to create tables for polls and this is the query i have:

$aquery = $con->prepare("ALTER TABLE `$table` ADD `$field` $enum DEFAULT '$def' NOT NULL");

the $table and $enum fields are both coming from another table so they are safe, but the $def and $field variables are both coming from the user. How can i check to be sure they are safe to use. I've tried this

$aquery->bindParam(':field', $field);
$aquery->bindParam(':def', $def);

but that doesn't work

Link to comment
https://forums.phpfreaks.com/topic/273867-pdo-sterilization/
Share on other sites

You need to properly normalize your data, so that the answers are a row in a table of their own. Then associate them to the poll, by using a many-to-many relationship.

Search the net for more information, and tutorials, on how to accomplish this.

Link to comment
https://forums.phpfreaks.com/topic/273867-pdo-sterilization/#findComment-1409466
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.