/    Sign up×
Community /Pin to ProfileBookmark

Parse error: syntax error, unexpected T_ECHO

Hey All,

I’m very new to PHP, and am a young guy at that (16), no don’t get me wrong I’m a smart kid, I just need time to perfect my skills

Anyhow, the following the the script I wrote. Here’s basically what I’m trying to do:

1) A user, in a previous HTML page has inputted data into a form
2) They press submit and the data SHOULD be processed through a PHP form
3) I want that data to be entered into a database table. The database and table are fully set up.
4) The script will have created the user and the user will now be able to login.

[url]www.mobitek.ca/createuser-builder/formto.html[/url] is the form, and there the insert fails, as per the error that was echoed.

Here’s the script:

[code=php]
<?php

$username = $_POST[“username”];
$password = $_POST[“password”];
$name = $_POST[“name”];
$address1 = $_POST[“address1”];
$address2 = $_POST[“address2”];
$city = $_POST[“city”];
$state = $_POST[“state”];
$zip = $_POST[“zip”];
$country1 = $_POST[“country1”];
$phone = $_POST[“phone”];
$email = $_POST[“email”];
$admin = $_POST[“admin”];
$country2 = $_POST[“country2”];

$link = mysql_connect(‘localhost’, ‘mobitek_build’,

‘PASSWORD’);
if (!$link) {
die(‘Could not connect: ‘ . mysql_error());
}
echo ‘Connected successfully’;

$query = “INSERT INTO compb_users ( id , username ,

password , name, address , city , state , zip , country1 , phone

, email , admin , country2 )
VALUES (
‘$id’, ‘$username’, ‘$password’, ‘$name’, ‘$address’, ‘$city’,

‘$state’, ‘$zip’, ‘$country1’, ‘$phone’, ‘$email’, ‘$admin’,

‘$country2’)”;

mysql_query($query) or die (‘Error creating user’)

echo “Thank you”;

?>
[/code]

Thanks for the help in advance, Justin.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogAug 12.2009 — Missing semi-colon on the preceding line (right before the last echo).

Tip: an "Unexpected [something]" error often means the actual error is before the line number cited in the error message. That line number and message just tells you where the parser got confused and "gave up."
×

Success!

Help @beaudoin spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...