following code has runtime errors,
"hid" is a hidden in a form
//code
$strWho=$_POST['hid'];//php, error also?
print('<script language="javascript">
alert("It is read"+$strWho);
</script>');
note on line 3: "It is read"+$strWho
what is correct code for above purpose?
thanks
syntax error: how to mix script code with php code
Moderator: General Moderators
-
php12342005
- Forum Commoner
- Posts: 79
- Joined: Mon Mar 21, 2005 3:35 am
Please read Posting Code in the Forums
viewtopic.php?t=21171
Your quotes are messed up:
viewtopic.php?t=21171
Your quotes are messed up:
Code: Select all
//code
<?php
$strWho=$_POST['hid'];//php, error also?
echo '<script language="javascript">';
echo 'alert("It is read ' . $strWho . '");';
echo '</script>';
?>Code: Select all
if (isset($_POST['hid']))
{
$who = $_POST['hid'];
}
else
{
$who = 'Hey, nothing is posted!';
}
echo '<script language="javascript">';
echo 'alert("It is read ' . $who . '");';
echo '</script>';- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia