0

I know this will probably be very simple, but I don't find a solution.

I am trying to add a class 'inactivelicence' to an object () when the database row 'glider' in table 'users' and where 'username = $u' equals '1'.

This is the code I have now (I only post the code that matters):

<?php
include_once("php_includes/check_login_status.php");

$u = "";
$glider = "";

if(isset($_GET["u"])){
    $u = preg_replace('#[^a-z0-9]#i', '', $_GET['u']);
} else {
    header("location: index.html");
    exit(); 
}

$sql = "SELECT * FROM users WHERE username='$u' AND activated='1' LIMIT 1";
$user_query = mysqli_query($db_conx, $sql);

while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {

    $glider= $row["glider"];

}

if($glider == "1"){
    echo "<script>$('#glider').addClass('inactivelicence')</script>"; 
}

?>

<div class="licences">

    <img id="glider" src="img/licences/icon_hc.png" > 

</div>

UPDATE:

I now have this code :

echo "<script>$(document).ready(function(){$('#glider').addClass('inactivelicence')})‌​;</script>"; 

But I still get an error on this line.. Error: Parse error: syntax error, unexpected '(', expecting T_VARIABLE or '$' in /home/a3318252/public_html/user.php on line 64

1 Answers1

0
if($glider == "1"){
    echo "<script>$(document).ready(function(){$('#glider').addClass('inactivelicence')});</script>"; 
}
Lal
  • 14,726
  • 4
  • 45
  • 70
user3227295
  • 2,168
  • 1
  • 11
  • 17
  • Then I get this error: Parse error: syntax error, unexpected '(', expecting T_VARIABLE or '$' in /home/a3318252/public_html/user.php on line 64 – Senne Vandenputte Jun 14 '15 at 16:19
  • you missed a `.` in `$(document).ready()`..edited the answer.. – Lal Jun 14 '15 at 16:30
  • Still gives me the same error (Parse error: syntax error, unexpected '(', expecting T_VARIABLE or '$' in /home/a3318252/public_html/user.php on line 64) on this line: `echo ""; ` – Senne Vandenputte Jun 14 '15 at 16:35