• 0
Sign in to follow this  
Guest Eduardo Assis

Proteção Com Sql

Question

Guest Eduardo Assis

Tenho alguns inputs onde um usuario entra com dados

No SQL tenho:

Insert into tabela (campo1,campo2,campo3) values ('$campo1','$campo2','$campo3',);

O problema está no input quando o usuario digita:

D'Agua, ou outro dado qua tenha ' ou "

Como proteger para não dar erro de SQL ?

Abraços.

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Use addslashes().

Se magic_quotes_gpc estiver en on, automaticamente será adicionadas barras invertidas a dados vindos de formulários, por exemplo, então faça assim:

$campo = get_magic_quotes_gpc() ? $_POST['campo'] : addslashes ($_POST['campo']);

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this