Reputation: 628
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/style.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script src="./js/jquery.js"></script>
<script src="./js/laddubox.js"></script>
<script src="./js/pop.js"></script>
<script src="./js/jquery.js"></script>
<script type="text/javascript">
var sbs = {
'url' : '<?="./gearedup-pics/"?>',
'logged' : '<?=$notregister?>',
'userid' : '<?= $id ?>',
'father' : '<?= $father ?>' ,
'mother' : '<?= $mother ?>',
'kid' : "<?= $kid ?>"
};
</script>
<title><?=$title?></title>
</head>
I am sending information via javascript using php but $kid ,$mother and $father are in array format . So its showing me an error.
Notice: Array to string conversion in C:\xampp\htdocs\sbs\sbs\html\meta.php on line 19
Array' ,
Upvotes: 0
Views: 53
Reputation: 29424
<?=
converts the variable to a string and outputs it. Implicitly converting arrays to strings results in a notice (not an error).
I advise you to use json_encode()
:
<?php
$data = array(
'url' => './gearedup-pics/',
'logged' => $notregister,
'userid' => $id,
'father' => $father,
'mother' => $mother,
'kid' => $kid
);
?>
var sbs = <?php echo json_encode($data); ?>;
Upvotes: 5