mrt003003 Posted May 1, 2011 Share Posted May 1, 2011 Hi there i have a basic query that is simply not outputting, i just dont get it. Im pretty sure the query is sound. If you can spot anything wrong here please let me know. $colname_RecordSet1 = "-1"; if (isset($_SERVER['MM_Username'])) { $colname_RecordSet1 = (get_magic_quotes_gpc()) ? $_SERVER['MM_Username'] : addslashes($_SERVER['MM_Username']); } mysql_select_db($database_swb, $swb); $query_resultp = sprintf("SELECT PlayerName, PlanetName, Class1, Class2, Class3, Class4 FROM planet WHERE PlayerName = %s", GetSQLValueString($colname_RecordSet1, "text")); $resultp = mysql_query($query_resultp, $swb) or die(mysql_error()); $row_resultp = mysql_fetch_assoc($resultp); $totalRows_resultp = mysql_num_rows($resultp); <?php do { echo 'Class: '; echo $row_resultp['PlanetName']; echo $row_resultp['Class1']; echo $row_resultp['Class2']; echo $row_resultp['Class3']; echo $row_resultp['Class4']; ?> <?php } while ($row_resultp = mysql_fetch_assoc($resultp)); mysql_free_result($resultp); ?> Thanks Quote Link to comment https://forums.phpfreaks.com/topic/235281-query-not-outputting/ Share on other sites More sharing options...
fugix Posted May 1, 2011 Share Posted May 1, 2011 you do not receive any errors when this script is run? Quote Link to comment https://forums.phpfreaks.com/topic/235281-query-not-outputting/#findComment-1209053 Share on other sites More sharing options...
mrt003003 Posted May 1, 2011 Author Share Posted May 1, 2011 No errors at all and the only thing that is outputted is the echo 'Class: '; And only once. Quote Link to comment https://forums.phpfreaks.com/topic/235281-query-not-outputting/#findComment-1209055 Share on other sites More sharing options...
PaulRyan Posted May 1, 2011 Share Posted May 1, 2011 Try the following? $colname_RecordSet1 = "-1"; if (isset($_SERVER['MM_Username'])) { $colname_RecordSet1 = (get_magic_quotes_gpc()) ? $_SERVER['MM_Username'] : addslashes($_SERVER['MM_Username']); } mysql_select_db($database_swb, $swb); $query_resultp = sprintf("SELECT PlayerName, PlanetName, Class1, Class2, Class3, Class4 FROM planet WHERE PlayerName = %s", GetSQLValueString($colname_RecordSet1, "text")); $resultp = mysql_query($query_resultp, $swb) or die(mysql_error()); $totalRows_resultp = mysql_num_rows($resultp); <?php do { echo 'Class: '; echo $row_resultp['PlanetName']; echo $row_resultp['Class1']; echo $row_resultp['Class2']; echo $row_resultp['Class3']; echo $row_resultp['Class4']; ?> <?php } while ($row_resultp = mysql_fetch_assoc($resultp)); mysql_free_result($resultp); ?> Regards, PaulRyan. Quote Link to comment https://forums.phpfreaks.com/topic/235281-query-not-outputting/#findComment-1209059 Share on other sites More sharing options...
mrt003003 Posted May 1, 2011 Author Share Posted May 1, 2011 Hi Paul, i've tried and again notihng is outputted except for the echo 'Class: '; However there is a error notice now: Undefined variable: row_resultp :| Quote Link to comment https://forums.phpfreaks.com/topic/235281-query-not-outputting/#findComment-1209062 Share on other sites More sharing options...
PFMaBiSmAd Posted May 1, 2011 Share Posted May 1, 2011 It's highly unlikely you have a variable named - $_SERVER['MM_Username']. Have you echoed your query to see exactly what it contains? Are you developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON, so that all the php detected errors will be reported and displayed? And you should generally NOT use a do/while loop. It requires more code (you must setup the data before the loop.) Use a normal while(){} loop. Quote Link to comment https://forums.phpfreaks.com/topic/235281-query-not-outputting/#findComment-1209064 Share on other sites More sharing options...
wildteen88 Posted May 1, 2011 Share Posted May 1, 2011 Your query is failing because the username you're searching for doesn't exist. What is $_SERVER['MM_Username']? Should that not be $_SESSION['MM_Username']? Quote Link to comment https://forums.phpfreaks.com/topic/235281-query-not-outputting/#findComment-1209065 Share on other sites More sharing options...
mrt003003 Posted May 1, 2011 Author Share Posted May 1, 2011 OMG! yeah of course... Thank You Quote Link to comment https://forums.phpfreaks.com/topic/235281-query-not-outputting/#findComment-1209067 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.