hi friends,
Its me again, I just wanted to know how can write a javascript code in a php.
i have written complete php but wheni write the following lines i get error
following is the code
<?
if(0!=strcmp( $eml, $sr_rec[EML]) )
{
?>
<html>
<SCRIPT LANGUAGE="JavaScript">
function UpdtEID() {
$myact_EMLquery="UPDATE my_act set EML='".$eml."' where SRN='".$sr_no."'";
mysql_query($myact_EMLquery) or die (mysql_error());
$EMLrec_no=mysql_affected_rows();
if( $EMLrec_no!=1)
{
header("Location: error.php?error=10");
exit();
}
// alert("Hello, have a nice day!");
}
</SCRIPT>
<FORM>
<br>
<font face="Arial" size="4" color="black">
<b>
Update Email-ID
</b> <br>
<INPUT TYPE="BUTTON" VALUE="Update Email-ID " onClick="UpdtEID()">
</FORM>
</html>
<? }
echo "The renewal details has been sent to the registered email address.<br>
Please check your mails.<br>
Thank you.";
?>
i get on last line as parse error $ found. if not written in this format <?script ?>
and if i directly write the
Script language = ...
then i am getting Parse error '<' on the line where The <Script Lan...> is written.
How Do i go @ it ???
It really troubling me alot.
ANy help any suggetion welcome
TAHNX in Advance
php & javascript
Moderator: General Moderators
You're really mixing up Javascript and PHP here. UpdtEID has a bunch of PHP code, but it's not in between <?php ?> tags. Therefore it's just being output as text, which is being interpreted as a Javascript function, which, of course, is breaking. If you're trying to get Javascript to call a PHP function, your out of luck. The closest you can get is either get PHP to generate a Javacript function of similar functionality at load time, or use Javascript to load another page, which by being accessed, runs some PHP code.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.