i'm having trouble getting this to work. i want mysql to delete a row where the word 'example' is within a paragraph of a column.

e.g. in the column reply.. it has a paragraph with the word 'example' in it.

$deletebadreply1=  mysql_query("DELETE FROM `Reply` WHERE `reply` LIKE '%example%'") or die (mysql_error());

i tried the above and it isnt deleting the row. how do i resolve this?

Recommended Answers

All 3 Replies

are you getting any error message reported? Have you verified that the script actually attempts to execute that query? Does the authenticated DB user have permissions to delete records on that db? Does you paragraph have the word 'Example' (uppercase) as opposed to 'example' (all lowercase)?

Have you tried

"SELECT FROM `Reply` WHERE `reply` LIKE '%example%'

?

If that returns no results then probably delete will not work either.
Check your indexes too maybe (FULL TEXT vs LIKE). It's possible that your selection isn't working...

As Tim said above, first determine if there are any files with example in the paragraph, thus using the SELECT statement first. If BOF or EOF is true, there is no record to delete, else if there is a return, THEN delete the file until the EOF has been reached.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.