Page 1 of 1

still newbie: syntax error:

Posted: Fri Jul 29, 2005 8:21 am
by php12342005
php code:

-------------------------------------
function Alert($str)
{
echo("<script language='javascript'>");
echo("alert('$str');");
echo("</script>");
}

$str="Error: ".mysql_error();
Alert($str);//last line
-------------------------------------

problem is last line:
test (all OK)
1) if $str="PPPPP";
2) or: if last line changes to echo($str);

error is: Expected ')'

what is the matter?

Posted: Fri Jul 29, 2005 8:27 am
by tores
I don't know if this is identical to the code you're using, but your function is named Alert and you call it with Aleat

Posted: Fri Jul 29, 2005 8:29 am
by Todd_Z
Look at posting rules before the mods yell at you

it does say Aleat instead of Alert...
Change that and tell us what happens

Posted: Fri Jul 29, 2005 8:43 am
by php12342005
actually last line is
Alert($str).
spelling error on top post.
I have modified on top post.

Posted: Fri Jul 29, 2005 8:50 am
by timvw
An extract from the page at the link you were provided:

[quote]
Please, use the [syntax=php]tags around php code posted in the forum
[/quote][/syntax]