By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,786 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,786 IT Pros & Developers. It's quick & easy.

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ']' in C:\

P: 2
Hi everyone im a high school student and I'm having trouble with one of my projects could you please help!!
I'm getting this error message.
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ']' in C:\wamp\www\dwalk96\sign-up.php on line 26

Here is all the code of the file.
[PHP]<?php
// Connects to your Database
mysql_connect("aldridge3", "root", "") or die(mysql_error());
mysql_select_db("dwalk96") or die(mysql_error());

//This makes sure they did not leave any fields blank
if (!$_POST['firstname'] | !$_POST['lastname'] | !$_POST['streetnumber'] | !$_POST['streetname'] | !$_POST['postcode'] | !$_POST['password'] | !$_POST['password2'] | !$_POST['creditcardtype'] | !$_POST['cardholdersname'] | !$_POST['cardnumber'] | !$_POST['cardexpirydate'] | !$_POST['cardexpirydate2'] ) {
die('You did not complete all of the required fields');
}

// this makes sure both passwordwords entered match
if ($_POST['password'] != $_POST['password2']) {
die('Your passwords did not match.
');
}

// here we encrypt the password and add slashes if needed
$_POST['password'] = md5($_POST['password']);
if (!get_magic_quotes_gpc()) {
$_POST['password'] = addslashes($_POST['password']);
$_POST['username'] = addslashes($_POST['username']);
}

// now we insert it into the database
$insert = "INSERT INTO sing-up (FirstName, LastName, StreetNumber, StreetName, PhoneNumber, Postcode, E-mailAddress, Password, CreditCard, CardHolderName, CardNumber, ExpiryDate, ExpiryDateYear)
VALUES ('$_POST[firstname]', '$_POST[lastname']',
'$_POST[streetnumber]', '$_POST[streetname']',
'$_POST[phonenumber]', '$_POST[postcode']',
'$_POST[e-mailaddress]', '$_POST[password']',
'$_POST[creditcardtype]', '$_POST[creditcardholdersname']',
'$_POST[cardnumber]', '$_POST[creditcardexpirydate]', '$_POST[creditcardexpirydate2']')";
$add_member = mysql_query($insert);
?>
<h1>Registered</h1>
<p>Thank you, you have registered - you may now login</a>.</p>[/PHP]
Aug 2 '07 #1
Share this Question
Share on Google+
3 Replies


dafodil
100+
P: 392
Check this part:
There are some parts that do not match the single quotes. As much as I want to give the solution directly, I want you to learn and discover it so that the next time you see that error you'll remember that its all in the matching of the quotes.

Post again if you got any problems.

Expand|Select|Wrap|Line Numbers
  1. VALUES ('$_POST[firstname]', '$_POST[lastname']', 
  2. '$_POST[streetnumber]', '$_POST[streetname']', 
  3. '$_POST[phonenumber]', '$_POST[postcode']', 
  4. '$_POST[e-mailaddress]', '$_POST[password']', 
  5. '$_POST[creditcardtype]', '$_POST[creditcardholdersname']', 
  6. '$_POST[cardnumber]', '$_POST[creditcardexpirydate]', '$_POST[creditcardexpirydate2']')";
  7.  
  8.  
  9.  
Aug 3 '07 #2

pbmods
Expert 5K+
P: 5,821
Heya, basswhizz. Welcome to TSDN!

PHP does not allow constants inside of quoted strings. As such, if you try to quote an array index inside of a string, you will get an error.

Here are some examples of correct syntax:
Expand|Select|Wrap|Line Numbers
  1. $str = 'some text ' . CONSTANT . ' some more text';
  2. $str = 'some text ' . $_POST[CONSTANT] . ' some more text';
  3. $str = 'some text ' . $_POST['index'] . ' some more text';
  4.  
  5. $str = "some text $_POST[index] some more text";
  6. $str = "some text {$_POST['index']} some more text";
  7.  
For more information, check out this document.
Aug 5 '07 #3

mwasif
Expert 100+
P: 801
Moved to PHP forum..
Aug 6 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.