yuso6363 Posted October 8, 2010 Share Posted October 8, 2010 I am trying to make a page on my virtual pet site where you can breed your pets to get cute mini ones. At the moment I can't get it to get the stuff from the pet database and I have been doing it for three days... <?php $rank_check = 1; $page_title = "Under Construction"; include "header.inc.php"; echo $openHTML; ECHO <<<END <?php $query = "SELECT * FROM user_pets2 WHERE inrelationship = '0' AND gender = 'male' AND owner = '$userid'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo "Pet Name:"; echo $row[name]. " Level: ". $row[level]; echo "<br>"; <br> } ?> END; echo $closeHTML; ?> Link to comment https://forums.phpfreaks.com/topic/215448-help-with-pet-breeding/ Share on other sites More sharing options...
BlueSkyIS Posted October 8, 2010 Share Posted October 8, 2010 why is there ECHO <<<END and END? Those probably should not be in there. once you remove them, also remove the extra <?php and ?> around the query and loop/echo section. Link to comment https://forums.phpfreaks.com/topic/215448-help-with-pet-breeding/#findComment-1120344 Share on other sites More sharing options...
yuso6363 Posted October 8, 2010 Author Share Posted October 8, 2010 I get an error when I do that... Link to comment https://forums.phpfreaks.com/topic/215448-help-with-pet-breeding/#findComment-1120346 Share on other sites More sharing options...
Pikachu2000 Posted October 8, 2010 Share Posted October 8, 2010 Why are you using heredoc syntax for a database query? $openhtml and $closehtml appear to be undefined, also. Link to comment https://forums.phpfreaks.com/topic/215448-help-with-pet-breeding/#findComment-1120348 Share on other sites More sharing options...
Oziam Posted October 9, 2010 Share Posted October 9, 2010 I assume the header.inc.php file contains the database connection and data for $openHTML and $closeHTML? Its hard to tell whats happening without knowing the openHTML and closeHTML output but try something like; <?php $rank_check = 1; $page_title = "Under Construction"; include "header.inc.php"; $query = "SELECT * FROM user_pets2 WHERE inrelationship = '0' AND gender = 'male' AND owner = '$userid'"; $result = mysql_query($query) or die(mysql_error()); $rows= null; while($a = mysql_fetch_array($result)){ $rows .= "Pet Name: $a[name] - Level: $a[level]<br />\n"; } echo $openHTML; echo $rows."<br />\n"; echo $closeHTML; exit; ?> Link to comment https://forums.phpfreaks.com/topic/215448-help-with-pet-breeding/#findComment-1120442 Share on other sites More sharing options...
yuso6363 Posted October 9, 2010 Author Share Posted October 9, 2010 Yep, I just repeated it for the female pets and it works! I still need to add the extra pages to check it so you guys will probably be hearing more from me! Link to comment https://forums.phpfreaks.com/topic/215448-help-with-pet-breeding/#findComment-1120492 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.