How to fix - Parse error: syntax error, unexpected T_CLASS

Posted by user557015 on Stack Overflow See other posts from Stack Overflow or by user557015
Published on 2010-12-29T10:46:59Z Indexed on 2010/12/29 10:54 UTC
Read the original article Hit count: 414

Filed under:
|
|
|

Hi, I'm new to PHP, and i'm making a forum. all the files work except one file, add_topic.php.

It gives me an error saying:

Parse error: syntax error, unexpected T_CLASS in /home/a3885465/public_html/add_topic.php on line 25

I know it is probably on the lines:

</span>}<span class="s4"><br>
</span>else{<span class="s4"><br>
</span>echo "ERROR";<span class="s4"><br>
</span>}<span class="s4"><br>
</span>mysql_close();<span class="s4"><br>

but the whole code is below just in case.

If you have any idea, it would be really appreciated, thanks!


The Code for add_topic.php

  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1038.32">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 12.0px 0.0px; font: 12.0px Verdana; color: #009901}
p.p2 {margin: 0.0px 0.0px 12.0px 0.0px; font: 12.0px Verdana; color: #3a00ff}
span.s1 {color: #3a00ff}
span.s2 {font: 12.0px 'Lucida Grande'; color: #3a00ff}
span.s3 {font: 13.0px Courier; color: #404040}
span.s4 {font: 12.0px 'Lucida Grande'}
span.s5 {color: #009901}
td.td1 {width: 566.0px; margin: 0.5px 0.5px 0.5px 0.5px}
</style>
</head>
<body>
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="middle" class="td1">
<p class="p1"><span class="s1"></span><?php<span class="s2"><br>
</span><span class="s1">$host="</span><span class="s3">"host"</span><span class="s1">";</span> // Host name <span class="s4"><br>
</span><span class="s1">$username="</span><span class="s3">username</span><span class="s1">";</span> // Mysql username <span class="s4"><br>
</span><span class="s1">$password="password";</span> // Mysql password <span class="s4"><br>
</span><span class="s1">$db_name="</span><span class="s3">database_name</span><span class="s1">";</span> // Database name <span class="s4"><br>
</span><span class="s1">$tbl_name="forum_question";</span> // Table name</p>
<p class="p2"><span class="s5">// Connect to server and select database.</span><span class="s4"><br>
</span>mysql_connect("$host", "$username", "$password")or die("cannot connect"); <span class="s4"><br>
</span>mysql_select_db("$db_name")or die("cannot select DB");</p>
<p class="p2"><span class="s5">// get data that sent from form </span><span class="s4"><br>
</span>$topic=$_POST['topic'];<span class="s4"><br>
</span>$detail=$_POST['detail'];<span class="s4"><br>
</span>$name=$_POST['name'];<span class="s4"><br>
</span>$email=$_POST['email'];<span class="s4"><br>
<br>
</span>$datetime=date("d/m/y h:i:s"); <span class="s5">//create date time</span><span class="s4"><br>
<br>
</span>$sql="INSERT INTO $tbl_name(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$name', '$email', '$datetime')";<span class="s4"><br>
</span>$result=mysql_query($sql);<span class="s4"><br>
<br>
</span>if($result){<span class="s4"><br>
</span>echo "Successful<BR>";<span class="s4"><br>
</span>echo "<a href=main_forum.php>View your topic</a>";<span class="s4"><br>
</span>}<span class="s4"><br>
</span>else{<span class="s4"><br>
</span>echo "ERROR";<span class="s4"><br>
</span>}<span class="s4"><br>
</span>mysql_close();<span class="s4"><br>
</span>?></p>
</td>
</tr>
</tbody>
</table>
</body>
</html>

Thanks again!

© Stack Overflow or respective owner

Related posts about php

Related posts about html