QUOTE(stu26 @ 2 Aug, 2007 - 10:56 AM)

Quick Update. I started receiving the same error again, so I used the mysql_error() instead of die("Error"). It works fine without any errors like that and as soon as I change it back to die I get the same error again. Not sure why this causes a problem but that appears to be the culprit.
Thanks again!
That's really very strange. The contents of the die() block shouldn't affect the outcome of the mysql_query() at
all! My best guess is there's something else causing it, and it's just coincidence that it changed at the same time as you changed the die() call.
In all truth, I don't like die() calls
at all. It means your entire script bombs out mid-flow and the user sees an unintelligable message with no clue as to what's gone wrong or where to go next. Much better to just print a "We are experiencing database problems, please try resubmitting in a minute or two" and redisplay the form containing whatever the user already inputted, so they haven't lost whatever they were trying to send. Any database insertion errors need to be handled in an intelligent way, because things can and will go wrong at any time.
Since I can't see your database structure, I can't suggest what could be causing the problem. Possibly you have some validation going on in your database (i.e. unique fields, that kind of thing) which is being violated by some of your test posts.
p.s. Instead of all that Javascript, try
CODE
header("Location: usermanagement.php?userAdded=true");
Then somehwere in usermanagement.php:
CODE
<? if(isset($_GET["userAdded"]) && $_GET["userAdded"]=="true") { ?>
<p>User successfully added</p>
<? } ?>
Again it's a matter of preference but I reckon that's much simpler, and alert boxes are pretty ugly...
p.p.s. You need to "escape" any values from form inputs
before inserting them into MySQL; otherwise this is open to SQL Injection Attacks, which are a pretty easy way for anyone to destroy your database. Read:
How to prevent SQL Injection Attacks with PHP and MySQL--serializer
This post has been edited by serializer: 3 Aug, 2007 - 12:31 PM