i can't get my "updatebeer.php" to work:

$db     = "c:/server/sqlite/selection.db";
  $handle = sqlite_open($db) or die("Could not open database");
	$query  = "";

if (isset($_POST['tableName'])
 && isset($_POST['item_id']) {
  $table = sqlite_escape_string($_POST['tableName']);
  $id = sqlite_escape_string($_POST['item_id']);

	if (isset($_POST['Delete'])) {
	  echo "Delete";

  $query   = "DELETE FROM $table WHERE item_id='$id'";
		$result  = sqlite_query($handle, $query) or die("Error in query: ".sqlite_error_string(sqlite_last_error($handle)));
	} 
elseif (isset($_POST['Update'])) {
	  echo "Update";

  if (!empty($_POST['title'])
		 && !empty($_POST['info_dk'])
		 && !empty($_POST['info_uk'])
		 && !empty($_POST['land'])
		 && !empty($_POST['vol'])
     && !empty($_POST['size'])
		 && !empty($_POST['price'])) {

			$title	 = sqlite_escape_string($_POST['title']);
			$info_dk = sqlite_escape_string($_POST['info_dk']);
			$info_uk = sqlite_escape_string($_POST['info_uk']);
			$land	   = sqlite_escape_string($_POST['land']);
			$vol     = sqlite_escape_string($_POST['vol']);
      $size		 = sqlite_escape_string($_POST['size']);
			$price	 = sqlite_escape_string($_POST['price']);

	    $query = "UPDATE $table SET
							 title=\"$title\",
							 info_dk=\"$info_dk\",
							 info_uk=\"$info_uk\",
							 land=\"$land\",
							 vol=\"$vol\",
               size=\"$size\",
							 price=\"$price\"
							 WHERE item_id='$id'";
			$result = sqlite_query($handle, $query) or die("Error in query: ".sqlite_error_string(sqlite_last_error($handle)));
		}
	} else {
	  echo "Returning to main, no changes.";
	}
	header ("Location: ../index2.php?tableName=$table");
	exit;

i cant find the error... 🙁

    seeing as you dont tell us what the error is (big hint - this is helpfull info to supply), i'll just have a guess and say your query should look more like;

    $query = "UPDATE $table SET 
                       title='$title', 
                       info_dk='$info_dk', 
                       info_uk='$info_uk', 
                       land='$land', 
                       vol='$vol', 
                       size='$size', 
                       price='$price' 
                       WHERE item_id=$id";
    

      i don't get any errors, just it freezes the screen at updatebeer.php...
      I can't delete or update the table.

        Write a Reply...