Skip to main content
Inspiring
December 14, 2010
Answered

MySQL Dual Entry???

  • December 14, 2010
  • 1 reply
  • 464 views

Hello,

I have been doing INSERT function for mysql for a while and I have never come across this problem. The following code:

if (isset($_GET['vote']) && $voteOK && $totalRows_CheckVote == 0 && $totalRows_Active > 0) {

  $insertSQL = sprintf("INSERT INTO Rankings (AnimeID, UserID, Vote) VALUES (%s, %s, %s)",

                       GetSQLValueString($_GET['animeid'], "text"),

                       GetSQLValueString($row_Active['MEMBERID'], "text"),

                       GetSQLValueString($_GET['vote'], "int"));

  mysql_select_db($database_Anime, $Anime);

  $Result1 = mysql_query($insertSQL, $Anime) or die(mysql_error());

}

inserts the data twice. So I get duplicates of everything!

Any and all help would be appreciated

Message was edited by: cwhazzoo

This topic has been closed for replies.
Correct answer David_Powers

cwhazzoo wrote:

inserts the data twice. So I get duplicates of everything!

On its own, that code inserts the data only once. There must be something else in your complete script that's causing the duplicate entry.

1 reply

David_Powers
David_PowersCorrect answer
Inspiring
December 14, 2010

cwhazzoo wrote:

inserts the data twice. So I get duplicates of everything!

On its own, that code inserts the data only once. There must be something else in your complete script that's causing the duplicate entry.

cwhazzooAuthor
Inspiring
December 14, 2010

Nevermind, I found the problem. And David, I saw you released a new PHP Solutions book. I was wondering if it covered anything new or if it just uses up to date syntax? I loved your first one and I figured I would ask you.

David_Powers
Inspiring
December 16, 2010

cwhazzoo wrote:

I saw you released a new PHP Solutions book. I was wondering if it covered anything new or if it just uses up to date syntax? I loved your first one and I figured I would ask you.

Glad you liked the first edition. The second edition of "PHP Solutions" is an update, rather than a completely new book. The main difference is that it requires a minimum of PHP 5.2 and MySQL 4.1. The chapters on file uploads and thumbnail creation have been completely rewritten to use PHP 5 classes. There's also some new material, such as a password strength checking class, and detailed coverage of the date and time related classes in PHP 5.2 and 5.3. There's a more detailed rundown on my site at http://foundationphp.com/phpsolutions/.

Although readers of the first edition would probably get some value out of the new edition, it's mainly targeted at new readers. Much though I would love you to buy the book, I don't want to mislead you about the content.