marklarah Posted January 18, 2008 Share Posted January 18, 2008 Probably elementary, but compared to you guys, I suck ass at php (im only a begginer) Im coding some forms, and on the page that displays the messages, I wan't the catagory, and the topic. I can echo the catagory fine, but the echoing the topic doesn't want to work: <?php if (isset($_GET['topic'])) { $boardB = $_GET['topic']; $loolo = 'SELECT * FROM topics WHERE ID = '.$boardB; $lolo = mysql_query($loolo) or die(mysql_error()); $rowob = mysql_num_rows($lolo); $titler = $rowob['Name']; if (isset($titler)){ echo "yup"; }else{ echo "nope"; } echo $boardB; echo $titler; } ?> It echoes nope and 1. The one is what it should be, and its definetly one in the DB and the title is correct and such. Help please? Quote Link to comment https://forums.phpfreaks.com/topic/86675-solved-mysql-php-problem-again/ Share on other sites More sharing options...
marklarah Posted January 18, 2008 Author Share Posted January 18, 2008 you can see it here: http://tls-3.com/genmessage.php?board=1&topic=1 you need to login though (use username: olive and password: olive) Quote Link to comment https://forums.phpfreaks.com/topic/86675-solved-mysql-php-problem-again/#findComment-442943 Share on other sites More sharing options...
GingerRobot Posted January 18, 2008 Share Posted January 18, 2008 Thats because $rowob contains the number of rows returned by the query, not an array of the returned row. I assume you meant: <?php if (isset($_GET['topic'])) { $boardB = $_GET['topic']; $loolo = 'SELECT * FROM topics WHERE ID = '.$boardB; $lolo = mysql_query($loolo) or die(mysql_error()); $rowob = mysql_fetch_assoc($lolo); $titler = $rowob['Name']; if (isset($titler)){ echo "yup"; }else{ echo "nope"; } echo $boardB; echo $titler; } ?> p.s. You should learn to indent your code - it'll save you a hell of a lot of time and hassle in the future. Quote Link to comment https://forums.phpfreaks.com/topic/86675-solved-mysql-php-problem-again/#findComment-442948 Share on other sites More sharing options...
marklarah Posted January 18, 2008 Author Share Posted January 18, 2008 'thanks....I wove you Quote Link to comment https://forums.phpfreaks.com/topic/86675-solved-mysql-php-problem-again/#findComment-442952 Share on other sites More sharing options...
Stooney Posted January 18, 2008 Share Posted January 18, 2008 You should also add mysql_real_escape_string for security. $boardB = mysql_real_escape_string($_GET['topic']); Quote Link to comment https://forums.phpfreaks.com/topic/86675-solved-mysql-php-problem-again/#findComment-442953 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.