Note that there are some explanatory texts on larger screens.

plurals
  1. POUser Log in page
    primarykey
    data
    text
    <p>I have posted similar code here recently but still couldn't get it working properly. I have attempted to rewrite the script but it's still not working - all i am getting is a grey box in the top right corner of the screen. The idea is that someone logs in and this is used to display their profile information to the screen. I am trying to get the users data from the row that matches their email address which I am using as the username.</p> <p>Any help would be greatly appreciated as this is the last bit I need to get working to complete the technical bits of my site.</p> <p>Thanks.</p> <pre><code>&lt;?php # DISPLAY USER DATA/PROFILE # Access session. session_start() ; # Redirect if not logged in. if ( !isset( $_SESSION[ 'user_id' ] ) ) { require ( 'login_tools.php' ) ; load() ; } # Set page title and display header section. $page_title = 'Forum' ; # Open database connection. require ( 'connect_db.php' ) ; # Display body section, retrieving from 'forum' database table. $q = "SELECT * FROM users WHERE email = {$_SESSION['email']}" ; $r = mysqli_query( $dbc, $q ) ; echo '&lt;tr&gt;&lt;td&gt;' . $r['first_name'] .' '. $r['last_name'] . '&lt;br&gt;'. $r['email'].'&lt;/td&gt; &lt;td&gt;' . '&lt;/td&gt;&lt;td&gt;' . '&lt;/td&gt; &lt;/tr&gt;'; # Close database connection. mysqli_close( $dbc ) ; ?&gt; </code></pre> <p>*<strong><em>NOW</em>*</strong></p> <pre><code>&lt;?php # DISPLAY COMPLETE FORUM PAGE. # Access session. session_start() ; # Redirect if not logged in. if ( !isset( $_SESSION[ 'user_id' ] ) ) { require ( 'login_tools.php' ) ; load() ; } # Set page title and display header section. $page_title = 'Forum' ; # Open database connection. require ( 'connect_db.php' ) ; # Display body section, retrieving from 'forum' database table. $q = "SELECT * FROM users WHERE email = {$_SESSION['email']}" ; $r = mysqli_query( $dbc, $q ) ; $results = $r -&gt; fetchAssoc() ; echo '&lt;tr&gt;&lt;td&gt;' . $results['first_name'] .' '. $r['last_name'] . '&lt;br&gt;'. $r['email'].'&lt;/td&gt; &lt;td&gt;' . '&lt;/td&gt;&lt;td&gt;' . '&lt;/td&gt; &lt;/tr&gt;'; # Close database connection. mysqli_close( $dbc ) ; ?&gt; </code></pre> <p>The error now shows " Call to a member function fetchAssoc() on a non-object" - line 19 which is the new line that I have added $results = $r -> fetchAssoc() ;</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload