i have an upate script which uses a form that has this code in it which is a self populating select box ....
print ("<tr>
<td width=\"140\" bgcolor=\"#cccccc\"><b>Agency : </b></td>
<td width=\"427\">");
$table="agency"; // name of the table
$orderBy="agency_name"; // Usually a column name
$conn = pg_connect("","","","","funds");
if(!$conn)
{echo "Could not make a connection";exit;}
$sql = "select distinct* from $table order by $orderBy;";
$select_box = pg_Exec($conn, $sql);
$numrecords = pg_NumRows($select_box);
echo "<select name=\"agency_name\">";
echo"<option value=\"n/a\">select from previously input agencies</option>";//pre selected option
for ($j=0; $j < $numrecords; $j++) //loop through database to populate select box
{
$value = pg_result($select_box, $j, "agency_name"); //column name for the value of the checkbox
$option = pg_result($select_box, $j, "agency_name"); // select option column name
echo"<option value=$value>$option</option>";
}
echo"</select>";
this form then goes to the script page which runs the update like so ....
<?php
$db = pg_connect("","","","","funds");
$query = "UPDATE scholarship SET schol_name='$name', value='$value', deadline='$deadline',
app_info='$app_info', agency_name='$agency_name', eligibility='$eligibility', field='$field',
level='$level', gender='$gender' where schol_id='$id'";
$result = pg_exec($db, $query);
if (!$result) {print ("ERROR"); exit;}
print ("The values were updated in the database");
print ("<div align=\"center\">
<p><a href=\"updateschol.php\">Update more Scholarships in the Database</a></p>
<p><a href=\"index.html\">Return to the Options Menu</a></p>
<p><a href=\"sview.php\">View Funds</a></p>
</div>");
pg_close($db);
?>
band it works just fine - for anything it seems EXCEPT for when the agency name in the database is more than one word long ... why is this happening ????????? the error i get is "Warning: PostgreSQL query failed: ERROR: referential integrity violation - key referenced from scholarship not found in agency in /home/httpd/html/development/php/Funds/updatescript.php on line 59
ERROR" but this message is wrong because the values ARE there ... when i run my view script to see what is in the database - sure enough the valuei want to update to (which is more than one word long - IS there). PLEASE HELP. or perhaps is there another way - because i need this agency box to be self populating....