Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error on line 30
#1
I keep getting this error:

"Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /register.php on line 30"

The code on lines 29, 30 & 31 is this:

PHP Code:
$query "INSERT INTO tablename (username, password, email, ip) 
        VALUES ('
$username', '$password', '$email', '$ip')";
        
mysql_query($query); 

Can anybody spot where the error is? It's been driving me mad all day.
#2
Which one of those 3 lines in the 30th line? I think I may know what it is...
#3
I mentioned that they are lines 29, 30 & 31, meaning the 2nd line is the 30th Tongue

#4
Oh I'm not sure actually, I just though about that one. Hmm, try putting line 29 & 30 on just one line?
It's saying it's an unexpected T_VARIABLE, did you set the variables?
#5
Yes I've set the variables. I've done some research and found that most of the time that this occurs, there is usually some sort of space somewhere, or a semi-colon in the wrong place, etc... However I can't see anything wrong with my bit of code??

I'm new to PHP so I could be wrong however I have asked a PHP coder on One.com if he could see anything wrong and he couldn't.
#6
Oh, then I'm not sure, I just took another look at it and can't find any spaces either so I'm not sure. I think Laugh knows PHP so it would be worth asking him.
#7
I haven't touched php in awhile but try removing the final ; in line 30.
#8
Try this:
PHP Code:
$query "INSERT INTO tablename values ('$username', '$password', '$email', '$ip')";
$qresult mysql_query($query); 

In you're code it's not seeing a ; or an , at the end of the first line, which is where your error comes from
#9
PHP Code:
$query "INSERT INTO tablename (username, password, email, ip);
        VALUES ('
$username', '$password', '$email', '$ip')";
        
mysql_query($query); 
You just missed out the ; at the end of the first line.

#10
(09-19-2011, 02:37 AM)Kyle FYI Wrote:
PHP Code:
$query "INSERT INTO tablename (username, password, email, ip);
        VALUES ('
$username', '$password', '$email', '$ip')";
        
mysql_query($query); 
You just missed out the ; at the end of the first line.

I'm pretty sure that would be invalid too because it's not the end of the syntax when he has double quotes on 2 lines.

The proper way is to use it all in one line of syntax:
Code:
$query = "INSERT INTO tablename VALUES ('$username', '$password', '$email', '$ip')";


Forum Jump:


Users browsing this thread: 2 Guest(s)