Page 2 of 2

Posted: Mon Nov 27, 2006 10:25 am
by boo_lolly
Burrito wrote:the uid looks to be alphanumeric, you'll need to quote that in your sql statement. If you put some error checking in your mysql_query() as has been suggested, you'd see this.
what is that supposed to mean? it's still passing the same information the same way... my debug output shows that $c is printing the values of the uID's that i want to be deleted. it's printed the same exact way in the sql query. so i don't understand what you mean? can you explain?

here's the code now.

Code: Select all

if($_POST['delete'] != NULL){
		foreach($_POST['delete'] as $k => $c){
			echo $k ." / ". $c ." || ";  //<-- prints the EXACT correct information for the sql query to be properly executed.
			$sql = "DELETE * FROM my_search_table WHERE uID = ". $c ."";
			mysql_query($sql) OR die ("The query:<br>" . $sql . "<br>Caused the following error:<br>" . mysql_error());
		}
	}
here's what it prints...

Code: Select all

0 / 7djtV0nIPaui9Wt7WkIUBts2M3b3bh || The query:
DELETE * FROM my_search_table WHERE uID = 7djtV0nIPaui9Wt7WkIUBts2M3b3bh
Caused the following error:
You have an error in your SQL syntax near '* FROM my_search_table WHERE uID = 7djtV0nIPaui9Wt7WkIUBts2M3b3bh' at line 1
even if i click more than one checkbox, it only prints an error for the FIRST of the many to be checked (in order from top to bottom). which makes sense. but what does the error mean?

Posted: Mon Nov 27, 2006 10:29 am
by JayBird
he means your query should look like this (notice the extra quotes around the $c variable)

Code: Select all

$sql = "DELETE * FROM my_search_table WHERE uID = '". $c ."'";

Posted: Mon Nov 27, 2006 10:32 am
by Burrito
get rid of your '*' in your delete query too.

it should just be:

Code: Select all

delete from myTable where...

Posted: Mon Nov 27, 2006 10:33 am
by boo_lolly
IT WORKS IT FINALLY WORKS!!!!! it was the '*' and the single quotes in the SQL query that were causing all the problems!!!! IT WORKS!!!!

Code: Select all

$_POST['delete'];
if($_POST['delete'] != NULL){
	foreach($_POST['delete'] as $k => $c){
		//echo $k ." / ". $c ." || ";  //<-- prints the EXACT correct information for the sql query to be properly executed.
		$sql = "DELETE FROM my_search_table WHERE uID = '". $c ."'";
		mysql_query($sql) OR die ("The query:<br>" . $sql . "<br>Caused the following error:<br>" . mysql_error());
	}
}
RIGHTEOUS!!!!!! thank you guys so much!