miligraf Posted April 28, 2006 Share Posted April 28, 2006 Hello, i have a click counter that works with a link like this: [b]http://www.yourdomain.com/tutorial.php?id=1[/b] But when i click the link it takes me to that URL and not to the one saved in the SQL table, so i guess its the [b]tutorial.php[/b]. Ive been trying to make it work but i cant :(tutorial.php[code]<?include ('conbd.php');$query = mysql_query ("SELECT * FROM tutoriales WHERE id='$id'");while ($row = mysql_fetch_row($query)){$id = $row[0];$enlace = $row[5];header('Location: '.$enlace);}mysql_query ("UPDATE tutoriales SET clics = clics + 1 WHERE id='$id'");?>[/code]Thanks for your help! Quote Link to comment Share on other sites More sharing options...
Orio Posted April 29, 2006 Share Posted April 29, 2006 Add this after the include:$id=$_GET['id'];Btw, read about SQL injections, because your script is unsecure.Orio. Quote Link to comment Share on other sites More sharing options...
miligraf Posted April 30, 2006 Author Share Posted April 30, 2006 Negative Orio, still doesnt work :-(And thx for the suggestion!I would also like an easy-to-learn php manual, so i will have a better sense on figuring php things out, ty. Quote Link to comment Share on other sites More sharing options...
Brandon Jaeger Posted April 30, 2006 Share Posted April 30, 2006 Injection proof:[code]$id = $row[0];$enlace = $row[5];$id = mysql_escape_string(striptags($id));$enlace = mysql_escape_string(striptags($enlace));[/code] Quote Link to comment Share on other sites More sharing options...
Orio Posted April 30, 2006 Share Posted April 30, 2006 Maybe its the:mysql_query ("UPDATE tutoriales SET clics = clics + 1 WHERE id='$id'");Thats got to be-$newclics=$clics+1;mysql_query ("UPDATE tutoriales SET clics='$newclics' WHERE id='$id'");Orio. Quote Link to comment Share on other sites More sharing options...
miligraf Posted April 30, 2006 Author Share Posted April 30, 2006 Doesnt work either...ive checked the other php where you click the link but it works fine, its this [b]tutorial.php[/b] that isnt working, it doesnt add the click or redirects you to the URL stored in the database. I dunno what happened, it was working fine before but now it doesnt.Edit: i already figured out the problem, thx for your help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.