function Postedit () {$this->load->helper ("url"), $this->load->helper ("form");//$sql = "SELECT * FROM UserInfo where username = ' zhangning ' "; $data [" user "] = $this->db->query (" select * from userinfo where username = ' ". $this->uri->segment (3). "'"); $this->load->view ("Postedit", $data);}
Front desk:
Age?>
A PHP Error was encountered
Severity:notice
message:undefined Property:ci_db_mysql_result:: $Age
filename:views/postedit.php
Line Number:9
What's the reason? I've been looking for a long day. Just learned 2 3 days. I can't see what's wrong with it.
$data ["user"] = "FSDFSD"; if so, the foreground output is worth
Reply to discussion (solution)
This mistake can be ignored, define the level of error is OK.
Your query is just inquiry, did not return the results ah, you look at the CI Handbook
This mistake can be ignored, define the level of error is OK.
Your query is just inquiry, did not return the results ah, you look at the CI Handbook
That's not what you're talking about.
Under the database folder under the System file
/** * Execute the query * * accepts an SQL string as input and returns a result object upon * successful execution of a "R EAD "type query. Returns Boolean TRUE * Upon successful execution of a "write" type query. Returns Boolean * FALSE upon failure, and if the $db _DEBUG variable is set to TRUE * would raise an error. * * @accesspublic * @paramstringAn SQL query String * @paramarrayAn array of binding data * @returnmixed */function query ( $sql, $binds = FALSE, $return _object = TRUE) {if ($sql = = ") {if ($this->db_debug) {log_message (' error ', ' Invalid query: '. $sql); return $this->display_error (' Db_invalid_query ');} return FALSE;} Verify table prefix and replace if Necessaryif (($this->dbprefix! = "and $this->swap_pre! =") and ($this-> ;d Bprefix! = $this->swap_pre)) {$sql = Preg_replace ("/(\w)". $this->swap_pre. " (\s+?) /"," \\1 ". $this->dbprefix." \\2 ", $sql);} Compile binds if Neededif ($binds!== FALSE) {$sql = $this->compile_binds ($sql, $binds);} is query CAChing enabled? If the query is a "read type"//We'll load the caching class and return the previously//cached query if it existsif ($t his->cache_on = = TRUE and Stristr ($sql, ' SELECT ')) {if ($this->_cache_init ()) {$this->load_rdriver (); if (FALSE !== ($cache = $this->cache->read ($sql))) {return $cache;}}} Save the query for debuggingif ($this->save_queries = = TRUE) {$this->queries[] = $sql;} Start the Query timer$time_start = List ($SM, $ss) = Explode (', microtime ());//Run the queryif (FALSE = = = ($this result_id = $this->simple_query ($sql))) {if ($this->save_queries = = TRUE) {$this->query_times[] = 0;} This would trigger a rollback if transactions is being Used$this->_trans_status = false;if ($this->db_debug) {//G Rab the error number and message now, as we might run some//additional queries before displaying the ERROR$ERROR_NO = $th Is->_error_number (); $error _msg = $this->_error_message ();//We Call the This function in order to Roll-backqueries//if transactions is enabled. If we don ' t call this here//the error message would trigger an exit, causing the//transactions to remain in limbo. $this-& Gt;trans_complete ();//Log and display errorslog_message (' Error ', ' Query error: '. $error _msg); return $this->display _error (Array (' ERROR number: '. $error _no, $error _msg, $sql));} return FALSE;} Stop and aggregate the query time Results$time_end = List ($em, $es) = Explode ("', Microtime ()); $this->benchmark + = ($em + $es)-($SM + $ss), if ($this->save_queries = = TRUE) {$this->query_times[] = ($em + $es)-($SM + $ss);} Increment the query counter$this->query_count++;//was the query a "write" type?//If so we'll simply return Trueif ($this->is_write_type ($sql) = = = TRUE) {//If caching is enabled we ' ll auto-cleanup any//existing files related to this particular uriif ($this->cache_on = = True and $this->cache_autodel = = True and $this->_cache_init ()) {$this->cache->delete ();} return TRUE;} Return TRUE if we don ' t need to create a result object//currently only the Oracle driver uses this when stored//procedures is use DIF ($return _object!== true) {return true;} Load and instantiate the result driver$driver= $this->load_rdriver (); $RES = new $driver (); $RES->conn_id= $this-& gt;conn_id, $RES->result_id= $this->result_id;if ($this->dbdriver = = ' Oci8 ') {$RES->stmt_id= $this stmt_id; $RES->curs_id= NULL; $RES->limit_used= $this->limit_used; $this->stmt_id= FALSE;} Oci8 VARs must be set before calling this$res->num_rows= $RES->num_rows ();//Is query caching enabled? If So, we'll serialize the//result object and save it to a cache File.if ($this->cache_on = = TRUE and $this->_cache _init ()) {//we ' ll create a new instance of the result object//only without the platform specific driver since//We can ' t Use it with cached data (the query result//resource ID won ' t is any good once we ' ve cached the//result object, so we ' ll Has to compile the dataand save it) $CR = new Ci_db_result (); $CR->num_rows= $RES->num_rows (); $CR->result_object= $RES->result_ Object (); $CR->result_array= $RES->result_array ();//Reset These since cached objects can not utilize resource ids.$ cr->conn_id= null; $CR->result_id= null; $this->cache->write ($sql, $CR);} return $RES;}
The DB class is put in that place, you just read the manual tutorial at first glance.
$user->age for $user->age
The variable name of PHP, the property name of the object, and the associated key of the array are case-sensitive
Your $user->age is the query result ($data ["user"] = $this->db->query ("SELECT * from Use .... )
If it can be written like this, then the corresponding field name must also be age, but generally do not write so, but the habitual all lowercase
All right. I know what the reason is.
Or I'm not familiar with PHP's reasons.
These things should be read more CI more trained line
Grey often thanks 2 bit!!