Click here to Skip to main content
16,018,650 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am a newbie to php and been trying to get rid of this error for a while now. I believe i have the correct amount of parameters but cant figure out where the problem is. This is my php code below.. any answer is much appreciated. thanks

PHP
<?php
/*
 * Created on Oct 10, 2013
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 require ("common.php");
 
 //$mySessionName = $_SESSION['UserName'];
 	if (isset($_POST['Add'])){
		
		$mySession = $_SESSION['user']['FullName']; //get the current user
		
		//mysql_select_db("tech_debt") or die("Could not connect to the database..".mysql_error());
		$query = "INSERT INTO compliance_requirement (ComplianceID, ComplianceName, ComplianceGoal, ComplianceDescription, ComplianceStartDate, ComplianceEndDate, UserName)
				VALUES (NULL, :ComplianceName, :ComplianceGoal, :ComplianceDescription, :ComplianceStartDate, :ComplianceEndDate, :UserName)";
		
		
		$query_params = array(
			':ComplianceID' => '',
            ':ComplianceName' => $_POST['ComplianceName'],
            ':ComplianceGoal' => $_POST['ComplianceGoal'],
            ':ComplianceDescription' => $_POST['ComplianceDescription'],
            ':ComplianceStartDate' => $_POST['ComplianceStartDate'],
            ':ComplianceEndDate' => $_POST['ComplianceEndDate'],
            ':UserName' => $_POST['UserName']
        );

		try
        {
            // Execute the query to create the compliance
            $stmt = $db->prepare($query);
            $result = $stmt->execute($query_params);
        }
        catch(PDOException $ex)
        {
            die("Failed to run query: " . $ex->getMessage()); 
        } 
         
        // This redirects the user back to the login page after they register 
        header("Location: createcompliance.php"); 
	}
?>
Posted

1 solution

You'are declaring :ComplianceID which doesn't exist in your SQL sentence.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900