I am trying to use the sql delete from statement to delete certain data (which are urls) from my db, but they don't seem to actually get deleted. (there are no errors, of course, so it looks like the code is working, but the data does not actually get erased)'

I was curious if this is because I'm using an actual URL (http://www.whatever.com) to locate the data within the sql database.... would passing on certain characters cause problems? (like say a url with "http://www.whatever.com/?file=something" etc?

Basically, my code looks like this:

$del = mysql_query("DELETE FROM items WHERE url = '$delurl'");

and $delurl is an actual URL link that is found earlier in the script.

Is there a problem with the way this passes to the database because of the way some urls are? (having question marks, etc. in them?) Is there some code I should use to strip the special characters out of the urls? Hopefully this makes sense! :)

9 Years
Discussion Span
Last Post by squid44th

delete mysql from url???

right now you use $del = mysql_query("DELETE FROM items WHERE url = '$delurl'"); how about try select first $del = mysql_query("SELECT url FROM items WHERE url = '$delurl'"); if select found, you can delete
if cannot found, you must look url first

if url like domain -> http://www.whatever.com/
maybe database can found
but if url like ->http://www.whatever.com/?file=something&item=0
the database hard to found because &
database must error

and my solution
you select first, after that delete use form
if you select form url
use $_GET[...]
if you want to delete
use $_POST[...]

like this

$find_first = mysql_query("SELECT url FROM items WHERE url = '$delurl'");
$del = mysql_query("DELETE FROM items WHERE url = '$delurl'");

I like using the \" when using php, never had any problems when doing it this way.

$del = mysql_query("DELETE FROM items WHERE url=\"".$delurl."\"");
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.