• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 452
  • Last Modified:

ON DUPLICATE KEY UPDATE wipes out fields

I have a database which will store contest participant's votes.  I want to allow participants to update their votes if they decide to change their mind.  I am using the ON DUPLICATE KEY UPDATE feature of MySQL.  I have the username set as the primary key and so if the username is already in the table, then it updates the votes that person had previously entered with the new ones they choose.

The problem I am having is that if a participant already exists in the table and tries to update his/her votes, then the fields that holds the votes becomes blank.  The fields do not get updated with the new votes, they get wiped out completely.

Any idea why this is happening?  
applicable code is shown below.
$sql = "INSERT INTO $table_name
	(username, wk1_home, wk1_2nd, wk1_3rd, wk1_pts) VALUES
	('$username', '$_POST[wk1_home]','$_POST[wk1_2nd]','$_POST[wk1_3rd]', '$_POST[wk1_pts]')
	ON DUPLICATE KEY UPDATE wk1_home = '$_POST[$wk1_home]', wk1_2nd = '$_POST[$wk1_2nd]', wk1_3rd = '$_POST[$wk1_3rd]'";
	
	$result = @mysql_query($sql, $connection) or die(mysql_error());

Open in new window

0
deeayrian
Asked:
deeayrian
  • 17
  • 12
  • 4
  • +1
1 Solution
 
Mark BradyPrincipal Data EngineerCommented:
That is because you are using "INSERT" instead of "UPDATE".  You should probably do a query to see if that username is already in the table and if it is, then do an Update query and if it is not, then do an insert query. All you would need to do is update the actual vote so it would be something like this:

$SQL = "SELECT `username` FROM $table_name WHERE `username`=$username";
$result = mysql_query($SQL)or die(mysql_error());

if(!$result){
// Then do your insert statement
}else{
// The user has already voted so update the vote
$sql1 = "UPDATE $table_name SET `vote`=$vote WHERE `username`=$username";
$result1 = mysql_query($sql1)or die(mysql_error());
}
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>The problem I am having is that if a participant already exists in the table and tries to update his/her votes, then the fields that holds the votes becomes blank.
the syntax looks fine (except for the sql injection problems, you should read up about that and use mysql_real_escape_string() function !)

which is the botes fields? are the other fields you update ok?
0
 
Mark BradyPrincipal Data EngineerCommented:
I may have missunderstood the question sorry....
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Ray PaseurCommented:
Lining it all up makes it easier to read.  It looks like the update query omitted the wk1_pts field.

HTH, ~Ray
$sql = "INSERT INTO $table_name (   username,          wk1_home,          wk1_2nd,          wk1_3rd,           wk1_pts ) 
                        VALUES  ( '$username', '$_POST[wk1_home]','$_POST[wk1_2nd]','$_POST[wk1_3rd]', '$_POST[wk1_pts]' )
        ON DUPLICATE KEY UPDATE wk1_home = '$_POST[$wk1_home]', 
                                wk1_2nd  = '$_POST[$wk1_2nd]', 
                                wk1_3rd  = '$_POST[$wk1_3rd]',
                                wk1_pts  = '$_POST[$wk1_pts]' ";
        
$result = mysql_query($sql, $connection) or die(mysql_error());

Open in new window

0
 
deeayrianAuthor Commented:
@elvin66 - no need to apologize.  When using the ON DUPLICATE KEY UPDATE command, you begin the process with the INSERT command.  (http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html) so I don't believe that was the problem with my code.  However,  I think I am going to go ahead and do the IF statement you recommend and have the commands separate so that I can have an email sent out specifying that the votes are updated (if they had been updated).  By using the ON DUPLICATE KEY UPDATE command, I am not able to do this (that I know of).  

@angellll - I don't believe that sql injection is a problem for the voting portion simply because the data that is being inserted is taken from a drop down menu on a form (not a text box).  I will however, look into using the mysql_real_escape_string() function for the username and password portions and the user profile page.  

Thank you for the tips.  I will award the points to elvin66, when I successfully test his code at home tonight.
0
 
deeayrianAuthor Commented:
@Ray_Paseur - Thank you but I don't wish to update the wk1_pts field at that point in the code.  That bit of data will be calculated separately.  From what I have read, you do not have to include every field in the database after the UPDATE command.  You only specify those fields you wish to update and what you want to update them with.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
> I don't believe that sql injection is a problem for the voting portion
not for your page, but a hacker could "post" to your page with completely different data !
and as I said: please read up about sql injection, and protect your sql anyway.

0
 
Ray PaseurCommented:
So you mean to insert that value if it is new, but not update it if it was already there?  Sorry -  I guess I did not understand what you were trying to achieve

Please take to hear what angelIII: said about SQL injection.  You MUST use mysql_real_escape_string() on external input, and that includes anything that you take out of the data base, that you plan to reinsert later.  It cannot hurt to use it on everything, assuming you use it only once on each field ;-)
0
 
deeayrianAuthor Commented:
@Ray_Paseur - No I wish to insert the wk1_home, wk1_2nd, wk1_3rd fields if they are new and update them if they already exist.  I do not wish to update the wk1_pts field in that block of code.  That is why I left the wk1_pts field out of the UPDATE command.  In addition, having that missing from the UPDATE command would not cause an error.
Yes, I am educating myself on the sql injection issues and realize that angellll's advice is very valuable.  I definitely plan to implement it throughout my website.  However, it was not the solution to my original issue so I am not sure it would be accurate to grant any points to him in this particular thread.
0
 
Ray PaseurCommented:
I'm not worried about the points, deeayrian.  I have enough points to orbit Saturn.  I am worried about your data base, that's all.  Best regards, ~Ray
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I agree, the injection is just additional value, and not to solve the problem submitted.

can you please check with trying to reproduce the problem?
creating an empty table with the same structure etc , and running tests "by hand" ...
0
 
deeayrianAuthor Commented:
@elvin66 -  I made use of your code but now I am getting an odd error that reads "Unknown column 'deeayrian' in 'where clause'  

I don't understand why it is looking for the column deeayrian (which is the person's username), instead of the field deeayrian.  Any ideas?



$sql = "SELECT username FROM $table_name WHERE username = $username";
$result = mysql_query($sql, $connection)or die(mysql_error());

if(!$result){
// Then do your insert statement
$sql2 = "INSERT INTO $table_name
        (username, wk1_home, wk1_2nd, wk1_3rd, wk1_pts) VALUES
        ('$username', '$_POST[wk1_home]','$_POST[wk1_2nd]','$_POST[wk1_3rd]',               '$_POST[wk1_pts]')";
        $result2 = @mysql_query($sql2, $connection) or die(mysql_error());
        
}else{
// The user has already voted so update the vote
$sql1 = "UPDATE $table_name 
              SET wk1_home = '$_POST[$wk1_home]', wk1_2nd = '$_POST[$wk1_2nd]', 
                      wk1_3rd = '$_POST[$wk1_3rd]' WHERE username = $username";

$result1 = mysql_query($sql1, $connection)or die(mysql_error());
}

Open in new window

0
 
deeayrianAuthor Commented:
Anyone else can feel free to provide input as to why I am getting the "Unknown column 'deeayrian' in 'where clause'" error if they wish.  
This error has me completely baffled.  
Thank you.
0
 
deeayrianAuthor Commented:
Okay, I actually just realized that the Unknown column error was due to missing single quotes around the $username variable name.  I fixed that problem.  But now I am back to square one.  Once again while I am using the UPDATE command, the data does not get updated, instead all existing data gets wiped out and the fields are left blank, however I receive no error messages.

I am posting my code again for help:
$sql = "SELECT * FROM $table_name WHERE username = '$username'";
$result = mysql_query($sql, $connection)or die(mysql_error());

if(!$result){
// Then do your insert statement
$sql2 = "INSERT INTO $table_name
        (username, wk1_home, wk1_2nd, wk1_3rd, wk1_pts) VALUES
        ('$username', '$_POST[wk1_home]','$_POST[wk1_2nd]','$_POST[wk1_3rd]', '$_POST[wk1_pts]')";
        $result2 = @mysql_query($sql2, $connection) or die(mysql_error());
        
}else{
// The user has already voted so update the vote
$sql1 = "UPDATE $table_name SET wk1_home = '$_POST[$wk1_home]', wk1_2nd = '$_POST[$wk1_2nd]', wk1_3rd = '$_POST[$wk1_3rd]' WHERE username = '$username'";
$result1 = mysql_query($sql1, $connection)or die(mysql_error());
}

Open in new window

0
 
Mark BradyPrincipal Data EngineerCommented:
Sorry I forgot the single quotes but glad you sorted that out. As for your main problem, are you certain that the posted values actually hold data ?  Sounds to me like they are blank (empty) and you are updating the table with the new empty values.

Try doing a simple echo statement to see if they actually hold data or structure your if statement a little different. Something like assign the posted data to variables:

$wk1_home = $_POST['wk1_home'];  // or if that value is an integer   $wk1_home = $_POST[wk1_home];

$wk1_2nd = $_POST['wk1_2nd'];
$wk1_3rd = $_POST['wk1_3rd'];
$wk1_pts = $_POST['wk1_pts'];

Now check them for values

if($wk1_home != "" && $wk1_2nd != "" && $wk1_3rd != "" && $wk1_pts != "") {
if(!result){
// Then do your insert statement
}
}

 


if(!$result){
  if(!empty($_POST[wk1_home])) && !empty($_POST[wk1_2nd])','$_POST[wk1_3rd]', '$_POST[wk1_pts]'
0
 
Mark BradyPrincipal Data EngineerCommented:
Ignore the last 3 lines of my post. I had forgotten to delete them.
0
 
deeayrianAuthor Commented:
It appears you are correct in your assumption.  It is odd because I know there were values before I added the new lines of code.  I was able to vote just fine previously (meaning the values went into the database) but only the UPDATE statement wiped out votes if there were some previously there.  Now nothing gets added to the database and I get no errors.
My values are assigned properly and I have made no changes to the POST method or ACTION method.

See the code below.  
Do you know why it would stop accepting the values?

//Values are assigned

<select name="wk1_home">
<option value="default">Choose One</option>
<option value="Joe">Joey Constadine</option>
<option value="Adam">Adam Lambert</option>
<option value="Jessie">Jessie Hemp</option>
</select>


//My PHP code for the do_addwk1votes.php file
$username = $_COOKIE["username"];
$db_name = "develde1_idol";
$table_name = "week1";

$connection = @mysql_connect("localhost", "loginid", "password")
	or die(mysql_error()); 

$db = @mysql_select_db($db_name, $connection) or die(mysql_error());

$sql = "SELECT username FROM $table_name WHERE username = '$username'";
$result = mysql_query($sql, $connection)or die(mysql_error());

$wk1_home = '$_POST[wk1_home]';
$wk1_2nd = '$_POST[wk1_2nd]';
$wk1_3rd = '$_POST[wk1_3rd]';


echo "$wk1_home $wk1_2nd $wk1_3rd";

if(!$result){
// Then do your insert statement
$sql2 = "INSERT INTO $table_name
        (username, wk1_home, wk1_2nd, wk1_3rd, wk1_pts) VALUES
        ('$username', '$_POST[wk1_home]','$_POST[wk1_2nd]','$_POST[wk1_3rd]', '$_POST[wk1_pts]')";
        $result2 = @mysql_query($sql2, $connection) or die(mysql_error());
        
}else{
// The user has already voted so update the vote
$sql1 = "UPDATE $table_name SET wk1_home = '$_POST[$wk1_home]', wk1_2nd = '$_POST[$wk1_2nd]', wk1_3rd = '$_POST[$wk1_3rd]' WHERE username = '$username'";
$result1 = mysql_query($sql1, $connection)or die(mysql_error());
}

Open in new window

0
 
deeayrianAuthor Commented:
I apologize, I posted too soon.  My values are working correctly, I just didn't assign the variables correctly in my test (I used single quotes around the values).  
So, I have confirmed the values are working.  But they are not being transferred over into the database.

0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
username is the primary key of the table?
what engine is the table? (MyISAM, Innodb...)
what version is your mysql server?
0
 
deeayrianAuthor Commented:
Yes username is the primary key of the table
MyISAM is the table engine
MySQL version is: 5.0.85-community
0
 
Mark BradyPrincipal Data EngineerCommented:
Instead of trying to look at bits and pieces of your code can you please post the entire php script from <?php to ?> tags and the html form that the users fill out. Thanks
0
 
deeayrianAuthor Commented:
Here you go.
Thanks.
<?php

if (($_POST[wk1_home]) == "default" || ($_POST[wk1_2nd]) == "default" || ($_POST[wk1_3rd]) == "default") {

	header("Location: wk1votes.php");
	exit;
/* }else{
	session_start();
}  

if ($_SESSION[valid] != "yes") {
	header("Location: login.html");
	exit;   */
}


$username = $_COOKIE["username"];
$db_name = "develde1_idol";
$table_name = "week1";

$connection = @mysql_connect("localhost", "id", "password")
	or die(mysql_error()); 

$db = @mysql_select_db($db_name, $connection) or die(mysql_error());

$sql = "SELECT username FROM $table_name WHERE username = '$username'";
$result = mysql_query($sql, $connection)or die(mysql_error());

if(!$result){
// Then do your insert statement
$sql2 = "INSERT INTO $table_name
        (username, wk1_home, wk1_2nd, wk1_3rd, wk1_pts) VALUES
        ('$username', '$_POST[wk1_home]','$_POST[wk1_2nd]','$_POST[wk1_3rd]', '$_POST[wk1_pts]')";
        $result2 = @mysql_query($sql2, $connection) or die(mysql_error());
        
}else{
// The user has already voted so update the vote
$sql1 = "UPDATE $table_name SET wk1_home = '$_POST[$wk1_home]', wk1_2nd = '$_POST[$wk1_2nd]', wk1_3rd = '$_POST[$wk1_3rd]' WHERE username = '$username'";
$result1 = mysql_query($sql1, $connection)or die(mysql_error());
}
?>
<HTML>
<HEAD>
<TITLE>Week 1 Voting Confirmation</TITLE>
</HEAD>
<BODY>
<H1> The Following Votes Have Been Submitted for Week 1 </H1>


<TABLE CELLSPACING=3 CELLPADDING=3>
<TR>
<TD VALIGN=TOP>
<P><STRONG>Username: </STRONG>
<?php echo $username ?></P>
</TD>
</TR>

<TR>
<TD VALIGN=TOP>
<P><STRONG>Person Going Home: </STRONG><BR>
<?php echo "$_POST[wk1_home]"; ?></P>
</TD>
</TR>

<TR>
<TD VALIGN=TOP>
<P><strong>Person with 2nd Lowest Amount of Votes:</strong><br>
<?php echo "$_POST[wk1_2nd]"; ?></P>
</TD>
</TR>

<tr>

<TD VALIGN=TOP>
<P><strong>Person with 3rd Lowest Amount of Votes:</strong><br>
<?php echo "$_POST[wk1_3rd]"; ?></P>
</P>
</TD>
</TR>

</TABLE>

<P><a href="welcome.php">Go to the Home Page</a></P>

</BODY>
</HTML>

Open in new window

0
 
Mark BradyPrincipal Data EngineerCommented:
deeayrian:  I thought I had posted earlier but it seems it never got posted. What I wanted to ask you is will you please post your entire php script here so I can read it from top to bottom. Also, please post the full form that the user is filling in. I'm sure there is a very simple explanation to your problem but until I see the whole it makes it harder to find. Cheers
0
 
Mark BradyPrincipal Data EngineerCommented:
Woops my computer is really playing up. Thanks ! I don't suppose you can do a quick sql dump of your table so I can test it without having to make up a test table ?
0
 
Mark BradyPrincipal Data EngineerCommented:
Also, I'm confused about the form now. Please attach the following:

1: Your user form (html) or whatever form the user sees when voting.
2: The sql file (do a dump from mysql of that table if you could.

I already have your PHP script you posted above so just need the form and the SQL file.
0
 
deeayrianAuthor Commented:
I apologize but I am new to MySQL and I have no idea where the file for the database is located.  
Here is the voting file.  I also didn't think you could actually use the database without me giving you the login information for, which I am hesitant to do for obvious security reasons.  Not sure what other option I have.  
Thank you again for your help.
I really really appreciate it.
wk1votes.php
0
 
deeayrianAuthor Commented:
Sorry I am a little slow tonight.  Here is a dump of the week1 table.  
Nevermind, the row that is missing the username.  What I want the focus to be on is the fact that there are some rows with usernames but the wk1 columns are blank.  They used to have data in there until I tried to update them.  
week1.pdf
0
 
Mark BradyPrincipal Data EngineerCommented:
Ok let me take a look for you....
0
 
Mark BradyPrincipal Data EngineerCommented:
I'd hate to point out the obvious and maybe I'm missing something but the reason why no points are being assigned to the data base is there are no points being posted. I asked you earlier to check that all posted values had data in them and you said they do but where is this value coming from ?  $_POST[wk1_pts]

Your query is formatted a little strange for my liking but there are no errors in it. What is happening with your web pages is that you have a form with only 3 form controls on it. They are :

1: wk1_home  // a selectbox
2: wk1_2nd    // a selectbox
3: wk1_3rd    // a selectbox

That form is sending only those 3 values through to your script so in the php script when it asks for $wk1_pts = $_POST['wk1_pts']; there is nothing being posted as "wk1_pts".

So the value of $wk1_pts will be NULL or empty or ''
When you update a database value with a NULL or empty value that is exactly what you get. Nothing.

So go and find out where that value should be coming from and sort that out and it should all owrk for you.

Cheers
Elvin66
0
 
deeayrianAuthor Commented:
@elvin66:

The points will be calculated later and the fact that the points field is empty/null is not my concern.  My concern are the other fields (wk1_home, wk1_2nd, wk1_3rd).  Why do those fields go blank once they get updated?  Those fields are not updating as the code says they should.  
0
 
deeayrianAuthor Commented:
In addition, ever since I added the additional queries and the UPDATE command you provided above, nothing gets posted to my week1 table.  Not even the original votes get posted via the INSERT command.  I have stared at that code for hours and compared it to others and it looks perfectly fine.  I am completely clueless why nothing will post to that table.  Perhaps the extra queries before it are wrong?  
I have no idea.
0
 
deeayrianAuthor Commented:
I just tested if the code would work to insert the data into my week2 table, an empty table, and it did not work.  Something is wrong either with the queries or the insert command.
I am sorry this is taking so much of your time.  I am going to post a second thread on this since I am using different commands then the original one in the question.  I am hoping a new post with the updated version of the problem could spike some interest of help from others.
Feel free to continue to work with me in this thread and I will be thrilled to give you the points should you find a solution.  
0
 
Mark BradyPrincipal Data EngineerCommented:
Ok try this:



$sql = "SELECT username FROM $table_name WHERE username = '$username'";
$result = mysql_query($sql, $connection)or die(mysql_error());
$nums = mysql_num_rows($result);  // I've added this line

if($nums == 0){  // I've added this line also
// Then do your insert statement
$sql2 = "INSERT INTO $table_name
        (username, wk1_home, wk1_2nd, wk1_3rd, wk1_pts) VALUES
        ('$username', '$_POST[wk1_home]','$_POST[wk1_2nd]','$_POST[wk1_3rd]', '$_POST[wk1_pts]')";
        $result2 = @mysql_query($sql2, $connection) or die(mysql_error());
       
}else{
// The user has already voted so update the vote
$sql1 = "UPDATE $table_name SET wk1_home = '$_POST[$wk1_home]', wk1_2nd = '$_POST[$wk1_2nd]', wk1_3rd = '$_POST[$wk1_3rd]' WHERE username = '$username'";
$result1 = mysql_query($sql1, $connection)or die(mysql_error());
}
0
 
deeayrianAuthor Commented:
Yes, the $num(result) query works and the table now accepts new data. However, the UPDATE command is still not working.  Whenever there is an existing username, the voting data does not update, it gets wiped out.  

As a side note, I did echo my $num variable and verified it was working by showing "1" when the username existed.  I also checked my UPDATE statement in PHPMyAdmin and it passed and was able to update my table correctly.  So I am thinking that there is an error in the queries around the UPDATE command?  I tried the else statement both ways - once with just else and again as it is shown below (else if).  

I also noticed that I had previously forgotten a few @ symbols in front of the queries so I added those as well.
Here is my updated code.


<?php 
 
if (($_POST[wk1_home]) == "default" || ($_POST[wk1_2nd]) == "default" || ($_POST[wk1_3rd]) == "default") { 
 
        header("Location: wk1votes.php"); 
        exit; 
} 
 
 
$username = $_COOKIE["username"]; 
$db_name = "develde1_idol"; 
$table_name = "week1"; 
$week = "Week 1"; 
 
$connection = @mysql_connect("localhost", "id", "password") 
        or die(mysql_error());  
 
$db = @mysql_select_db($db_name, $connection) or die(mysql_error()); 
 
$sql = "SELECT username FROM $table_name WHERE username = '$username'"; 
$result = @mysql_query($sql, $connection) or die(mysql_error()); 
$num = @mysql_num_rows($result); 

 
if($num == 0) { 
// Then do your insert statement 
$sql2 = "INSERT INTO $table_name 
        (username, wk1_home, wk1_2nd, wk1_3rd, wk1_pts) VALUES 
        ('$username', '$_POST[wk1_home]','$_POST[wk1_2nd]','$_POST[wk1_3rd]', '$_POST[wk1_pts]')"; 
        $result2 = @mysql_query($sql2, $connection) or die(mysql_error()); 
         
        //send confirmation email 
         
        $msg = "Confirmation of votes for $week\n"; 
        $msg .= "UserName:  $username \n"; 
        $msg .= "Going Home:    $_POST[wk1_home]\n"; 
        $msg .= "2nd Lowest Amount of Votes:    $_POST[wk1_2nd]\n"; 
        $msg .= "3rd Lowest Amount of Votes:    $_POST[wk1_3rd]\n"; 
         
        $email = "SELECT email FROM participants WHERE username = '$username'"; 
        $to = "$email"; 
        $subject = "$week Votes Confirmation"; 
        $mailheaders = "From: <americanidolvotes@gmail.com>\n"; 
 
mail($to, $subject, $msg, $mailheaders);   
 
         
}else if ($num == 1) { 
// The user has already voted so update the vote 
$sql1 = "UPDATE $table_name  
                SET wk1_home = '$_POST[$wk1_home]',  
                wk1_2nd = '$_POST[$wk1_2nd]',  
                wk1_3rd = '$_POST[$wk1_3rd]'  
                WHERE username = '$username'"; 
 
$result1 = @mysql_query($sql1, $connection) or die(mysql_error()); 
 
 
        $msg = "Confirmation of UPDATED votes for $week\n"; 
        $msg .= "UserName:  $username \n"; 
        $msg .= "Going Home:    $_POST[wk1_home]\n"; 
        $msg .= "2nd Lowest Amount of Votes:    $_POST[wk1_2nd]\n"; 
        $msg .= "3rd Lowest Amount of Votes:    $_POST[wk1_3rd]\n"; 
         
        $email = "SELECT email FROM participants WHERE username = '$username'"; 
        $to = "$email"; 
        $subject = "$week Votes Have Been Updated"; 
        $mailheaders = "From: <americanidolvotes@gmail.com>\n"; 
 
mail($to, $subject, $msg, $mailheaders);    
} 
 
 
?> 
<HTML> 
<HEAD> 
<TITLE><?php echo $week ?> Voting Confirmation</TITLE> 
</HEAD> 
<BODY> 
<H1> The Following Votes Have Been Submitted for <?php echo $week ?> </H1> 
<H4> You will receive a confirmation email </H4> 
 
 
<TABLE CELLSPACING=3 CELLPADDING=3> 
<TR> 
<TD VALIGN=TOP> 
<P><STRONG>Username: </STRONG> 
<?php echo $username ?></P> 
</TD> 
</TR> 
 
<TR> 
<TD VALIGN=TOP> 
<P><STRONG>Person Going Home: </STRONG><BR> 
<?php echo "$_POST[wk1_home]"; ?></P> 
</TD> 
</TR> 
 
<TR> 
<TD VALIGN=TOP> 
<P><strong>Person with 2nd Lowest Amount of Votes:</strong><br> 
<?php echo "$_POST[wk1_2nd]"; ?></P> 
</TD> 
</TR> 
 
<tr> 
 
<TD VALIGN=TOP> 
<P><strong>Person with 3rd Lowest Amount of Votes:</strong><br> 
<?php echo "$_POST[wk1_3rd]"; ?></P> 
</P> 
</TD> 
</TR> 
 
</TABLE> 
 
<P><a href="welcome.php">Go to the Home Page</a></P> 
 
 
 
</BODY> 
</HTML> 


   

Open in new window

0
 
deeayrianAuthor Commented:
IT'S WORKING!!!!!  
I was playing with the code and decided to change the UPDATE's query to sql3 and result3 and for some reason it worked.  The update now updates properly.  I am so happy (and tired).
Thank you so much for your persistence.  I would give you double points if I could.  :o)
0
 
Mark BradyPrincipal Data EngineerCommented:
I'm glad you finally got it working. That doesn't make sense to just change sql1 to sql3 and it works? I would say that it is  not possible as $sql1 is just a holder for the data that comes after it. Maybe there was some other small thing you changed? In any case, it is working and that is the main thing. Good for you !
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 17
  • 12
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now