Jump to content

CadJoe

New Members
  • Posts

    2
  • Joined

  • Last visited

Community Answers

  1. CadJoe's post in Fatal error: Call to a member function bind_param() on boolean was marked as the answer   
    ok, I have it working now.
     
    Knew it was something with the SQL statement, but couldn't figure out what.
     
    I added this to the top <?php
     
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
     
     
    I changed the Prepare statement to include the error which lead me to error 1064.
    Took the single quotes off of the Field Names, and it started working.
     
     
    Adding the below IF statement is HUGE to see the errors.
     
     
           $database = "Survey";

            $db_found = new mysqli('localhost', 'survey', 'survey', $database);
            $db_found->set_charset("utf8");
            
            
            if (!$db_found) {
                echo "Error: db connection = false";
            }
            else {
                $SQL_INSERT = "INSERT INTO Answers (QuestionID, PlayerID, Answer, Option) VALUES (?,?,?,?)";
                $stmt = $db_found->prepare($SQL_INSERT);

                if($stmt = $db_found->prepare($SQL_INSERT)) {        
                    $stmt->bind_param('iiii', $QuestionID, $PlayerID, $Answer, $Option);
                    $stmt->execute();
                    $voteMessage = "Thanks for voting";
                } else {
                    $error = $db_found->errno . ' ' . $db_found->error;
                    echo $error;
                }
            } // else
     
     
     
     
    Really hope this HELPS someone else, as I didn't see this anywhere except one link out of hundreds.
     
    Thanks,
     
    CadJoe
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.