patsman77 Posted December 23, 2006 Share Posted December 23, 2006 Hello All, I am trying to figure this out, though I am new to this: This is what I am looking to do.... I am trying to update database entry when user submits a form, ifthey already submitted the form I want the database to update the information...what I have is not working....here is what i am using:<?php/* Update MembershipProfile */$host = xxxxx;$user = xxxxx;$pass = xxxxx;$dbase = xxxxx;$table = xxxxx;$table2 = memberinfo2;?><?php $connection = @mysql_connect($host,$user,$pass) or die ("Could not connect!"); $db = @mysql_select_db($dbase, $connection) or die("Could not select a validdatabase."); $sql = "SELECT * FROM $table"; $result = @mysql_query($sql, $connection) or die ("Could not execute query"); while ($row = mysql_fetch_array( $result) { $user_name =$row['user_name']; $name =$row['Name']; $Week =$row['Week']; $game01 =$row['game01']; $game02 =$row['game02']; $game03 =$row['game03']; $game04 =$row['game04']; $game05 =$row['game05']; $game06 =$row['game06']; $game07 =$row['game07']; $game08 =$row['game08']; $game09 =$row['game09']; $game10 =$row['game10']; $game11 =$row['game11']; $game12 =$row['game12']; $game13 =$row['game13']; $game14 =$row['game14']; $game15 =$row['game15']; $game16 =$row['game16']; $survivor =$row['survivor']; $margin =$row['margin']; $Tiebreaker =$row['Tiebreaker']; }endif; $link = mysql_connect($host,$user,$pass); mysql_select_db($dbase); mysql_query($query) or die("MySQL Error: " . mysql_error()); $user_name =addslashes($HTTP_POST_VARS['user_name']); $name =addslashes($HTTP_POST_VARS['Name']); $Week =addslashes($HTTP_POST_VARS['Week']); $game01 =addslashes($HTTP_POST_VARS['game01']); $game02 =addslashes($HTTP_POST_VARS['game02']); $game03 =addslashes($HTTP_POST_VARS['game03']); $game04 =addslashes($HTTP_POST_VARS['game04']); $game05 =addslashes($HTTP_POST_VARS['game05']); $game06 =addslashes($HTTP_POST_VARS['game06']); $game07 =addslashes($HTTP_POST_VARS['game07']); $game08 =addslashes($HTTP_POST_VARS['game08']); $game09 =addslashes($HTTP_POST_VARS['game09']); $game10 =addslashes($HTTP_POST_VARS['game10']); $game11 =addslashes($HTTP_POST_VARS['game11']); $game12 =addslashes($HTTP_POST_VARS['game12']); $game13 =addslashes($HTTP_POST_VARS['game13']); $game14 =addslashes($HTTP_POST_VARS['game14']); $game15 =addslashes($HTTP_POST_VARS['game15']); $game16 =addslashes($HTTP_POST_VARS['game16']); $survivor =addslashes($HTTP_POST_VARS['survivor']); $margin =addslashes($HTTP_POST_VARS['margin']); $Tiebreaker =addslashes($HTTP_POST_VARS['Tiebreaker']); $result = mysql_query("SELECT * FROM $table WHERE user_name = '$user_name' "); if ($user_name && $Week) { $query="UPDATE $table SET user_name='$user_name',name='$Name',game01='$game01',game02='$game02',game03='$game03',game04='$game04',game05 ='$game05',game06='$game06',game07='$game07',game08 ='$game08',game09='$game09',game10='$game10',game11='$game11',game12='$game12',game13='$game13',game14='$game14',game15='$game15',game16='$game16',survivor='$survivor',margin='$margin',Tiebreaker='$Tiebreaker'"; user_name='$user_name',Name='$Name',game01='$game01',game02='$game02',game03='$game03',game04='$game04',game05='$game05',game06='$game06',game07='$game07',game08='$game08',game09='$game09',game10='$game10',game11='$game11',game12='$game12',game13='$game13',game14='$game14',game15='$game15',game16='$game16',survivor='$survivor',margin='$margin',Tiebreaker='$Tiebreaker',last_update=NOW()WHERE user_name=$user_name"; }else{ $query="INSERT INTO picks (Week, Name, Game01, Game02, Game03, Game04, Game05, Game06, Game07, Game08, Game09, Game10, Game11, Game12, Game13, Game14, Game15, Game16, Survivor, Margin, Tiebreaker, user_name ) VALUES('$_POST[Week]','$_POST[Name]','$_POST[Game01]','$_POST[Game02]','$_POST[Game03]','$_POST[Game04]','$_POST[Game05]','$_POST[Game06]','$_POST[Game07]','$_POST[Game08]','$_POST[Game09]','$_POST[Game10]','$_POST[Game11]','$_POST[Game12]','$_POST[Game13]','$_POST[Game14]','$_POST[Game15]','$_POST[Game16]','$_POST[Survivor]','$_POST[Margin]','$_POST[Tiebreaker]','$_POST[user_name]')";if (!mysql_query($sql,$con)) } mysql_close($link); header("Location: indexhome.php");?>Any help would be great....right now it won post or update.Thanx,Patsman77 Quote Link to comment Share on other sites More sharing options...
taith Posted December 23, 2006 Share Posted December 23, 2006 your defining the $query at the bottom... but your not mysql_query(); ing it... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.