/    Sign up×
Community /Pin to ProfileBookmark

Deleting Rows From Database..Should Be Simple..

Having a little issue here.

I want to delete some make-believe accounts from my MySQL DB and I’m not quite understanding why this simple script/query doesn’t work.

[code=php]
function deleteUsers(){

global $wpdb;

$userdelete = $wpdb->query( “DELETE * FROM {$wpdb->users} WHERE user_login != ‘admin’ “);

if(! $userdelete )
{
die(‘Could not delete data: ‘ . mysql_error());
echo ‘deletion didnt work for users’;
}

}
[/code]

It is a WordPress site that’s where the $wpdb->users is coming from…$wpdb is an object and “users” is the table… so that part is right…but can anyone see any other errors?

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 02.2011 — There is no column list for a DELETE query, so the "*" does not belong in your query.
Copy linkTweet thisAlerts:
@tirnaMar 02.2011 — ....
Copy linkTweet thisAlerts:
@ChuckBauthorMar 02.2011 — There is no column list for a DELETE query, so the "*" does not belong in your query.[/QUOTE]

I tried it without and it still didn't work..maybe it's something else if you don't see anything wrong with the code...thanks..
Copy linkTweet thisAlerts:
@NogDogMar 02.2011 — Are you seeing the error message at all? If not, maybe stick something in that function that will indicate it was called -- in other words, are you sure you're calling it? ?
Copy linkTweet thisAlerts:
@ChuckBauthorMar 10.2011 — Are you seeing the error message at all? If not, maybe stick something in that function that will indicate it was called -- in other words, are you sure you're calling it? ?[/QUOTE]

Sorry for the very late reply NogDog...I'll eventually solve this...for now I'm moving on to the next issue (...I'm customizing a social networking plugin in Wordpress...what a headache :rolleyes: )

Thanks..
×

Success!

Help @ChuckB spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...