Having an ugly time with this Admin page. The problem is that I can't get it to do inserts into the database. The variables are passed from a form for the insert part of the function. The fuction itself as a whole works and I can successfully see each of the variables passed when I add an echo statement for any of them. But for some strange unknown reason I cant get new data into the database. It going to the correct section and I can even echo the query, but nothing happens and no error messages. If you have any ideas, let me know.
The database is setup with 9 fields: ID (primary key/autoincrement), piece, year, image, thumb, price (decimal(10,2), notes, status, link.
function admin($action1) {
global $action1,$title1,$year1,$price1,$notes1,$artfile,$status,$link,$ID1;
$connect = mysql_pconnect("", "user", "password")
or die ("ERROR: Database connection error #".mysql_error());
mysql_select_db("database1")
or die("ERROR: Table connection error #".mysql_error());
switch ($action1) {
case "INSERT":
$query = "insert into artwork values (null, '$title1', '$year1','$artfile','$thumb',$price1,'$notes1','$status','$link')";
case "UPDATE":
$query = "update artwork set piece='$title1', year='$year1', price='$price1', notes='$notes1', status='$status', link='$link' where ID='$ID1'";
case "DELETE":
$query = "delete from artwork where ID='$ID1'";
}
$results = mysql_query($query) or die ("ERROR: Bad query #".mysql_error());
if ($results) {
echo mysql_affected_rows()." record(s) affected.<p>\n";
echo $action1.",".$ID1.",".$title1.",".$year1.",".$price1.",".$notes1.",".$artfile.",".$status.",".$link;
}
mysql_close($connect);
}
?>