jmr3460 Posted July 9, 2009 Share Posted July 9, 2009 I just don't see what I am doing wrong. I am not getting any errors. My html is printing, my variables are not. Can someone tell me why? <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); $host = "localhost"; $user = "user"; $password = "password"; $db = "groupinfo"; $sql = "SELECT g.groupid,g.groupname,g.address,g.city,g.state FROM contact AS g INNER JOIN banner AS b USING ( groupid ) WHERE b.banner = '1'"; mysql_connect($host, $user, $password) or die(mysql_error()); mysql_select_db($db); $result = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_array($result));{ //I think these variables are not defined correctly $group = $row['groupname']; $address = $row['address']; $city = $row['city']; $state = $row['state']; $group_info = "<tr><td>$group</td><td>$address</td><td>$city</td><td>$state</td></tr>"; echo "<table>"; //the echo below produces prints"<tr><td></td><td></td><td></td><td></td></tr>" //none of the variables print echo $group_info; echo "</table>"; echo $group; } ?> Can someone point out the obvious? Link to comment https://forums.phpfreaks.com/topic/165302-solved-variable-not-printing/ Share on other sites More sharing options...
p2grace Posted July 9, 2009 Share Posted July 9, 2009 I'd start by making sure your array has data. print_r($row) within the while statement and see if the array has values. Link to comment https://forums.phpfreaks.com/topic/165302-solved-variable-not-printing/#findComment-871737 Share on other sites More sharing options...
jmr3460 Posted July 9, 2009 Author Share Posted July 9, 2009 OK I thought it would be obvious. I had a ; at the end of my mysql_fetch_array() before my curly bracket. Everything is working now. Thanks for the looksee. Link to comment https://forums.phpfreaks.com/topic/165302-solved-variable-not-printing/#findComment-871747 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.