Support Forums

Full Version: Error on line 30
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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.
Which one of those 3 lines in the 30th line? I think I may know what it is...
I mentioned that they are lines 29, 30 & 31, meaning the 2nd line is the 30th Tongue

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?
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.
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.
I haven't touched php in awhile but try removing the final ; in line 30.
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
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.

(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')";
Pages: 1 2