Jump to content

im new to PHP i need some help with the error Parse error: parse error, unexpect


Recommended Posts

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";

?>

 

$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!

Archived

This topic is now archived and is closed to further replies.

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