Jump to content

Query not outputting


mrt003003

Recommended Posts

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 :)

Link to comment
https://forums.phpfreaks.com/topic/235281-query-not-outputting/
Share on other sites

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.