php - Trying to get property of non-object when i use num_rows -


i had code register users information database, , before save them database has check if email address exists or not. work fine give me error message:

notice: trying property of non-object in x:\xampp\htdocs\csg2431\week4\registeruser.php on line 72

here code form line 72

$email_query = "select emailaddress userdetails emailaddress = '".$emailaddress."'"; $email_results = $db->query($email_query);  if (isset($emial_results)) {     $error_message ='your database empty.'; }  if ($email_results->num_rows > 0)  // line 72 {     $error_message = 'your email address exists, choose anther.'; }  if ($error_message != '') {     echo 'error: '.$error_message. '<a href="javascript: history.back();">go back</a>.';     echo '</body></html>';     exit; } 

it happend other page search user information database,

notice: trying property of non-object in x:\xampp\htdocs\csg2431\week4\searchusers.php on line 43

here code:

$results = $db->query($query);  echo '<p>'.$results->num_rows.' users found.</p>'; // line 43  while ($row = $results->fetch_assoc()) {     echo '<p><strong>name: </strong>'. $row['surname'].','.$row['firstname'].'<br />';      echo '<strong>gender: </strong>'. $row['gender'].',<br />';      echo '<strong>date of birth: </strong>'. $row['dob'].',<br />';      echo '<strong>home phone: </strong>'. $row['homephone'].',<br />';      echo '<strong>position: </strong>'. $row['position_id'].',<br />';      echo '<strong>room number: </strong>'. $row['roomno'].',<br />';      echo '<strong>work phone: </strong>'. $row['workphone'].',<br />';      echo '<strong>fax: </strong>'. $row['fax'].',<br />';      echo '<strong>mobile: </strong>'. $row['mobilephone'].',<br />';      echo '<strong>email: </strong>'. $row['emailaddress'].',<br />';      echo '<strong>department: </strong>'. $row['dept_id'].',<br /></p>'; } 

it looks every time when use num_rows error happens


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -