still newbie: syntax error:

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
php12342005
Forum Commoner
Posts: 79
Joined: Mon Mar 21, 2005 3:35 am

still newbie: syntax error:

Post 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?
Last edited by php12342005 on Fri Jul 29, 2005 8:35 am, edited 1 time in total.
tores
Forum Contributor
Posts: 120
Joined: Fri Jun 18, 2004 3:04 am

Post 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
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post 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
php12342005
Forum Commoner
Posts: 79
Joined: Mon Mar 21, 2005 3:35 am

Post by php12342005 »

actually last line is
Alert($str).
spelling error on top post.
I have modified on top post.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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]
Post Reply