Rosst Posted July 6, 2006 Share Posted July 6, 2006 OK, I will get straight to the point, I made a tutorial system, and when I went to my second tutorial I saw the first one, see the links: http://vexxon.net/index.php?id=tuts&cat=PHP&tutid=2, anyway here is my code:[code]<?phpinclude('config.php'); // connect to databaseinclude('includes/bbcode.php');if ($_GET['cat']) {if ($_GET['tutid']) {$tutid = $_GET['tutid'];$cat = $_GET['cat'];$query = mysql_query("SELECT * FROM tutorial where id = '$tutid' & tut_type = '$cat'");$r = mysql_fetch_array($query);echo "<table border=\"0\"><tr><td>".$r[tut_name]."</td><td>By ".$r[user]."</tr><tr><td>".$r[tut_desc]."</td></tr><tr><td>".bbcode($r[tut])."</td></tr></table>";}else {$acat = $_GET['cat'];$query1 = mysql_query("SELECT * FROM tutorial where tut_type = '$acat'");if (mysql_num_rows($query1) == 0) {echo "No tutorials in this category";}else {echo "<table border=\"0\">";while($s = mysql_fetch_array($query1)) {echo "<tr><td><a href=\"index.php?id=tuts&cat=".$s[tut_type]."&tutid=".$s[id]."\">".$s[tut_name]."</td><td>By <a href=\"index.php?id=memb&user=".$s[user]."\">".$s[user]."</a></td></tr>";}echo "</table>";}}}else {$query2 = mysql_query("SELECT * FROM tutorialcats");echo "<table border=\"0\">";while($t = mysql_fetch_array($query2)) {echo "<tr><td>- <a href=\"index.php?id=tuts&cat=".$t['name']."\">".$t['name']."</td></tr>";}echo "</table>";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13904-tutorial-system-problem/ Share on other sites More sharing options...
underparnv Posted July 6, 2006 Share Posted July 6, 2006 Change your query to this:[code]<?php$query = mysql_query("SELECT * FROM tutorial WHERE id = $tutid AND tut_type = '$cat'");?>[/code]Enjoy! Quote Link to comment https://forums.phpfreaks.com/topic/13904-tutorial-system-problem/#findComment-54155 Share on other sites More sharing options...
Rosst Posted July 7, 2006 Author Share Posted July 7, 2006 Thanks, it worked! Quote Link to comment https://forums.phpfreaks.com/topic/13904-tutorial-system-problem/#findComment-54189 Share on other sites More sharing options...
Daniel0 Posted July 7, 2006 Share Posted July 7, 2006 You would have to use [url=http://php.net/intval]intval[/url] or [url=http://php.net/mysql_real_escape_string]mysql_real_escape_string[/url] on the variable $tutid if you choose not to enclose the value in quotes in the query to ensure that people to not exploit your code inject another query the initial query. Quote Link to comment https://forums.phpfreaks.com/topic/13904-tutorial-system-problem/#findComment-54314 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.