Results 1 to 8 of 8

Thread: PDO prepared statement

Threaded View

  1. #1
    Join Date
    Nov 2009

    PDO prepared statement

    Hello everyone,

    I am trying to use PDO for my new projects and I can't seem to understand or at least find a good example on prepared statements, I have an update query that works fine but I know I'm not using it right for the data sanitation feature that PDO offers, this is my code:

    PHP Code:
    $data $conn->query("SELECT * FROM adminUsers INNER JOIN permissions ON adminUsers.adminUserID=permissions.adminUserID");
    while (
    $row $data->fetch(PDO::FETCH_ASSOC)){
    $sql "UPDATE adminUsers, permissions SET 
            adminUsers.name = '"
            adminUsers.lastName = '"
            adminUsers.email = '"
            permissions.superAdmin = '"
    .$_POST['superAdmin']."' , 
            permissions.editAdminUsers = '"
    .$_POST['editAdminUsers']."' , 
            permissions.deleteAdminUsers = '"
    .$_POST['deleteAdminUsers']."' , 
            permissions.editUsers = '"
    .$_POST['editUsers']."' , 
            permissions.deleteUsers = '"
        WHERE adminUsers.adminUserID = '"
    .$_POST['id']."' && permissions.adminUserID = '".$_POST['id']."'";
    $sql $conn->prepare($sql);

    Could someone please tell me what is the right way to use PDO in this case?

    Thanks a lot for any help provided.
    Last edited by NogDog; 02-01-2013 at 10:37 PM. Reason: changed [code] tags to [php] tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center