madhuramasamy Posted April 29, 2010 Share Posted April 29, 2010 My code is $query="select Chemical_ID, count(*) from Chem_Inventory where Date_Out=\'0000-00-00\' group by Chemical_ID"; $result=mysql_query($query); print "<h3><p><center>Microlab Chemical Inventory</center></p></h3><br>"; print "<table><tr><td><b>Chemical ID</td><td><b>Chemical Name</td><td><b>Available Stock</td></tr>"; while ($sel = mysql_fetch_array($result)){ if ($sel[Chemical_ID] >= 1000 && $sel[Chemical_ID] < 2000){ $tbl = "Chemicals_acids";} if ($sel[Chemical_ID] >= 2000 && $sel[Chemical_ID] < 3000){ $tbl = "Chemicals_solvents";} if ($sel[Chemical_ID] >= 3000 && $sel[Chemical_ID] < 4000){ $tbl = "Chemicals_metals";} if ($sel[Chemical_ID] >= 4000 && $sel[Chemical_ID] < 5000){ $tbl = "Chemicals_gases";} if ($sel[Chemical_ID] >= 5000 && $sel[Chemical_ID] < 6000){ $tbl = "Chemicals_waste";} $query="select Chemical_Name from $tbl where Chemical_ID = '$sel[Chemical_ID]'"; $chems1 = mysql_query($query); $chems = mysql_fetch_array($chems1); /*print "<tr><td>$sel[iD]</td><td>$sel[Chemical_ID]</td><td>$chems[Chemical_Name]</td><td>$sel</td><td>$sel[Owner]</td><td>$sel[sponsor]</td><td>$sel[Date_In]</td><td>$sel[Date_Out]</td></tr>";} */ print "<tr><td>$sel[Chemical_ID]</td><td>$chems[Chemical_Name]</td><td>$sel[count(*)]</td></tr>";} print "</table>\n"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/200203-im-new-to-php-i-need-some-help-with-the-error-parse-error-parse-error-unexpect/ Share on other sites More sharing options...
andrewgauger Posted April 30, 2010 Share Posted April 30, 2010 $query="select Chemical_Name from $tbl where Chemical_ID = '$sel[Chemical_ID]'"; should be $query="select Chemical_Name from $tbl where Chemical_ID = '{$sel[Chemical_ID]}'"; Also any other references to arrays inside strings need to be surrounded by {} print "<tr><td>{$sel[Chemical_ID]}</td><td>$chems[Chemical_Name]</td><td>$sel[count(*)]</td></tr>";} ALSO! Make sure that every reference anywhere in your code that you reference an associative array: array['key'] Use single quotes around the key! Quote Link to comment https://forums.phpfreaks.com/topic/200203-im-new-to-php-i-need-some-help-with-the-error-parse-error-parse-error-unexpect/#findComment-1050812 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.