jeudi 28 juillet 2016

Inserting data into database using pdo

keep failing inserting data into database... im totally newbie in this... just need someone to explain the correct way inserting data

<?php   
    //TO ADD DATA
    if (isset($_POST['add'])) {
        $conn = new PDO("mysql:host=localhost;dbname=fzdb", 'root', '');
        $stmt = $conn->prepare("INSERT INTO 'order' (phone, name, address, city, state, postcode, product, size, quantity) VALUES 
            (:Phone, :Name, :Address, :City, :State, :Postcode, :Product, :Size, :Quantity)");

        $stmt->bindParam(':Phone', $phone);
        $stmt->bindParam(':Name', $name);
        $stmt->bindParam(':Address', $address);
        $stmt->bindParam(':City', $city);
        $stmt->bindParam(':State', $state);
        $stmt->bindParam(':Postcode', $postcode);
        $stmt->bindParam(':Product', $product);
        $stmt->bindParam(':Size', $size);
        $stmt->bindParam(':Quantity', $quantity);

        $phone = 'Phone';
        $name = 'Name';
        $address = 'Address';
        $city = 'City';
        $state = 'State';
        $postcode = 'Postcode';
        $product = 'Product';
        $size = 'Size';
        $quantity = 'Quantity';


        $stmt->execute();
    }
    ?>

Aucun commentaire:

Enregistrer un commentaire