美好的一天! 我在我的代碼的更新部分有這個問題。每當我點擊我的按鈕更新,它給了我這個錯誤:未定義的變量調用堆棧#TimeMemoryFunctionLocation 10.0006379256。我做了什麼錯誤?拜託我需要你的幫忙。 這裏是我的代碼:未定義變量調用堆棧#TimeMemoryFunctionLocation 10.0006379256
<?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>
我OOP代碼:
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;
}
在此先感謝。
可能重複[參考 - 此錯誤在PHP中有何含義?](http://stackoverflow.com/questions/ 12769982/reference-what-does-this-error-mean-in-php) – DCoder
你從哪裏閱讀過關於如何使用準備好的語句的方式?這就像,你應該在做什麼:)極性相反:) –
謝謝你的幫助先生。你能告訴我該怎麼做,以避免這種編碼? – user12345654