Below is my code..
$stmt->execute($params) is not getting executed

        $name = $_REQUEST['name2'];
        $surname = $_REQUEST['surname2'];
        $add = $_REQUEST['add2'];
        $pdo = new PDO( "mysql:host = localhost;dbname = employee", "xxx", "");
        $stmt = $pdo->prepare( 'INSERT INTO test_differ VALUES( :name2 , :surname2 , :add2 )' );
        $params = array( ':name2' => $name, ':surname2' => $surname, ':add2' => $add );
        if ( !($stmt->execute($params))) {
            echo "error in execution";
        }

        $pdo = null;

Do you get an exception?

No Exception

Anything in the error log? Does your table only have those three columns?

I debugged it
I was missing space between values and opening bracket
changed VALUES( :name2 , :surname2 , :add2 ) to VALUES ( :name2 , :surname2 , :add2 )
and solved :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.