Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

Kesalahan penguraian:kesalahan penguraian di php

Dari mana else ini masuk? Tambahkan } :

} else if(($shares = mysql_query($sharesQuery)) == false)

Kode akhir Anda adalah:

<?

    // require common code
    require_once("includes/common.php");

    //check for errors
    $error = false;
    if (isset($_POST["submit"])) {

        if (empty($_POST["symbol"])) {
            $error   = true;
            $message = "Enter a name";
        }

        else if (empty($_POST["shares"])) {
            $error   = true;
            $message = "Enter the shares";
        }

        // check if user has the stocks and the shares
        $id     = $_SESSION["id"];
        $symbol = $_POST["symbol"];

        $sharesQuery = "SELECT shares FROM portfolio WHERE id = $id AND symbol = '$symbol' ";
    } else if (($shares = mysql_query($sharesQuery)) == false) {
        $error   = true;
        $message = "Don't have the stock";
    }

    // else, if everything checks out, delete it and increment the cash

    else {
        $deleteQuery = "DELETE from portfolio WHERE id = $id AND symbol = '$symbol'";
        mysql_query($deleteQuery);

        $incrementQuery = "UPDATE users SET cash = cash + ($shares * lookup($symbol)->price) WHERE id = $id ";
        mysql_query($incrementQuery);

        //set the variables into session  and then redicrect to sell2
        $_SESSION["symbol"] = $_POST["symbol"];
        $_SESSION["shares"] = $_POST["shares"];
        redirect("sell2.php");

    }

?>


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Bagaimana cara menyimpan teks arab di database mysql menggunakan python?

  2. 10 fakta &tips menarik tentang MySQL

  3. Cara mengatur zona waktu MySQL JDBC yang benar dalam konfigurasi Spring Boot

  4. Bagaimana menghubungkan ke MySQL menggunakan Python

  5. MYSQL Memesan dari Tabel lain