Jump to content

[PHP] Problem


MarkT

Recommended Posts

If the session ID is null then it sounds like you did not print out the query to verify it. That's why I said you should never assume anything, always verify.
Maybe you need to verify the values of $name and $email? Are you extracting them from $_POST, maybe? Could that be a problem?
What should I do now then?
Link to comment
Share on other sites

You should be trying to figure out why your $_SESSION['id'] is null. Where are you starting session?

Link to comment
Share on other sites

In order to verify things you need to print them, so you can see what the values are. Print your SQL queries, print the values in the session, print everything that you're using. Print all of the data. The point is to verify all of the data so you can check if something is not what you expect it to be.

Link to comment
Share on other sites

My $_SESSION['id'] returns null.These are where it sets the Session variable; $id = mysql_query("SELECT * FROM `users` WHERE `name` = '{$name}' AND `email` = '{$email}'");$ida = mysql_fetch_assoc($id); $_SESSION['id'] = $ida['id2'];

Link to comment
Share on other sites

You should verify that the value that it gets from the database and stores in the session is correct, it might not be getting anything from the database. Or the record might have a blank value for that field.

Link to comment
Share on other sites

You should verify that the value that it gets from the database and stores in the session is correct, it might not be getting anything from the database. Or the record might have a blank value for that field.
Am i right to use mysql_fetch_assoc, and did I use it the right way etc?
Link to comment
Share on other sites

 

 

Am i right to use mysql_fetch_assoc, and did I use it the right way etc?

That's the right way to use it, but you should check for errors whenever you run a query:

 

$id = mysql_query("SELECT * FROM `users` WHERE `name` = '{$name}' AND `email` = '{$email}'") or exit(mysql_error());

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...