0

Errors:
1. Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in C:\wamp\www\SICS\includes\submitcategory.php on line 75
2. PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in C:\wamp\www\SICS\includes\submitcategory.php on line 75

<?php



    //if form has been submitted process it
    if(isset($_POST['submit'])){

        $_POST = array_map( 'stripslashes', $_POST );

        //collect form data
        extract($_POST);

        //very basic validation
        if($catTitle ==''){
            $error[] = 'Please enter the Category.';
        }

        if(!isset($error)){

            try {

                $catURL = slug($catTitle);

                //insert into database
                $stmt = $db->prepare('INSERT INTO category (catTitle,catURL) VALUES (:catTitle, :catURL)') ;
                $stmt->execute(array(':catTitle' => $catTitle,':catURL' => $catURL));

                //redirect to index page
                header('Location: categories.php');
                exit;

            } catch(PDOException $e) {
                echo $e->getMessage();
            }

        }

    }

    //check for any errors
    if(isset($error)){
        foreach($error as $error){
            echo '<p class="error">'.$error.'</p>';
        }
    }
?>
    <?php
     $query = 'SELECT fullname from members where idNUMBER="'.$_SESSION['idnumber'].'"';
                try {
                        $pdoStatement = $db->query($query);
                }
                    catch (PDOException $exception) {
                        // the query failed and debugging is enabled
                        echo "<p>There was an error in query: $query</p>";
                        echo $exception->getMessage();
                        $pdoStatement = false;
                    }
                    if ($pdoStatement) {
                        // the query was successful
                        // get the result (if any)
                        // fetchObject returns FALSE if there is no record
                    if ($recordObj = $pdoStatement->fetchObject()) {
                        $user=$recordObj->fullname;       


                $act= "Added a category";
                $addcat=$db->prepare('INSERT INTO userlog (Name, Datelog, Activity ) VALUES (:Name, :Datelog, Activity)') ;
                $addcat->execute(array(
                    ':Name' => $user,

                    ':Datelog' => date('Y-m-d H:i:s'),

                    ':Activity'=> $act  

                ));

}       
}
?>
2
Contributors
2
Replies
10
Views
2 Years
Discussion Span
Last Post by RonKevinT.Manuela
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.