Parse Error

Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 1843 Views - Last Post: 13 March 2009 - 08:26 PM Rate Topic: -----

#1 gulK  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 31-January 09

Parse Error

Posted 26 February 2009 - 09:45 PM

I'm trying to make a submit form that emails me the information when "Submit" is clicked. Here is the error I get when submitting the form:

Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /users/gulk/www/yellow/waitlistaction.php on line 2

Here is the code i have done already:

 <form action="waitlistaction.php" method="post" enctype="text/plain" name="waitlist" id="waitlist">


and here is the php code.
<?php
	$1stresident = $_REQUEST['1stresident'];
	$age = $_REQUEST['age'];
	$date = $_REQUEST['date'];
	$2ndresident = $_REQUEST['2ndresident'];
	$2ndage = $_REQUEST['2ndage'];
	$2nddate = $_REQUEST['2nddate'];
	$street = $_REQUEST['street'];
	$city = $_REQUEST['city'];
	$state = $_REQUEST['state'];
	$zip = $_REQUEST['zip'];
	$phone = $_REQUEST['phone'];
	$phone2 = $_REQUEST['phone2'];

	mail( "yellowretirement@gmail.com", "Waitlist Agreement",
		$1stresident, $age, $date, $2ndresident, $2ndage, $2nddate, $street, $city, $state, $zip, $phone, $phone2 "From: $1stresident");
?> 


Not exactly sure what has gone wrong here. I was getting an example from thesitewizard.com.

Any help would be appreciated.
Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Parse Error

#2 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: Parse Error

Posted 26 February 2009 - 10:12 PM

http://us3.php.net/m...bles.basics.php
Was This Post Helpful? 0
  • +
  • -

#3 silverblaze  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 69
  • Joined: 18-January 08

Re: Parse Error

Posted 26 February 2009 - 11:02 PM

hello,

the problem is with this line..
	$1stresident = $_REQUEST['1stresident'];



a var name cannot start with a number.

Quote

A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores

Was This Post Helpful? 1
  • +
  • -

#4 gulK  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 31-January 09

Re: Parse Error

Posted 27 February 2009 - 05:23 AM

Thanks guys for the help. error is fixed!
Unfortunately, on to another error......

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /users/gulk/www/yellow/waitlistaction.php on line 15

here is what im looking at as far as code goes now.

<?php
	$firstresident = $_REQUEST['firstresident'];
	$age = $_REQUEST['age'];
	$date = $_REQUEST['date'];
	$secondresident = $_REQUEST['secondresident'];
	$secondage = $_REQUEST['secondage'];
	$seconddate = $_REQUEST['seconddate'];
	$street = $_REQUEST['street'];
	$city = $_REQUEST['city'];
	$state = $_REQUEST['state'];
	$zip = $_REQUEST['zip'];
	$phone = $_REQUEST['phone'];
	$phone2 = $_REQUEST['phone2'];

	mail( "yellowretirement@gmail.com", "Waitlist Agreement", $firstresident, $age, $date, $secondresident, $secondage, $seconddate, $street, $city, $state, $zip, $phone, $phone2 "From: $1stresident");
	header( "Location: http://gulk.bplaced.net/yellow/thankyou.html" );
?>


line 15 being the one starting with mail.

I will do some research on it today and see what I can find, but if anyone wants to lend a suggestion that would be great!

fixed taht problem.... im kinda blind here....
The original problem required me to change the variables that began with numbers to something else..... i missed one! oops.
But maybe im headed down the wrong trail here anyway.... fixed my first 2 errors, but now, i think ive perhaps hit a certain limit here with the mail() function.
Here is my newest error.
Warning: mail() expects at most 5 parameters, 15 given in /users/gulk/www/yellow/waitlistaction.php on line 15

and I still have checkbox information to send as well!

This post has been edited by gulK: 27 February 2009 - 05:36 AM

Was This Post Helpful? 0
  • +
  • -

#5 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: Parse Error

Posted 27 February 2009 - 05:38 AM

You are passing too many strings to your mail function. Try concatenating all those variables into one and pass that as the message body.

$messageBody = $firstresident . "\n" . $age . "\n" . $date . "\n" . $secondresident . "\n" . $secondage . "\n" . $seconddate . "\n" . $street . "\n" . $city . "\n" . $state . "\n" . $zip . "\n" . $phone . "\n" . $phone2;

mail( "yellowretirement@gmail.com", "Waitlist Agreement", $messageBody, "From: $1stresident");


Was This Post Helpful? 0
  • +
  • -

#6 gulK  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 31-January 09

Re: Parse Error

Posted 27 February 2009 - 06:05 AM

View Postthehat, on 27 Feb, 2009 - 04:38 AM, said:

You are passing too many strings to your mail function. Try concatenating all those variables into one and pass that as the message body.

$messageBody = $firstresident . "\n" . $age . "\n" . $date . "\n" . $secondresident . "\n" . $secondage . "\n" . $seconddate . "\n" . $street . "\n" . $city . "\n" . $state . "\n" . $zip . "\n" . $phone . "\n" . $phone2;

mail( "yellowretirement@gmail.com", "Waitlist Agreement", $messageBody, "From: $1stresident");



Thank you. I was searching my problem as I posted it, and as soon as i did, i came across a similar solution! but for some reason, when I get the email, i dont have any name in the "From" field, and the body of the email is empty. The subject line is ok though.

One more quick question.... "\n" is that for formatting the response? Each on its own line?
Was This Post Helpful? 0
  • +
  • -

#7 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: Parse Error

Posted 27 February 2009 - 06:17 AM

Yeah, \n is the newline character.

For the empty body, have you checked that the variables you are receiving have contents before you compose $messageBody?

Your from header still has an invalid variable name (starts with a number).
Was This Post Helpful? 0
  • +
  • -

#8 gulK  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 31-January 09

Re: Parse Error

Posted 27 February 2009 - 07:28 AM

View Postthehat, on 27 Feb, 2009 - 05:17 AM, said:

Yeah, \n is the newline character.

For the empty body, have you checked that the variables you are receiving have contents before you compose $messageBody?

Your from header still has an invalid variable name (starts with a number).


When I test the page, i enter some information. normally just a bunch of characters. I think it should at least send me the email with thoes same bunch of characters in the body of the email.

As far as the from header having the invalid variable name, i have changed that already. I get an email from the page, with the correct subject, just no From or body.
Was This Post Helpful? 0
  • +
  • -

#9 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: Parse Error

Posted 27 February 2009 - 07:41 AM

Have you actually checked that the data is coming through though? Try echoing $messageBody before you call the mail function just to make sure.
Was This Post Helpful? 0
  • +
  • -

#10 gulK  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 31-January 09

Re: Parse Error

Posted 27 February 2009 - 07:44 AM

View Postthehat, on 27 Feb, 2009 - 06:41 AM, said:

Have you actually checked that the data is coming through though? Try echoing $messageBody before you call the mail function just to make sure.


Hrm.... I will try that when I get home tonight and see if it is working properly. I will post back with the results.
Was This Post Helpful? 0
  • +
  • -

#11 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 542
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: Parse Error

Posted 27 February 2009 - 12:15 PM

View PostgulK, on 27 Feb, 2009 - 08:05 AM, said:

mail( "yellowretirement@gmail.com", "Waitlist Agreement", $messageBody, "From: $1stresident");



Thank you. I was searching my problem as I posted it, and as soon as i did, i came across a similar solution! but for some reason, when I get the email, i dont have any name in the "From" field, and the body of the email is empty. The subject line is ok though.

One more quick question.... "\n" is that for formatting the response? Each on its own line?


The variable in the From section of the code above is part of the problem, I'm sure ;)

Also, "\n" will put items on a new line if it's in Linux. If you're using Windows, you have to use "\r\n".

This post has been edited by Valek: 27 February 2009 - 12:16 PM

Was This Post Helpful? 0
  • +
  • -

#12 gulK  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 31-January 09

Re: Parse Error

Posted 27 February 2009 - 07:31 PM

So I took advice from thehat, and did this:
$messagedetails = $firstresident . "\n" . $age . "\n" . $date . "\n" . $secondresident . "\n" . $secondage . "\n" . $seconddate . "\n" . $street . "\n" . $city . "\n" . $state . "\n" . $zip . "\n" . $phone . "\n" . $phone2;

	echo $messagedetails;
	mail( "yellowretirement@gmail.com", "Waitlist Agreement", $messagedetails, "From: $firstresident");

Now when i click on the submit button on the form, i get a white screen in the browser. So I dont think for some reason that its getting the information from the form.

So I'm not exactly sure where to go from here. :crazy:
Was This Post Helpful? 0
  • +
  • -

#13 rashmisharma  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 28-February 09

Re: Parse Error

Posted 28 February 2009 - 02:23 AM

try to echo individual values to see what they are returning?
like:

echo $firstresident;
echo $age;
...
...
....


Was This Post Helpful? 0
  • +
  • -

#14 gulK  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 31-January 09

Re: Parse Error

Posted 28 February 2009 - 05:36 AM

View Postrashmisharma, on 28 Feb, 2009 - 01:23 AM, said:

try to echo individual values to see what they are returning?
like:

echo $firstresident;
echo $age;
...
...
....



Im beginning to think that I may be especially stupid for not being able to get echo to work. :blink: Here is what I put. Just for the sake of being through, here is all the code in the script right now.
?php
	$firstresident = $_REQUEST['firstresident'];
	$age = $_REQUEST['age'];
	$date = $_REQUEST['date'];
	$secondresident = $_REQUEST['secondresident'];
	$secondage = $_REQUEST['secondage'];
	$seconddate = $_REQUEST['seconddate'];
	$street = $_REQUEST['street'];
	$city = $_REQUEST['city'];
	$state = $_REQUEST['state'];
	$zip = $_REQUEST['zip'];
	$phone = $_REQUEST['phone'];
	$phone2 = $_REQUEST['phone2'];
	$messagedetails = $firstresident . "\n" . $age . "\n" . $date . "\n" . $secondresident . "\n" . $secondage . "\n" . $seconddate . "\n" . $street . "\n" . $city . "\n" . $state . "\n" . $zip . "\n" . $phone . "\n" . $phone2;

	echo $firstresident;
	echo $age;
	echo $date;
	echo $secondresident;
	echo $secondage;
	echo $seconddate;
	echo $street;
	echo $city;
	echo $state;
	echo $zip;
	echo $phone;
	echo $phone2;
	//mail( "yellowretirement@gmail.com", "Waitlist Agreement", $messagedetails, "From: $firstresident");
	//header( "Location: http://gulk.bplaced.net/yellow/thankyou.html" );
?>

When i click on submit right now, I get sent to the waitlistaction.php file, which is nothing but a script. so my browser shows just a blank white view.

If it makes ANY difference at all, I am writing this in Dreamweaver. If I un-comment the header re-direct, I get taken to that page correctly.

Im probably overlooking something obvious to everyone but myself, but if anyone could point it out, that would be great.
Was This Post Helpful? 0
  • +
  • -

#15 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 542
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: Parse Error

Posted 28 February 2009 - 06:09 AM

You say it's coming up blank. Are you sure your form is actually submitting the data to your script? It sounds to me as though the data's not being carried over, if you're echoing variables but getting no output. Try var_dump() instead of echo. If you get "NULL", your data's not making it.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2