madness69 Posted December 13, 2012 Share Posted December 13, 2012 (edited) Hello there, im having some problem whit my php code, i cant display the data from my database, is there somethign missing or wrong? Here is the code: $con = mysql_connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } if(isset($_GET['id'])) { $id=$_GET['id']; mysql_select_db("db_name", $con); $result = mysql_query("SELECT * FROM comments WHERE article = '".$row['title']."' AND approved = 'YES'"); while($row = mysql_fetch_array($result)) { echo $row['name'] . " " . $row['email']; echo "<br />"; } } Edited December 13, 2012 by madness69 Quote Link to comment https://forums.phpfreaks.com/topic/271974-its-not-displaying-the-data-from-mysql/ Share on other sites More sharing options...
Jessica Posted December 13, 2012 Share Posted December 13, 2012 See the post in my signature. Quote Link to comment https://forums.phpfreaks.com/topic/271974-its-not-displaying-the-data-from-mysql/#findComment-1399245 Share on other sites More sharing options...
madness69 Posted December 13, 2012 Author Share Posted December 13, 2012 ..., thanks anyway, bye Quote Link to comment https://forums.phpfreaks.com/topic/271974-its-not-displaying-the-data-from-mysql/#findComment-1399247 Share on other sites More sharing options...
Barand Posted December 13, 2012 Share Posted December 13, 2012 $result = mysql_query("SELECT * FROM commentsWHERE article = '".$row['title']."' AND approved = 'YES'"); $row has not yet been assigned a value Quote Link to comment https://forums.phpfreaks.com/topic/271974-its-not-displaying-the-data-from-mysql/#findComment-1399248 Share on other sites More sharing options...
Hall of Famer Posted December 13, 2012 Share Posted December 13, 2012 Yeah, sorta seems that way to me too, what is $row['title']? Perhaps you should use this instead: $_GET['title'] Not sure if this helps though, it's difficult to help you unless we know what this $row['title'] is supposed to mean. Quote Link to comment https://forums.phpfreaks.com/topic/271974-its-not-displaying-the-data-from-mysql/#findComment-1399257 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.