mrt003003 Posted June 1, 2011 Share Posted June 1, 2011 Hi there i keep getting an error: Notice: Undefined index: ShipYard in C:\wamp\www\SWB2\test3.php on line 160 Heres the relevant select query: // COUNT SHIPYARDS $colname_shipyard = 'Empire'; mysql_select_db($database_swb, $swb); $query_shipyard = sprintf("SELECT SUM(ShipYard) FROM planet WHERE PlayerName = %s", GetSQLValueString($colname_shipyard, "text")); $shipyard = mysql_query($query_shipyard, $swb) or die(mysql_error()); $row_shipyard = mysql_fetch_assoc($shipyard); $totalRows_shipyard = mysql_num_rows($shipyard); The error is pointing to: echo $row_shipyard['ShipYard']; Im a bit of a noob and have tried changing to: echo $row['ShipYard']; When i do this i get a different error: Notice: Undefined variable: row in C:\wamp\www\SWB2\test3.php on line 159 The row ShipYard is in a table called planet but its not suppose to be indexed or unique. Am I missing something here?? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/238135-undefined-index/ Share on other sites More sharing options...
mrt003003 Posted June 1, 2011 Author Share Posted June 1, 2011 Fixed it! I forgot to add the: $query_shipyard = sprintf("SELECT SUM(ShipYard) AS shipyard_total FROM planet THanks Quote Link to comment https://forums.phpfreaks.com/topic/238135-undefined-index/#findComment-1223677 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.