2
I am trying to save information in my database with the following functions:
$sql = $request[0];
$query = $this->conn->prepare($sql);
$query->execute();
var_dump of $sql:
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 executing the code returns me the following error:
"You have an error in your SQL syntax; check the manual that Corresponds to your Mysql server version for the right syntax to use near '' at line 1"
And I have no idea what might be going on, because if I put the value of $sql 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.
bin2hex return($sql):
494e5345525420494e544f20466f726e656365646f722028000072617a616f5f736f6369616c2c2000006e6f6d655f66616e74617369612c20000074656c65666f6e652c200000656d61696c2c2000007469706f5f666f726e656365646f722c2000006c6f6761646f75726f2c2000006e756d65726f2c20000062616972726f2c2000006365702c2000006369646164652c20000065737461646f2c20000070616973292056414c5545532028277465737465272c20276f7574726120636f697361272c2027333435393233393432333934272c20276d69676875656c406d69676875656c2e636f6d272c202730272c202772756120616c646d272c2027323131272c2027736466736466736466736466272c20273138382d35383532272c20276d6172696c6961272c202773756d207061756c6f272c20276272617a696c27293b