0

Im looking to send data to a local Database. I have connected the Database and everything is set up. I now want to send a query via php to the SQL database. All is well until I try to use the Blind Param Methods. Im new to php and cant figure out where im going wrong whether its Syntax or My mistakes. anyone any ideas ?

error message : expected semi-colon, (, ) stuff like that.

<?php
    
    class queryExecute
    {
        function sendData(){
            include_once 'dbConnect.php';
    
            $conn = new dbConnect(); //Connection to database.
    
            // Set the variables for the person we want to add to the database
            $id_Num = "Test";
            $movie_Title = "Testing";
            $category = "Testing@testing.com";
            $price = "Tester";
    
            //SQL Query
            $my_Insert_Statement = $conn->prepare("INSERT INTO evote.movie(id, title, category, price) VALUES (:id_Num, :movie_Title, :category, :price)");
    
            // Now we tell the script which variable each placeholder actually refers to using the bindParam() method
            $my_Insert_Statement->bindParam(:id_Num, $id_Num);
            $my_Insert_Statement->bindParam(:movieTitle, $movie_Title);
            $my_Insert_Statement->bindParam(:category, $category);
            $my_Insert_Statement->bindParam(:price, $price);
    
            // Execute Code.
            if ($my_Insert_Statement->execute()) {
                echo "New record created successfully";
            }
            else {
                echo "Unable to create record";
            }
        }
    }
    
    $send = new queryExecute();
    $send->sendData();
Simone Rossaini
  • 8,115
  • 1
  • 13
  • 34

0 Answers0