Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem

Status
Not open for further replies.

neilmurray

Technical User
Jan 18, 2005
32
GB
I am getting the following error

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/neil/web/adm_diskusi.php on line 14

where line 14 is
echo "Pilih Topic : <select class='entri' onChange="window.location = this.options[this.selectedIndex].value">";
thanks
Neil.
 
replace your line:

echo "Pilih Topic : <select class='entri' onChange="window.location = this.options[this.selectedIndex].value">";

with:

echo "Pilih Topic : <select class='entri' onChange=\"window.location = this.options[this.selectedIndex].value\">";

note that I added \ characters.
 
Too many double quotes in your string.

You wrote:
Code:
echo "Pilih Topic : <select class='entri' onChange="window.location = this.options[this.selectedIndex].value">";
Try this:
Code:
echo "Pilih Topic : <select class='entri' onChange=" . '"window.location = this.options[this.selectedIndex].value">';

I use double quotes if my string contains single quotes and single quotes if it contains double quotes. You can also escape the double quotes, but I think the resulting source looks sloppy.

Code:
$str = "this is\"a test\"";
$str2 = 'this is "a test"';
if ($str == $str2) echo "equal";

Ken
 
Also, determine what would be better for you. XHTML requires double quotes, so you might embed your html strings in single quotes:
Code:
echo 'Pilih Topic : <select class="entri" onchange="window.location = this.options[this.selectedIndex].value">';
 
There is also the heredoc syntax (in which variables are interpolated):
Code:
print <<<END
Pilih Topic : <select class="entri" onchange="window.location = this.options[this.selectedIndex].value">
END;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top