Hi, I couldn't get this to work, but I was using a PHP script to go through the rows in a table in my database and if it found a specific value, to delete that row. However, it deletes ALL the rows no matter what I do and throws an exception after. Any help is appreciated:
// connect (host, usr, and pwd are previously defined, correctly)
$cid = mysql_connect( $host, $usr, $pwd );
// get all columns from the table 'accounts', $db was previously defined (database name)
$query = "SELECT * FROM accounts ORDER BY id";
$result = mysql_db_query( $db, $query, $cid );
// run through each row looking for column 'usrn' with the value 'caughtusername'
while( $row = mysql_fetch_array( $result ) ) {
if( $row['usern'] == "caughtusername" ) {
$id = $row[ 'id' ];
$query = "DELETE FROM accounts WHERE id=$id";
// execute the deletion statement
$result = mysql_db_query( $db, $query, $cid );
echo "<b>Deleted: </b>" . $row['usern'] . "<br>";
}
else {
echo "<b>Spared: </b>" . $row['usern'] . "<br>";
}
}