0

I want to understand why the script below isn't working. Keep getting error: Fatal error: Too few arguments to function wpdb::prepare(), 1 passed ...2 expected...no idea where I need to get the second argument.

<?php

$zoekvn = $_POST['zoekvn']

if(isset($_POST['submit'])):


    try{
        $result = $wpdb->get_results($wpdb->prepare("SELECT id, geslacht, voornaam, familienaam, email, tel, afile, app_datum FROM sollicitatie_form WHERE voornaam = $zoekvn"));

        foreach ($result as $row){?>


        <form>

            <tr>
            <td><?php echo "{$row -> id}"; ?></td>
            <td><?php echo "{$row -> geslacht}"; ?></td>
            <td><?php echo "{$row -> voornaam}"; ?></td>
            <td><?php echo "{$row -> familienaam}"; ?></td>
            <td><?php echo "{$row -> email}"; ?></td>
            <td><?php echo "{$row -> tel }"; ?></td>
            <td><a href="sollicitatie/uploads/<?php echo "{$row -> afile}" ?>" target="_blank">view file</a></td>
            <td><?php echo "{$row -> app_datum}"; ?></td>


        </tr>

        </form>


        <?php
        }
    }

        // use exec() because no results are returned
        catch(PDOException $e)
        {
        echo $sql . "<br>" . $e->getMessage();
        }

$conn = null;
endif;
?>
2

After a million tries I finally found it...

$result = $wpdb->get_results($wpdb->prepare("SELECT id, geslacht, voornaam, familienaam, email, tel, afile, app_datum FROM sollicitatie_form WHERE voornaam = %s", $zoekvn));

I guess when you found the solution yourself you're less likely to forget it :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.