I'm trying to save an information in my database with the following functions:
$sql = $request[0];
$query = $this->conn->prepare($sql);
$query->execute();
$ sql var_dump:
string(322) "INSERT INTO Fornecedor (razao_social, nome_fantasia, telefone,
email, tipo_fornecedor, logadouro, numero, bairro, cep, cidade, estado,
pais) VALUES ('teste', 'outra coisa', '345923942394',
'[email protected]', '0', 'rua aldm', '211', 'sdfsdfsdfsdf', '188-5852',
'marilia', 'sum paulo', 'brazil');"
However, when the code is executed I get the following error:
"You have an error in your SQL syntax; check the manual that correspond to your MySQL server version for the right syntax to use near '' at line 1 "
And I have no idea what might be happening, because if I put the $ sql value inside the prepare function, like this:
$query = $this->conn->prepare("INSERT INTO Fornecedor (razao_social,
nome_fantasia, telefone, email, tipo_fornecedor, logadouro, numero, bairro,
cep, cidade, estado, pais) VALUES ('teste', 'outra coisa', '345923942394',
'[email protected]', '0', 'rua aldm', '211', 'sdfsdfsdfsdf', '188-5852',
'marilia', 'sum paulo', 'brazil');");
It saves information normally.
return bin2hex ($ sql):
494e5345525420494e544f20466f726e656365646f722028000072617a616f5f736f6369616c2c2000006e6f6d655f66616e74617369612c20000074656c65666f6e652c200000656d61696c2c2000007469706f5f666f726e656365646f722c2000006c6f6761646f75726f2c2000006e756d65726f2c20000062616972726f2c2000006365702c2000006369646164652c20000065737461646f2c20000070616973292056414c5545532028277465737465272c20276f7574726120636f697361272c2027333435393233393432333934272c20276d69676875656c406d69676875656c2e636f6d272c202730272c202772756120616c646d272c2027323131272c2027736466736466736466736466272c20273138382d35383532272c20276d6172696c6961272c202773756d207061756c6f272c20276272617a696c27293b