SQLITE PDO Delete

I think it are the tags of the include files.

Yes most likely. Dreamweaver or any developing tool will not be able to show you such things cause it can’t compile the script on the fly, it only checks against syntax errors.

Hi I have tried something else. I made this of the indexbody.php :

[php]<?php
define(“DBASE”,“sqlite:…/sqlite/Polderlaan_Db.sqlite”);
$db = new PDO(DBASE);

$table = “AanbodSpul”;

function Test($id) {
global $db; echo “test”;

$result = $db->query(“DELETE FROM $table WHERE id = $id”);if($result) echo “Deleted!”;
if (is_file("…/fotoos/$id.jpg"))
unlink("…/fotoos/$id.jpg");
}

Test(“2205”);

?>[/php]

The delete query still don’t work inside of a function. Outside the function it works fine. So not my code causes this behavior. So what do you think ??

Because you’re defining $table outside the function.

yes I see I forgot the global $table.

I placed the includes outside a function. Now the delete works.It deletes the text from the database. But first the picture is removed than I have to refresh the page to completely remove the text from showing. Is that normal ?

If you have the delete processing after the text has been already output to the browser, then yes. All the processing should happen before output to the browser. After all these posts I don’t know if anyone has asked if you have error_reporting turned on. It would have saved you a lot of trouble and shown you many of the errors you had in your script.

From now on, place this at the very top of your pages during development and then remove it when the page goes live.
[php]
ini_set(‘display_errors’,1);
error_reporting(E_ALL);
[/php]
This surely would have given you a undefined index error for the $table issue in your function.

I placed the delete before the output but I still have to refresh the page :

[php]foreach($result as $row) {
$i++;

extract($row);
		
if (is_numeric($lidnr)){
	$plaatje="../fotoos/".$id.".jpg";
	$ext = "jpg";
	
	if (!is_file($plaatje)) 
		{$plaatje='../fotoos/blanco.gif'; $ext = "gif";}
	
	$src="resizefoto.php?plaatje=$plaatje&ext=$ext";
	$info = "Spullen:$id <small>$datum</small>";
	
	if($wisbutton[$i])
			Delete($id);
			
	echo "<td class='table-cell'><div id = 'ad'><a href='nwspul_big.php?id=$id' target= '_top'><img id='foto'; src='$src';></a><div id = 'infoblok'>$info</div><div id = 'localtekstblok'>$tekst</div></div>";
	if ($status == $statuscode) {
	
		echo"<input type='submit' id='wisbutton' name='wisbutton[$i]' value='Delete' title='wis advertentie'>";
		
	}
	echo"</td>";
	
}

}[/php]

I’m getting Notice: Undefined variable: wisbutton

Sponsor our Newsletter | Privacy Policy | Terms of Service