Access denied error to database from my website when i try to register a user

I have 2 tickets with them and they have yet to respond back. They took me in circles before they opened the tickets.

The code a gave you works successfully on my local xampp server. Registers the users successfully in the database.

Yeah. There’s nothing wrong with the code (per-se. We could go into prepared statements…), it’s failing because the database connection hasn’t got the permissions you think it should.

and hostgator cant seem to figure that out.Maybe i should try another hosting

After many failed attempts going in circles with hostgator support, explaining over and over again the issues for them to come back with same reference that they couldn’t replicate the error and my database was empty(offcourse it would be empty if no data is being written to it), i decided to create a new database with different name and different password, IT WORKED! i suspect maybe the database name i used is the issue.

@m_hutley What code should i add and where to display username of a logged in user? Thank you.

Well you’ve written the username to the session. So on any page you’ve 'start’ed (really ‘start or continue’) the session on, you can simply echo $_SESSION['username']

@m_hutley is this the right place to put the echo session code, see below code from my login.php code…

<?php  if (isset($_SESSION['username'])) : ?>
			<p>Welcome <strong><?php echo $_SESSION['username']; ?></strong></p>
		     <?php echo $_SESSION['username'] ?>
			<p> <a href="index.html" style="color: red;">logout</a> </p>
		<?php endif ?>

Well other than the fact that you’re doing it twice, you mean?

Where is that code? We can’t say if it’s in the right place as you haven’t shown it in context.

PS - it’s getting a bit difficult discussing this point in two separate threads.

The issue is fixed. Created a new database with new new user and password and it started working.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.