0

My page is all blank because of this piece of code:

$coins = '2';                       
$vote_site = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';      
$account = $_POST['name']; 
$account = mysql_real_escape_string($account); 

$conn = mysql_connect($dbhost, $dbuser, $dbpassword) or die ('mySQL Connecting Error'); 
mysql_select_db($database); 
$ip = $_SERVER['REMOTE_ADDR']; 

if(isset($_POST['submit']) && strlen($account)>=4){
$search = mysql_query("SELECT * FROM account.account WHERE login = '$account' LIMIT 1");
    if (mysql_fetch_array($search) !== false){
    $insert = mysql_query("INSERT INTO account.account SET coins = "'.$coins.'" WHERE login = "'.$account.'"") or die(mysql_error);
    header("Location: http://' .$vote_site. '");
    }else{
        echo "Conta nao existe!";
        }
    }elseif (isset($_POST['submit']) && strlen($account)<4){
        echo "<font color='red'>Conta inválida!</font>";
    }

I have a html form, its supose to insert some values in a table and redirect to a website, but all I get is a white page.

I already tried all the ways to report errors, but it won't display anything!

Gumbo
  • 620,600
  • 104
  • 758
  • 828
Joao Paulo
  • 101
  • 7

1 Answers1

1

Remove double quotes around and concatenation dots here SET coins = "'.$coins.'" WHERE and here login = "'.$account.'"") :

$insert = mysql_query("INSERT INTO account.account SET coins = '$coins' WHERE login = '$account'") or die(mysql_error);

or switch their position:

$insert = mysql_query("INSERT INTO account.account SET coins = '".$coins."' WHERE login = '".$account."'") or die(mysql_error);

OOOPS Since this query is INSERT it has no sense to use WHERE so probably you've meant:

$insert = mysql_query("INSERT INTO account.account (coins, login) VALUES ('$coins', '$account')") or die(mysql_error);

UPDATE 1 It seems you don't understand difference between INSERT and UPDATE statement for mysql. Read about insert and update please . And try:

$insert = mysql_query("UPDATE account.account SET coins = '$coins' WHERE login = '$account'") or die(mysql_error);

Probably that is what you are looking for.

Alex
  • 16,571
  • 1
  • 27
  • 50