AngelS 0 Posted April 1, 2011 Report Share Posted April 1, 2011 Boas... Estou a fazer um site em php , mas no meu alterar, dá-me um erro ao qual não sei a solução... <?php require_once('ligacao.php'); $ref_calc=$_GET['ref_calc']; $query_calcs = "SELECT * FROM calcs where ref_calc='$ref_calc'"; $calcs = mysql_query($query_calcs) or die(mysql_error()); $row_calcs = mysql_fetch_assoc($calcs); $totalRows_calcs = mysql_num_rows($calcs); ?> Penso que esta parte do código é suficiente :S Agredecia ajuda... O erro é este: 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 'ref_calc']?>'' at line 1 Link to post Share on other sites
kareka 0 Posted April 1, 2011 Report Share Posted April 1, 2011 Verifica o nome da tabela e dos campos , se mesmo assim não der tenta o seguinte: <?php require_once('ligacao.php'); $ref_calc=$_GET['ref_calc']; $query_calcs = "SELECT * FROM calcs where ref_calc=".$ref_calc; $calcs = mysql_query($query_calcs) or die(mysql_error()); $row_calcs = mysql_fetch_assoc($calcs); $totalRows_calcs = mysql_num_rows($calcs); ?> <?php include("assinatura.txt"); ?> Link to post Share on other sites
AngelS 0 Posted April 1, 2011 Author Report Share Posted April 1, 2011 Fiz isso e o erro passou a ser: 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 Link to post Share on other sites
kareka 0 Posted April 1, 2011 Report Share Posted April 1, 2011 Mostra-me a tua tabela . <?php include("assinatura.txt"); ?> Link to post Share on other sites
AngelS 0 Posted April 1, 2011 Author Report Share Posted April 1, 2011 No eliminar dá-me o mesmo erro e não tenho tabelas :s <?php require_once('ligacao.php'); $ref_calc=$_GET['ref_calc']; $query_calcs = "delete FROM calcs where ref_calc='$ref_calc'"; $calcs = mysql_query($query_calcs) or die(mysql_error()); ?> <script> location.href= "ads.php"; </script> Link to post Share on other sites
kareka 0 Posted April 1, 2011 Report Share Posted April 1, 2011 Não tens tabelas ? Como assim ? <?php include("assinatura.txt"); ?> Link to post Share on other sites
AngelS 0 Posted April 1, 2011 Author Report Share Posted April 1, 2011 Tenho tabelas... Mas no eliminar também dá esse erro e não tem as tabelas ... Link to post Share on other sites
kareka 0 Posted April 1, 2011 Report Share Posted April 1, 2011 O campo de que tipo é ? Tenta um LIKE em vez '=' , não estou a ver qual é o problema mesmo . <?php include("assinatura.txt"); ?> Link to post Share on other sites
AngelS 0 Posted April 1, 2011 Author Report Share Posted April 1, 2011 varchar :s Link to post Share on other sites
kareka 0 Posted April 1, 2011 Report Share Posted April 1, 2011 Mesmo com o LIKE não funcionou ? <?php include("assinatura.txt"); ?> Link to post Share on other sites
softklin 11 Posted April 1, 2011 Report Share Posted April 1, 2011 Tenta fazer o seguinte, e verifica se a tua query está correcta: require_once('ligacao.php'); $ref_calc=$_GET['ref_calc']; $query_calcs = "SELECT * FROM calcs where ref_calc='$ref_calc'"; var_dump($query_calcs); $calcs = mysql_query($query_calcs) or die(mysql_error()); A query vai ser mostrada na página, e podes procurar por erros de sintaxe nela. BTW, deves escapar convenientemente os valores vindos do utilizador. No teu exemplo, atribuis o valor do utilizador directamente na query, que pode levar a falhas de segurança de SQL Injection. Uma solução rápida passa por substituir essa linha de atribuição por: $ref_calc = mysql_real_escape_string($_GET['ref_calc']); Nick antigo: softclean | Tens um projeto? | Wiki P@P Ajuda a comunidade! Se encontrares algo de errado, usa a opção "Denunciar" por baixo de cada post. Link to post Share on other sites
Fabricio 0 Posted April 1, 2011 Report Share Posted April 1, 2011 caso nada disso der certo poste seu formulario de inserir e o codigo no pate bin Alguem tem o Código Fonte da Vida ? Link to post Share on other sites
AngelS 0 Posted April 2, 2011 Author Report Share Posted April 2, 2011 Problema resolvido ! Era um problema na configuração do wamp Link to post Share on other sites
scorch 12 Posted April 2, 2011 Report Share Posted April 2, 2011 Não se esqueçam de marcar os tópicos como resolvidos. PS: Não respondo a perguntas por mensagem que podem ser respondidas no fórum. Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now