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
https://forums.phpfreaks.com/topic/294982-unexpected-t_encapsed_and_whitespace/
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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.