Posts: 3,538
Threads: 348
Joined: Mar 2010
Reputation:
57
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.
Posts: 2,216
Threads: 187
Joined: Jul 2011
Which one of those 3 lines in the 30th line? I think I may know what it is...
Posts: 3,538
Threads: 348
Joined: Mar 2010
Reputation:
57
I mentioned that they are lines 29, 30 & 31, meaning the 2nd line is the 30th
Posts: 2,216
Threads: 187
Joined: Jul 2011
09-08-2011, 07:15 AM
(This post was last modified: 09-08-2011, 07:22 AM by BreShiE.)
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?
Posts: 3,538
Threads: 348
Joined: Mar 2010
Reputation:
57
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.
Posts: 2,216
Threads: 187
Joined: Jul 2011
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.
Posts: 1,736
Threads: 198
Joined: May 2010
Reputation:
32
09-08-2011, 01:40 PM
(This post was last modified: 09-08-2011, 01:40 PM by Peter L.)
I haven't touched php in awhile but try removing the final ; in line 30.
Posts: 5,793
Threads: 268
Joined: Sep 2010
Reputation:
85
09-08-2011, 03:12 PM
(This post was last modified: 09-08-2011, 03:13 PM by AceInfinity.)
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
Posts: 8
Threads: 1
Joined: Sep 2011
09-19-2011, 02:37 AM
(This post was last modified: 09-19-2011, 02:38 AM by Kyle FYI.)
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.
Posts: 5,793
Threads: 268
Joined: Sep 2010
Reputation:
85
09-19-2011, 02:46 AM
(This post was last modified: 09-19-2011, 02:46 AM by AceInfinity.)
(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')";
|