Jump to content

unexpected T_ENCAPSED_AND_WHITESPACE


slj90

Recommended Posts

This code checks the users login history and if they have more than 4 failed login attempts in the past 3 minutes it locks their account.

However, I'm receiving the error Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING on line 36

 

36: ($diff = strtotime($row['login_time'])-time();)
 

$la_sql="SELECT login_username, login_time FROM login_attempts WHERE login_username = '$username';
while($row = mysqli_fetch_array($la_sql)) { 
$diff = strtotime($row['login_time'])-time();
if ($diff > -300){ $count = $count + 1; } 
if ($count > 4) { echo "locekd"; } }

What's wrong?

Thanks,

 

Link to comment
Share on other sites

You're missing a closing " at the end of the first line.  SImply viewing the code after you posted it woudl have shwon you that pretty easily ;)

 

Oh yeah, thanks.

 

I'm now getting this error: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given in /home/content/45/10084845/html/your-collection/action/logincheck.php on line 35

correct

Link to comment
Share on other sites

If this is all the code for the query, then yo uforgot to actually run the query.  You're trying to get the results with the fetch_array but yo unever ran the query beforehand.  Also, there is no need for the while() since you are only getting a single row from the db.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.