PHP注意:未定义属性:stdClass:
我从Flash Builder 4中创建的Flash应用程序中得到了一个数组 我有一个服务设置,可以成功地查询数据库并从数据库返回数据,但是更新脚本正在生成未定义的属性错误 我仍在学习PHP和Flash Builder,并不完全理解$this->命令的作用 如果有人能指出这个脚本哪里出了问题,它基本上是由FlashBuilder生成的,不是我自己开发的,我会很感激吗 还有,如果有人能向我解释$this->,那也太棒了 我以前见过它们,但后来我看到脚本做了与不使用它们相同的事情,所以这是一种老方法吗 非常感谢任何人的意见 更新了完整的PHP代码 生成错误 [18-Jun-2010 13:01:37]PHP通知:未定义的属性:stdClass::$inst_代码在C:\wamp\www\Coradia-175105-debug\services\tbltrustservice.PHP的第48行PHP注意:未定义属性:stdClass:,php,Php,我从Flash Builder 4中创建的Flash应用程序中得到了一个数组 我有一个服务设置,可以成功地查询数据库并从数据库返回数据,但是更新脚本正在生成未定义的属性错误 我仍在学习PHP和Flash Builder,并不完全理解$this->命令的作用 如果有人能指出这个脚本哪里出了问题,它基本上是由FlashBuilder生成的,不是我自己开发的,我会很感激吗 还有,如果有人能向我解释$this->,那也太棒了 我以前见过它们,但后来我看到脚本做了与不使用它们相同的事情,所以这是一种老方法
<?php
//reroute errors to get rid of that annoying CHANNEL DISCONNECTED message.
ini_set('error_log', 'errorLog.txt');
ini_set('html_errors', '0');
ini_set('display_errors', '0');
ini_set('log_errors', '1');
class tbltrustservice {
public $connection;
public function connect() {
$this->connection = mysqli_connect("ahoey-1:3306", "<Username Removed For StackOverflow>", "<Password Removed for StackOverflow>", "enabmodules") or die(mysqli_connect_error());
}
public function getAllItems($search) {
$this->connect();
if ($search=="") {
$sql = "SELECT * FROM tbltrust";
} else {
$sql = 'SELECT * FROM tbltrust WHERE trust_name LIKE \'%'.mysql_escape_string($search).'%\' OR trust_code LIKE \''.mysql_escape_string($search).'%\' OR inst_code LIKE \'%'.mysql_escape_string($search).'%\'';
}
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rows = array();
while ($row = mysqli_fetch_object($result)) {
$rows[] = $row;
}
mysqli_free_result($result);
mysqli_close($this->connection);
return $rows;
}
public function updateItem($item) {
// TODO Auto-generated method stub
// Update an existing record in the database and return the item
// Sample code \'
$this->connect();
$sql = "UPDATE tbltrust SET inst_code = '$item->inst_code', trust_name = '$item->trust_name', trust_code = '$item->trust_code' WHERE trust_key = '$item->trust_key'";
mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
mysqli_close($this->connection);
}
/*
public function updateItem($item) {
$stmt = mysqli_prepare($this->connection, "UPDATE $this->tablename SET trust_code=?, trust_name=?, inst_code=? WHERE trust_key=?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'sssi', $item->trust_code, $item->trust_name, $item->inst_code, $item->trust_key);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
}
*/
public function getItem($itemID) {
// TODO Auto-generated method stub
// Return a single record from the database and return the item
// Sample code
/*
$this->connect();
$itemID = mysqli_real_escape_string($this->connection, $itemID);
$sql = "SELECT * FROM books where itemID=$itemID";
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rows = array();
while ($row = mysqli_fetch_object($result)) {
$rows[] = $row;
}
mysqli_free_result($result);
mysqli_close($this->connection);
return $rows;
*/
}
public function createItem($item) {
// TODO Auto-generated method stub
// Insert a new record in the database using the parameter and return the item
// Sample code
/*
$this->connect();
$sql = "INSERT INTO books (title, au_first_name, au_last_name)
VALUES ('$item->title','$item->au_first_name','$item->au_last_name')";
mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$autoid= mysqli_insert_id($this->connection);
mysqli_close($this->connection);
return $autoid;
*/
}
/*
public function updateItem($item) {
$stmt = mysqli_prepare($this->connection, "UPDATE tbltrust SET trust_code=?, trust_name=?, inst_code=? WHERE trust_key=?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'sssi', $item->trust_code, $item->trust_name, $item->inst_code, $item->trust_key);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
} */
public function deleteItem($itemID) {
// TODO Auto-generated method stub
// Delete a record in the database
// Sample code
/*
$this->connect();
$itemID = mysqli_real_escape_string($this->connection, $itemID);
$sql = "DELETE FROM books WHERE itemID = $itemID";
mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
mysqli_close($this->connection);
*/
}
public function count() {
// TODO Auto-generated method stub
// Return the number of items in your array of records
// Sample code
/*
$this->connect();
$sql = "SELECT * FROM books";
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rec_count = mysqli_num_rows($result);
mysqli_free_result($result);
mysqli_close($this->connection);
return $rec_count;
*/
}
public function getItems_paged($startIndex, $numItems) {
// TODO Auto-generated method stub
// Return a page of records as an array from the database for this startIndex
// Sample code
/*
$this->connect();
$startIndex = mysqli_real_escape_string($this->connection, $startIndex);
$numItems = mysqli_real_escape_string($this->connection, $numItems);
$sql = "SELECT * FROM books LIMIT $startIndex, $numItems";
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rows = array();
while ($row = mysqli_fetch_object($result)) {
$rows[] = $row;
}
mysqli_free_result($result);
mysqli_close($this->connection);
return $rows;
*/
}
}
?>
[18-Jun-2010 13:01:37]PHP通知:未定义的属性:stdClass::$trust\u C:\wamp\www\Coradia-175105-debug\services\tbltrustservice.PHP中的名称,第48行
<?php
//reroute errors to get rid of that annoying CHANNEL DISCONNECTED message.
ini_set('error_log', 'errorLog.txt');
ini_set('html_errors', '0');
ini_set('display_errors', '0');
ini_set('log_errors', '1');
class tbltrustservice {
public $connection;
public function connect() {
$this->connection = mysqli_connect("ahoey-1:3306", "<Username Removed For StackOverflow>", "<Password Removed for StackOverflow>", "enabmodules") or die(mysqli_connect_error());
}
public function getAllItems($search) {
$this->connect();
if ($search=="") {
$sql = "SELECT * FROM tbltrust";
} else {
$sql = 'SELECT * FROM tbltrust WHERE trust_name LIKE \'%'.mysql_escape_string($search).'%\' OR trust_code LIKE \''.mysql_escape_string($search).'%\' OR inst_code LIKE \'%'.mysql_escape_string($search).'%\'';
}
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rows = array();
while ($row = mysqli_fetch_object($result)) {
$rows[] = $row;
}
mysqli_free_result($result);
mysqli_close($this->connection);
return $rows;
}
public function updateItem($item) {
// TODO Auto-generated method stub
// Update an existing record in the database and return the item
// Sample code \'
$this->connect();
$sql = "UPDATE tbltrust SET inst_code = '$item->inst_code', trust_name = '$item->trust_name', trust_code = '$item->trust_code' WHERE trust_key = '$item->trust_key'";
mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
mysqli_close($this->connection);
}
/*
public function updateItem($item) {
$stmt = mysqli_prepare($this->connection, "UPDATE $this->tablename SET trust_code=?, trust_name=?, inst_code=? WHERE trust_key=?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'sssi', $item->trust_code, $item->trust_name, $item->inst_code, $item->trust_key);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
}
*/
public function getItem($itemID) {
// TODO Auto-generated method stub
// Return a single record from the database and return the item
// Sample code
/*
$this->connect();
$itemID = mysqli_real_escape_string($this->connection, $itemID);
$sql = "SELECT * FROM books where itemID=$itemID";
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rows = array();
while ($row = mysqli_fetch_object($result)) {
$rows[] = $row;
}
mysqli_free_result($result);
mysqli_close($this->connection);
return $rows;
*/
}
public function createItem($item) {
// TODO Auto-generated method stub
// Insert a new record in the database using the parameter and return the item
// Sample code
/*
$this->connect();
$sql = "INSERT INTO books (title, au_first_name, au_last_name)
VALUES ('$item->title','$item->au_first_name','$item->au_last_name')";
mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$autoid= mysqli_insert_id($this->connection);
mysqli_close($this->connection);
return $autoid;
*/
}
/*
public function updateItem($item) {
$stmt = mysqli_prepare($this->connection, "UPDATE tbltrust SET trust_code=?, trust_name=?, inst_code=? WHERE trust_key=?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'sssi', $item->trust_code, $item->trust_name, $item->inst_code, $item->trust_key);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
} */
public function deleteItem($itemID) {
// TODO Auto-generated method stub
// Delete a record in the database
// Sample code
/*
$this->connect();
$itemID = mysqli_real_escape_string($this->connection, $itemID);
$sql = "DELETE FROM books WHERE itemID = $itemID";
mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
mysqli_close($this->connection);
*/
}
public function count() {
// TODO Auto-generated method stub
// Return the number of items in your array of records
// Sample code
/*
$this->connect();
$sql = "SELECT * FROM books";
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rec_count = mysqli_num_rows($result);
mysqli_free_result($result);
mysqli_close($this->connection);
return $rec_count;
*/
}
public function getItems_paged($startIndex, $numItems) {
// TODO Auto-generated method stub
// Return a page of records as an array from the database for this startIndex
// Sample code
/*
$this->connect();
$startIndex = mysqli_real_escape_string($this->connection, $startIndex);
$numItems = mysqli_real_escape_string($this->connection, $numItems);
$sql = "SELECT * FROM books LIMIT $startIndex, $numItems";
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rows = array();
while ($row = mysqli_fetch_object($result)) {
$rows[] = $row;
}
mysqli_free_result($result);
mysqli_close($this->connection);
return $rows;
*/
}
}
?>
[18-Jun-2010 13:01:38]PHP通知:未定义的属性:stdClass::$trust\u C:\wamp\www\Coradia-175105-debug\services\tbltrustservice.PHP中的代码,第48行
<?php
//reroute errors to get rid of that annoying CHANNEL DISCONNECTED message.
ini_set('error_log', 'errorLog.txt');
ini_set('html_errors', '0');
ini_set('display_errors', '0');
ini_set('log_errors', '1');
class tbltrustservice {
public $connection;
public function connect() {
$this->connection = mysqli_connect("ahoey-1:3306", "<Username Removed For StackOverflow>", "<Password Removed for StackOverflow>", "enabmodules") or die(mysqli_connect_error());
}
public function getAllItems($search) {
$this->connect();
if ($search=="") {
$sql = "SELECT * FROM tbltrust";
} else {
$sql = 'SELECT * FROM tbltrust WHERE trust_name LIKE \'%'.mysql_escape_string($search).'%\' OR trust_code LIKE \''.mysql_escape_string($search).'%\' OR inst_code LIKE \'%'.mysql_escape_string($search).'%\'';
}
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rows = array();
while ($row = mysqli_fetch_object($result)) {
$rows[] = $row;
}
mysqli_free_result($result);
mysqli_close($this->connection);
return $rows;
}
public function updateItem($item) {
// TODO Auto-generated method stub
// Update an existing record in the database and return the item
// Sample code \'
$this->connect();
$sql = "UPDATE tbltrust SET inst_code = '$item->inst_code', trust_name = '$item->trust_name', trust_code = '$item->trust_code' WHERE trust_key = '$item->trust_key'";
mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
mysqli_close($this->connection);
}
/*
public function updateItem($item) {
$stmt = mysqli_prepare($this->connection, "UPDATE $this->tablename SET trust_code=?, trust_name=?, inst_code=? WHERE trust_key=?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'sssi', $item->trust_code, $item->trust_name, $item->inst_code, $item->trust_key);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
}
*/
public function getItem($itemID) {
// TODO Auto-generated method stub
// Return a single record from the database and return the item
// Sample code
/*
$this->connect();
$itemID = mysqli_real_escape_string($this->connection, $itemID);
$sql = "SELECT * FROM books where itemID=$itemID";
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rows = array();
while ($row = mysqli_fetch_object($result)) {
$rows[] = $row;
}
mysqli_free_result($result);
mysqli_close($this->connection);
return $rows;
*/
}
public function createItem($item) {
// TODO Auto-generated method stub
// Insert a new record in the database using the parameter and return the item
// Sample code
/*
$this->connect();
$sql = "INSERT INTO books (title, au_first_name, au_last_name)
VALUES ('$item->title','$item->au_first_name','$item->au_last_name')";
mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$autoid= mysqli_insert_id($this->connection);
mysqli_close($this->connection);
return $autoid;
*/
}
/*
public function updateItem($item) {
$stmt = mysqli_prepare($this->connection, "UPDATE tbltrust SET trust_code=?, trust_name=?, inst_code=? WHERE trust_key=?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'sssi', $item->trust_code, $item->trust_name, $item->inst_code, $item->trust_key);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
} */
public function deleteItem($itemID) {
// TODO Auto-generated method stub
// Delete a record in the database
// Sample code
/*
$this->connect();
$itemID = mysqli_real_escape_string($this->connection, $itemID);
$sql = "DELETE FROM books WHERE itemID = $itemID";
mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
mysqli_close($this->connection);
*/
}
public function count() {
// TODO Auto-generated method stub
// Return the number of items in your array of records
// Sample code
/*
$this->connect();
$sql = "SELECT * FROM books";
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rec_count = mysqli_num_rows($result);
mysqli_free_result($result);
mysqli_close($this->connection);
return $rec_count;
*/
}
public function getItems_paged($startIndex, $numItems) {
// TODO Auto-generated method stub
// Return a page of records as an array from the database for this startIndex
// Sample code
/*
$this->connect();
$startIndex = mysqli_real_escape_string($this->connection, $startIndex);
$numItems = mysqli_real_escape_string($this->connection, $numItems);
$sql = "SELECT * FROM books LIMIT $startIndex, $numItems";
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rows = array();
while ($row = mysqli_fetch_object($result)) {
$rows[] = $row;
}
mysqli_free_result($result);
mysqli_close($this->connection);
return $rows;
*/
}
}
?>
[18-Jun-2010 13:01:38]PHP通知:未定义属性:stdClass::$trust\u在第48行的C:\wamp\www\Coradia-175105-debug\services\tbltrustservice.PHP中输入key
<?php
//reroute errors to get rid of that annoying CHANNEL DISCONNECTED message.
ini_set('error_log', 'errorLog.txt');
ini_set('html_errors', '0');
ini_set('display_errors', '0');
ini_set('log_errors', '1');
class tbltrustservice {
public $connection;
public function connect() {
$this->connection = mysqli_connect("ahoey-1:3306", "<Username Removed For StackOverflow>", "<Password Removed for StackOverflow>", "enabmodules") or die(mysqli_connect_error());
}
public function getAllItems($search) {
$this->connect();
if ($search=="") {
$sql = "SELECT * FROM tbltrust";
} else {
$sql = 'SELECT * FROM tbltrust WHERE trust_name LIKE \'%'.mysql_escape_string($search).'%\' OR trust_code LIKE \''.mysql_escape_string($search).'%\' OR inst_code LIKE \'%'.mysql_escape_string($search).'%\'';
}
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rows = array();
while ($row = mysqli_fetch_object($result)) {
$rows[] = $row;
}
mysqli_free_result($result);
mysqli_close($this->connection);
return $rows;
}
public function updateItem($item) {
// TODO Auto-generated method stub
// Update an existing record in the database and return the item
// Sample code \'
$this->connect();
$sql = "UPDATE tbltrust SET inst_code = '$item->inst_code', trust_name = '$item->trust_name', trust_code = '$item->trust_code' WHERE trust_key = '$item->trust_key'";
mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
mysqli_close($this->connection);
}
/*
public function updateItem($item) {
$stmt = mysqli_prepare($this->connection, "UPDATE $this->tablename SET trust_code=?, trust_name=?, inst_code=? WHERE trust_key=?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'sssi', $item->trust_code, $item->trust_name, $item->inst_code, $item->trust_key);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
}
*/
public function getItem($itemID) {
// TODO Auto-generated method stub
// Return a single record from the database and return the item
// Sample code
/*
$this->connect();
$itemID = mysqli_real_escape_string($this->connection, $itemID);
$sql = "SELECT * FROM books where itemID=$itemID";
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rows = array();
while ($row = mysqli_fetch_object($result)) {
$rows[] = $row;
}
mysqli_free_result($result);
mysqli_close($this->connection);
return $rows;
*/
}
public function createItem($item) {
// TODO Auto-generated method stub
// Insert a new record in the database using the parameter and return the item
// Sample code
/*
$this->connect();
$sql = "INSERT INTO books (title, au_first_name, au_last_name)
VALUES ('$item->title','$item->au_first_name','$item->au_last_name')";
mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$autoid= mysqli_insert_id($this->connection);
mysqli_close($this->connection);
return $autoid;
*/
}
/*
public function updateItem($item) {
$stmt = mysqli_prepare($this->connection, "UPDATE tbltrust SET trust_code=?, trust_name=?, inst_code=? WHERE trust_key=?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'sssi', $item->trust_code, $item->trust_name, $item->inst_code, $item->trust_key);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
} */
public function deleteItem($itemID) {
// TODO Auto-generated method stub
// Delete a record in the database
// Sample code
/*
$this->connect();
$itemID = mysqli_real_escape_string($this->connection, $itemID);
$sql = "DELETE FROM books WHERE itemID = $itemID";
mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
mysqli_close($this->connection);
*/
}
public function count() {
// TODO Auto-generated method stub
// Return the number of items in your array of records
// Sample code
/*
$this->connect();
$sql = "SELECT * FROM books";
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rec_count = mysqli_num_rows($result);
mysqli_free_result($result);
mysqli_close($this->connection);
return $rec_count;
*/
}
public function getItems_paged($startIndex, $numItems) {
// TODO Auto-generated method stub
// Return a page of records as an array from the database for this startIndex
// Sample code
/*
$this->connect();
$startIndex = mysqli_real_escape_string($this->connection, $startIndex);
$numItems = mysqli_real_escape_string($this->connection, $numItems);
$sql = "SELECT * FROM books LIMIT $startIndex, $numItems";
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rows = array();
while ($row = mysqli_fetch_object($result)) {
$rows[] = $row;
}
mysqli_free_result($result);
mysqli_close($this->connection);
return $rows;
*/
}
}
?>
噢,天哪:)
$这是您所在的当前对象的“名称”。我相信你刚刚从一个更大的物体内部复制了这个函数,把它粘贴在一个随机的地方,现在它停止了工作,因为它缺少了它自身的重要部分
要使用该脚本,您需要完整的源代码。您最好尝试学习一些PHP基础知识,否则您将很难自己理解它们。哦,天哪:)
$这是您所在的当前对象的“名称”。我相信你刚刚从一个更大的物体内部复制了这个函数,把它粘贴在一个随机的地方,现在它停止了工作,因为它缺少了它自身的重要部分
要使用该脚本,您需要完整的源代码。您最好尝试学习一些PHP基础知识,否则您将很难自己理解它们。能否添加准确的错误消息以及它们出现在哪一行?请尽快学习您正在编写的语言。巧合编程要比正确编程花费更多的精力。你能添加准确的错误消息以及它们出现在哪一行吗?尽快学习你正在编码的语言。巧合编程比正确编程需要付出更多的努力。是的,我同意每个人的观点,即意外编程是不可取的。我已经发布了页面上的完整PHP代码,以及我收到的错误。这段PHP代码是由FlashBuilder本身而不是我自己生成的。干杯。是的,我同意每个人的观点,意外编程是不可取的。我已经发布了页面上的完整PHP代码,以及我收到的错误。这段PHP代码是由FlashBuilder本身而不是我自己生成的。干杯