Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHP
what's this error :syntax error, unexpected T_CLASS
this is a part of my code :
<?php
	$connection2 = mysql_connect("localhost","login_h","1234");
	$db = "login_sys";
	mysql_select_db($db , $connection2) 
class Blogpost{
		public $id;
		public $title;
		public $post;
		public $author;
		public $tags;
		public $dateposted;
		public $images;
Posted 10-Sep-12 11:24am
Edited 10-Sep-12 11:31am
v2
Comments
enhzflep at 10-Sep-12 17:27pm
   
It's a syntax error, which, without context means pretty much nothing.
Like C, the error can appear to point to a line that's some distance away from the actual error. If you could show the smallest example of code that exhibits this error, you're likely to get a prompt response. :)

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It looks like you've missed the ; from the mysql_select_db line.
Sine this line isn't terminated, the PHP pre-processor is surprised to see
class Blogpost
 
Hence the message 'unexpected T_CLASS'
  Permalink  
Comments
Hysen Ndregjoni at 10-Sep-12 17:51pm
   
thanks a lot !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
enhzflep at 10-Sep-12 18:02pm
   
You're welcome. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 589
1 OriginalGriff 309
2 CPallini 205
3 RyanDev 165
4 Sergey Alexandrovich Kryukov 110
0 OriginalGriff 5,689
1 Sergey Alexandrovich Kryukov 4,803
2 Peter Leow 2,974
3 Maciej Los 2,819
4 DamithSL 2,465


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 10 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100