Hi,
I'll admit it, this is damned messy. But I want to learn from the list in
how to sort it out. Than for future refrence I will know...
Now I am running 2 different queries/statements here completely seperate. I
have made the "nickname" field in the database UNIQUE. So than when I have
this sort of query setup no matter what their will only be one "nickname" entry
for that user. So when people update their profile a new "nickname" is not
inserted but it is updated. But I want it all in one PHP call. How do I do
this?
Here is the code:
<?
if ($REQUEST_METHOD == "POST") {
$usr = "" . $mysql_user . "";
$pwd = "" . $mysql_password . "";
$db = "" . $mysql_database . "";
$host = "" . $mysql_hostname . "";
$cid = mysql_connect($host,$usr,$pwd);
mysql_select_db($db);
// NOTE that form fields automatically become variables
$sql = "update round" . $round_number . " SET
game1='$game1',game2='$game2',game3='$game3',game4='$game4',game5='$game5',game6='$game6',game7='$game7',game8='$game8',misc='y'
WHERE username='$username'";
mysql_query("$sql");
echo("Your tips have been
saved<br><br>$game1<br>$game2<br>$game3<br>$game4<br>$game5<br>$game6<br>$game7<br>$game8<br>.");
}
else {echo("Ooops, something bad happened! Please try again shortly.");}
?>
<?
if ($REQUEST_METHOD == "POST") {
$usr = "" . $mysql_user . "";
$pwd = "" . $mysql_password . "";
$db = "" . $mysql_database . "";
$host = "" . $mysql_hostname . "";
$cid = mysql_connect($host,$usr,$pwd);
mysql_select_db($db);
// NOTE that form fields automatically become variables
$sql = "insert into round" . $round_number . " SET
game1='$game1',game2='$game2',game3='$game3',game4='$game4',game5='$game5',game6='$game6',game7='$game7',game8='$game8',misc='y',username='$username'";
mysql_query("$sql");
echo(" ");
}
else {echo("Ooops, something bad happened! Please try again shortly.");}
?>
As you can see 2 PHP calls. What I want is to have it all in one PHP call.
On the update one I deleted the echo statement text. I want the insert one to
have the text that appears and the update text output to say "your tips have
been updated..."
Of course if the DB is down or something output an error to try again like
already in the else() statements.
The help would be great.
Thanks!
J