samedi 1 août 2015

Variable not passed by reference | ms-sql and php

When I insert a row into my ms-sql server database, I have the following error:

Warning: Variable parameter 3 not passed by reference (prefaced with an &). Variable parameters passed to sqlsrv_prepare or sqlsrv_query should be passed by reference, not by value. For more information, see sqlsrv_prepare or sqlsrv_query in the API Reference section of the product documentation. in C:\...\ImmoToevoegen.php on line 6

The same warning for parameter 1 and 2.

This is my php code:

<?php
if (!empty($_POST['omschrijving']) && !empty($_POST['woningtype']) && !empty($_POST['data'])){
    $oms = $_POST['omschrijving'];
    $type = $_POST['woningtype'];
    $data = json_encode($_POST['data']);

    $prep = sqlsrv_prepare($conn, "insert into Woning(omschrijving, data, typeid) values (?, ?,  ?);", array($oms, $data, $type));
    sqlsrv_execute($prep);

    print "Woning is toegevoegd";
}
?>

<form action="<?php print $_SERVER['PHP_SELF']; ?>" method="POST">
    <!--param 1 "omschrijving"-->
    Omschrijving:
    <textarea name="omschrijving" id="omschrijving" cols="30" rows="10></textarea>

    <!--param 2 "data"-->
    <div>
        wc: <input type="checkbox" name="data[]" value="wc"/><br/>
        cv: <input type="checkbox" name="data[]" value="cv"/><br/>
        boiler: <input type="checkbox" name="data[]" value="boiler"/><br/>
    </div>

    <!--param 3 "woningtype"-->
    <select name="woningtype" id="woningtype">
        <?php
        //code for load data from database
        print "<option value='" . $rij["ID"] . "'>" . $rij["naam"] . "</option>";
        ?>
    </select>
</form>

<?php
sqlsrv_close($conn);
?>

I use like I said php with a ms-sql server database.

What is wrong with my code?
Thanks

Aucun commentaire:

Enregistrer un commentaire