0
I’m passing a PHP project I did on the local server to a paid server. When I was only using the location of my machine, everything worked. However, when I passed the whole program to the new server, the problem appeared. I am using the Postgresql database, and when trying to execute an INSERT command, to insert the data in the BD, appears the message that was registered but is not registered in the BD. The DELETE and UPDATE commands are working normally. Follow the code
$inserir = $pdo->prepare("INSERT INTO produtos values (nextval('produto_id_seq'::regclass),:nome, :preco,:tipo, :imagem, :medida, :observacao);");
$inserir->bindParam(':nome', $nomeprod, PDO::PARAM_STR);
$inserir->bindParam(':preco', $preco, PDO::PARAM_STR);
$inserir->bindParam(':tipo', $tipo, PDO::PARAM_STR);
$inserir->bindParam(':imagem', $novoNome, PDO::PARAM_STR);
$inserir->bindParam(':medida', $medida, PDO::PARAM_STR);
$inserir->bindParam(':observacao', $observacao, PDO::PARAM_STR);
$inserir->execute();
Do
if(!$inserir->execute()){ print_r($stmt->errorInfo()); }
and see if any error appears, if yes edit the question and add it :)– rray
Not even an error appeared putting this line of code.
– JerryMoon
If you run this insert directly in the error production bank?
– rray
I already tested an INSERT with data ready and when running in the database it worked perfectly, after that, I copied the same INSERT to test by the program, and the error continued.
– JerryMoon
Ah, now the error has appeared, it was the following
Array([0] => 42501 [1] => 7[2] => ERRO : permissão negada para sequência produto_id_seq)
@rray– JerryMoon
I would try to solve it this way first, instead of
nextval()
send anull
if not sure would check the issue of Quenquence’s permission. At least now have an error to fix :)– rray
I set the null and the following appeared
erro: valor nulo na coluna "id_produto" viola a restrição não-nula
@rray– JerryMoon
If you specify the column names with the respective values and of course do not include the
id_produto
?– rray
When doing this, the initial error returns. (permission denied for sequence)
– JerryMoon
you are using pgAdmin or phpPgAdmin? can give permission in Quence there?
– rray
I also thought about it, I was going through the permissions and apparently there is only permission for UPDATE and SELECT, I just contacted the provider to release the permission. If it works, I return here to report. Thank you for your attention
– JerryMoon