I have a simple script to check if a particular field is already in the db. The field is taken from the registration form. The code is this:
if ($_POST != null) {
$partita_iva = $_POST['taxvat'];
$abspath = $_SERVER['DOCUMENT_ROOT'] . '/';
require_once $abspath . 'CANENERO/inc/pdo_statment.php';
$conn = PDO();
$query = "SELECT * FROM `customer_entity_varchar` WHERE `attribute_id` = 17 AND `value` LIKE '".$partita_iva."'";
$all_rows = countRow($query);
if( $all_rows > 0 ) {
header("location: http://test.fitoweb.com/partita-iva-gia-registrata");
$conn = null;
exit;
}
}
countRow gives the number of rows in a pdo statement.
I have a problem to make the query work. If i send the value inserted in the 'taxvat' field directly, i have always zero rows.
The attribute id 17 is for filtering the results that i need. If i omit the value $partita_iva the code works.
I think that the problem could be caused by the encoding of the variable maybe?
In the db the field is varchar(255) utf8_general_ci.
What can i do to make the query work?
Thank you