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
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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.