Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 135,914 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,569 people online right now. Registration is fast and FREE... Join Now!




Form processing

 
Reply to this topicStart new topic

Form processing, I'm getting an error but can't figure out why!

rjolitz
19 May, 2008 - 08:10 PM
Post #1

D.I.C Head
Group Icon

Joined: 17 May, 2008
Posts: 86



Thanked: 1 times
Dream Kudos: 75
My Contributions
Hello.

I'm trying to process form data into a mysql database.

The error I'm getting is:

Parse error: syntax error, unexpected $end in /home/richardj/public_html/gametest/register.php on line 61

Here is the code I'm trying to process the form data through:

CODE


<html>
<head>
<title>test page</title>
</head>
<body>
<div>

<?php

       include "database.connect.php";


$user_name =$POST_['name'];
$password=$POST_['password'];
$affiliation=$POST_['affiliation'];
$admin='N';
$subscription='N';
$beta_test='N';
$email='none';
$user_id='rijoieoe';
$points=0;
$wins=0;
$losses=0;
$rank='Ensign';

$query = "INSERT INTO users (
`user_name` ,
`password` ,
`affiliation` ,
`admin` ,
`subscription` ,
`beta_test` ,
`email` ,
`user_id` ,
`points` ,
`wins` ,
`losses` ,
`rank`
)
VALUES (
'$user_name',
'$password',
'$affiliation',
'$admin',
'$subscription',
'$beta_test',
'$email',
'$user_id',
'$points',
'$wins',
'$losses',
'$rank'
);

if  ($mysqli->query($query)){
}


?>



I'm only feeding 3 pieces in at this point and setting the rest.

I'm not sure why I'm getting the error. Does anyone see something obvious I'm just over looking?

Thanks!

Rich

User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Form Processing
19 May, 2008 - 08:57 PM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,433



Thanked: 64 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
Try replacing your mysql statement with this:
CODE

$query = "INSERT INTO users (
`user_name` ,
`password` ,
`affiliation` ,
`admin` ,
`subscription` ,
`beta_test` ,
`email` ,
`user_id` ,
`points` ,
`wins` ,
`losses` ,
`rank`
)
VALUES (
'$user_name',
'$password',
'$affiliation',
'$admin',
'$subscription',
'$beta_test',
'$email',
'$user_id',
'$points',
'$wins',
'$losses',
'$rank'
);";


You are missing your ending quote.
User is offlineProfile CardPM
+Quote Post

akozlik
RE: Form Processing
21 May, 2008 - 08:17 PM
Post #3

D.I.C Addict
Group Icon

Joined: 25 Feb, 2008
Posts: 603



Thanked: 22 times
Dream Kudos: 750
My Contributions
As no2pencil said, you're missing your last double quote. That's easy to do when you're working with long strings, or long functions. You'll notice that you get the same error if you forget a closing } brace. Just so you get a good idea, what your above code is equivalent to is

<?php
echo "Hello;
?>

Notice the missing double quote? Typically if you get that error you want to run through and make sure you've got everything closed out. You get the $end notification because PHP finished processing the end of the file.

Hope that not only clears up your error, but explains why the error was thrown. Take it easy.


User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Form Processing
21 May, 2008 - 08:21 PM
Post #4

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,433



Thanked: 64 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE(akozlik @ 22 May, 2008 - 12:17 AM) *

That's easy to do when you're working with long strings, or long functions.

It's even easier to do when working with mysql. Because it's a language that also uses the semi-colon, so it's easy to loose track, like you said, when working with a vary long statement. It's unfortunate that PHP can sometimes be a bit cryptic with it's error messages, unlike other languages. The trick is knowing common failure points.
User is offlineProfile CardPM
+Quote Post

akozlik
RE: Form Processing
21 May, 2008 - 08:25 PM
Post #5

D.I.C Addict
Group Icon

Joined: 25 Feb, 2008
Posts: 603



Thanked: 22 times
Dream Kudos: 750
My Contributions
Yeah I definitely agree with you. The more you write in a particular language, the more you'll understand common pitfalls. I remember when I first started I'd have trouble figuring out what the different error codes meant, and now it's just a quick fix. PHP definitely has some of the more cryptic error messages, but it's nothing compared to Oracle ora-codes. Ha ha.
User is offlineProfile CardPM
+Quote Post

JBrace1990
RE: Form Processing
22 May, 2008 - 05:05 AM
Post #6

D.I.C Regular
Group Icon

Joined: 9 Mar, 2008
Posts: 476



Thanked: 22 times
Dream Kudos: 350
My Contributions
apparently PHP wasn't written by the common man =P

if I wrote it, one of the messages would be "you forgot the ending quote on $line line genius tongue.gif"
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 07:53AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month