PHP not deleting data from database

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Thu Mar 21, 2013 11:38 am

in mysql, the ampersand (&) is the operator for a bitwise 'and' comparison. 'A & B' translates to 0. instead of using mysql functions, you should use PDO. the syntax is similar enough that you'll catch on quickly and pdo functions are much faster and more secure. a good example of use can be seen at ... o-examples . it's a 12 minute video that goes over some basics and advantages, including using prepared statements. Whether you switch to pdo or not, you should also not delete based on a field that is not a primary key, as it creates the possibility for error. You should have a findByName() if you like that returns a record or id, and then delete based only on the id or a unique field. then you won't have to limit results, or risk your data if someone re-uses a name. quoting your fields (using PDO::quote() or mysqli::real_escape_string) should avoid the current issue you're having though.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests