Jump to content

PHP remember user (cookie)

Joveice
Go to solution Solved by leonfagan71,
Just now, Joveice said:

Is this all I need to do?

yes, basically.

session_set_cookie_params(3600 * 24 * 7);

needs to go just before the first 

session_start();

 

it cannot go after it, it must be before the session is started.

 

It will then have the session on the server and the client for 7 days.

1 minute ago, leonfagan71 said:

it should print the SQL error onto the page.

Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in script.php:87 Stack trace: #0 {main} thrown in script.php on line 87

 

Back-end developer, electronics "hacker"

Link to comment
Share on other sites

Link to post
Share on other sites

15 minutes ago, Joveice said:

I don't see whats wrong, could you help?

testr.png

Okay, the issue here sounds like a MySQL query failing.

could you pop single quotes before and after the question marks in the values area?

like VALUES ('?', '?', '?', '?',..........

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, leonfagan71 said:

Okay, the issue here sounds like a MySQL query failing.

could you pop single quotes before and after the question marks in the values area?

like VALUES ('?', '?', '?', '?',..........

same error again

Back-end developer, electronics "hacker"

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, Joveice said:

Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in script.php:87 Stack trace: #0 {main} thrown in script.php on line 87

 

Another thing sorry, I personally just use the variables in the query like::

mysqli_query($link, "INSERT INTO `batman` (`name`, `cool`, `level`) VALUES ('{$name}', '{$coolval}', '$level');");

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Joveice said:

same error again

THO it created the table in the database

Back-end developer, electronics "hacker"

Link to comment
Share on other sites

Link to post
Share on other sites

6 minutes ago, Joveice said:

THO it created the table in the database

and removing the ' from everything in prepare created a table and displayed this


Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in script.php on line 95

 

Back-end developer, electronics "hacker"

Link to comment
Share on other sites

Link to post
Share on other sites

12 minutes ago, Joveice said:

THO it created the table in the database

that means that the mysqli_query has now succeeded.

 

Next thing to look at is the bind params bit.

INSERT INTO `newmatch` (`uid`, `t1p1`, `t1p2`, `t1p3`, `t1p4`, `t1p5`, `rank`, `date`) VALUES ('{$username}','{$player1}','{$player2}','{$player3}','{$player4}','{$player5}','{$option2}','{$date}');

can you put this into the prepare line and comment out the line with bind_param.

 

if any of the fields are blank on the database, please let me know which ones.

 

Cheers,

Leon.

Link to comment
Share on other sites

Link to post
Share on other sites

6 minutes ago, leonfagan71 said:

that means that the mysqli_query has now succeeded.

 

Next thing to look at is the bind params bit.


INSERT INTO `newmatch` (`uid`, `t1p1`, `t1p2`, `t1p3`, `t1p4`, `t1p5`, `rank`, `date`) VALUES ('{$username}','{$player1}','{$player2}','{$player3}','{$player4}','{$player5}','{$option2}','{$date}');

can you put this into the prepare line and comment out the line with bind_param.

 

if any of the fields are blank on the database, please let me know which ones.

 

Cheers,

Leon.

Notice: Undefined variable: username in script.php on line 86

Notice: Undefined variable: date in script.php on line 86

and uid and date is empty, (when I removed all ' they where also filled

Back-end developer, electronics "hacker"

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Joveice said:

Notice: Undefined variable: username in script.php on line 86

Notice: Undefined variable: date in script.php on line 86

and uid and date is empty, (when I removed all ' they where also filled

Cool, that will explain it then.. the $date and $username are being defined after the bind_param and that is why it was failing, if you move the $date and the $username to before the prepare then it should work, then you may be able to put bind_param back in if you really want to.

 

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Joveice said:

No idea again, but now it works

testr.png

Might be worth moving lines 89-90 to before the prepare statement, 85.

 

 

Link to comment
Share on other sites

Link to post
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

×