0

Not sure why, but this line does not even give an error, it simply does not run, and also stops any code after it running. I have checked with die("check") either side of the statement, and only runs before.

mysql_query("UPDATE rounds 
             SET `active`='0', `winnerusername`='$WinnerUsername', `winnerid`='$WinnerID', `pot`='$PreviousPot', `paid`='1' 
             WHERE `round`='$CurrentRound' ") or die(mysql_error());

Any idea why it will not run?

Serguei Fedorov
  • 7,763
  • 9
  • 63
  • 94
user2924019
  • 1,983
  • 4
  • 29
  • 49
  • What does the SQL statement look like once all of the variables are substituted in? – Clart Tent Oct 31 '13 at 20:13
  • 1. There is no row to update. 2. Something about prepared statements: http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php?rq=1 – speccode Oct 31 '13 at 20:13
  • also do not use backticks ` when you really don't need to .. – G-Man Oct 31 '13 at 23:50
  • The `mysql_*` functions are **no longer maintained** and shouldn't be used in any new codebase. It is being phased out in favor of newer APIs. Instead you should use [**prepared statements**](https://www.youtube.com/watch?v=nLinqtCfhKY) with either [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli). – tereško Dec 02 '13 at 19:49

2 Answers2

0

Change it as

mysql_query(
  "UPDATE rounds SET `active`='0',
       `winnerusername`='".$WinnerUsername."', 
       `winnerid`='".$WinnerID."', 
       `pot`='".$PreviousPot."', 
       `paid`='1' 
   WHERE `round`='".$CurrentRound."' "
) or die(mysql_error());
Naveen Kumar Alone
  • 7,536
  • 5
  • 36
  • 57
0

try this:

$sql="UPDATE rounds SET active='0', winnerusername='".$WinnerUsername."', winnerid='".$WinnerID."', pot='".$PreviousPot."', paid='1' WHERE round='".$CurrentRound."' ";
$rs=mysql_query($sql,$Your_Connection_String);

with $Your_Connection_String being something like:

$Your_Connection_String=mysql_connect("localhost","username","password");
mysql_select_db("db_name",$Your_Connection_String);

try to echo $sql; below the query and then paste this into a query in PHPMyAdmin or a MySQL Connection program and see what output you get

charlie
  • 1,356
  • 7
  • 38
  • 76