PHP: Why when I print the contents of the session ignores the leading zero?

Question!

I've a problem when print the content session, because when create the session, the variable is string (varchar obtained from a mysql field):

Initial variable: 09680040

Print with alert or display in div: 9680040

???

PHP CODE

$query = "SELECT nombre, apellidop, apellidom, tUser FROM users WHERE ncontrol = '$numeroControl'";
$result = mysql_query($query) or die (mysql_error());
$no_of_rows = mysql_num_rows($result);
if ($no_of_rows > 0) {
    $result = mysql_fetch_array($result);
    $_SESSION['n_control'] = $user['ncontrol'];
}

JS CODE
........
alert <?php echo $_SESSION['n_control'];?>;

JQuery CODE

('#div').html(<?php echo $_SESSION['n_control']; ?>);

EDIT: The problem is only when display alert, and when put content on div in jquery



Answers

Try:

 $_SESSION['n_control'] = strval($user['ncontrol']);
By : Cymbals


This video can help you solving your question :)
By: admin