Good day! I am having this problem on the update part of my code. Whenever I click my button for update, it gives me this error: Undefined variable Call Stack #TimeMemoryFunctionLocation 10.0006379256 . What did error did I made? Please I need your help. Here is my code:
<?php
session_start();
include_once "../styles/header-menu-out.php";
include "dbconnection.php";
function __autoload($class){
include_once("../main/".$class.".php");}
$code = new codex("localhost","library_books","root","" );
$books = $code->showData("book_info");
$id = $_REQUEST['update'];
?>
<html>
<head><link rel="stylesheet" type="text/css" href="../styles/library_style.css"></head>
<title>Book-A-Holic: Update an Item</title>
<body>
<table>
<?php foreach ($books as $book){ ?>
<tr><td><input type="Hidden" name="id" value="<?php echo $id; ?>"/></td></tr>
<tr><td>Title</td><td><input type="text" name="title" value="<?php echo $title; ?>"/></td></tr>
<tr><td>Author</td><td><input type="text" name="author" value="<?php echo $author; ?>"/></td></tr>
<tr><td>ISBN</td><td><input type="text" name="isbn" value="<?php echo $isbn; ?>"/></td></tr>
<tr><td>Publisher</td><td><input type="text" name="publisher" value="<?php echo $publisher; ?>"/></td></tr>
<tr><td>Language</td><td><input type="text" name="language" value="<?php echo $language; ?>"/></td></tr>
<tr>
<td>Genre</td>
<td><select name="genre">
<option value="<?php echo $genre; ?>"><?php echo $genre; ?></option>
<option value="Non-Fiction">Non-Fiction</option>
<option value="Fiction">Fiction</option>
<option value="Educational">Educational</option>
<option value="Reserved">Reserved</option>
<option value="Instructional Materials">Instructional Materials</option>
</select>
</td>
</tr>
<tr><td>Quantity</td><td><input type="text" name="quantity" value="<?php echo $quantity; ?>"/></td></tr>
<tr>
<td>Availability</td>
<td><select name="availability">
<option value="<?php echo $availability; ?>"></option>
<option value="Available">Yes</option>
<option value="N/A">No</option>
</select>
</td>
</tr>
<tr><td>Queue</td><td><input type="text" name="queue" value="<?php echo $queue; ?>"/></td></tr>
<?php } ?>
<tr>
<td></td>
<td>
<button class="mybutton"><a href="bookUpdate.php?update=<?php echo urlencode($id); ?>">Update</a></button>
<button class="mybutton"><a href="bookDeleteUI.php">Cancel</a></button>
</td>
</tr>
</table>
</body>
</html>
my oop code:
public function updateData($id, $title, $author, $isbn, $publisher, $language, $genre, $quantity, $queue, $availability, $table)
{
$q = "UPDATE $table SET title = '$title', author = '$author', isbn = '$isbn', publisher = '$publisher',language = '$language', genre = '$genre', quantity = '$quantity', availability = '$availability', queue = '$queue' WHERE id ='$id'";
$stmt = $this->con->prepare($q);
$stmt->execute(array(':title'=>$title,':author'=>$author,':isbn'=>$isbn,':publisher'=>$publisher,':language'=>$language, ':genre'=>$genre,':quantity'=>$quantity,':availability'=>$availability,':queue'=>$queue));
return true;
}
thanks in advance.