0

The following code is used to insert values into my mysql-database. The "$statement2" is used when a certain account is logged in to my website and works correctly. My problem is, even before I added the second statement-part, that the command "execute();" does not work. I'm using the JS-console.log in order to see where in my program it stops and by using that I found out that my problem was with the execute()-command. I can verify that my code to connect to the database is correct and that my server for the database is running. The variables from my HTML-form are also correct and the querys are correct if put in the console (when changing the variables to actual values).

Does anybody know any fixes?

<?php
            if(isset($_POST['submitRapport'])){
                ?>
                <script> console.log("test") </script> <?php
                $query  = "INSERT INTO tblaccounts(accountid, username, 'password') 
                VALUES(:säljarid, :username, :'password')";

                $query2 = "INSERT INTO tblSeller(sellerid,'status')
                values(:sellerid, :'status')";

                $statement=$connect->prepare($query);
                $statement->bindValue(':sellerid', $_POST['sellerid']);
                $statement->bindValue(':username', $_POST['username']);
                $statement->bindValue(':password',$_POST['password']);
                
                $statement2 = $connect->prepare($query2);
                $statement2->bindValue(':status',$_POST['status']);
                ?>
                <script> console.log("test2") </script> <?php
                $statement2->execute();
                $statement->execute();
                $success = true;
                ?>
                <script> console.log("test3") </script> <?php
            }
            
        ?>
ADyson
  • 57,178
  • 14
  • 51
  • 63
Henric
  • 1
  • use error reporting to check what is the error. https://www.php.net/manual/en/pdo.error-handling.php – Hello World Feb 22 '21 at 09:40
  • Make PDO report errors (see https://www.php.net/manual/en/pdo.error-handling.php) and make sure PHP is set to log those errors (https://stackify.com/php-error-logs-guide/). Then you should get a useful error message, instead of guessing. – ADyson Feb 22 '21 at 09:41
  • I don't know what `'password'` and `:'password'` are meant to be, but both make no selse. Please learn basic SQL first. – Your Common Sense Feb 22 '21 at 09:50

0 Answers0