Page 1 of 1

Noob Needs help on first attempt

Posted: Mon May 15, 2006 9:58 am
by Grifter79
Hi fellas....complete noob to PHP

trying to get a demo request form built for my company....have found code on w3school site

but i am getting an error that i cant understand....

error:

Parse error: parse error, unexpected T_LNUMBER, expecting ',' or ';' in /homepages/13/d142595334/htdocs/NewSite/test.php on line 24


Now i had this form working....it was sending me the emails quite happily.....but as soon as i incorporate the code into a table for layout purposes.....it goes mental.....probably very easy for non noobs but i cant spot it....or understand what the problem could be....any help greatly appreciated

or better yet....if someone could correct my code where i've fecked it up....so that i can see exactly where and how i went wrong.....that would be superb

code:

Code: Select all

<?php
if (isset($_REQUEST['email']))
  {
  $clientname = $_REQUEST['clientname'] ;
  $position = $_REQUEST['position'] ;
  $company = $_REQUEST['company'] ;
  $postcode = $_REQUEST['postcode'] ;
  $tel = $_REQUEST['tel'] ;
  $email = $_REQUEST['email'] ; 
  $subject = "Demo Request" ;
  $more = $_REQUEST['more'] ; 
  $message = " Name: $clientname\n Position: $position\n Company: $company\n Postcode: $postcode\n Tel: $tel\n Message: $more\n";
  
  mail( "me@mydomain.com", "Subject: $subject", $message, "From: $email" );

  echo "Thank you for using our mail form";
  }

else
{
echo "<form method='post' action='test.php'>
<table border="0" width="36%" id="table1" cellspacing="0" cellpadding="2">
	<tr>
		<td width="132"><b>Name</b></td>
		<td>	<input name='clientname' type='text' /></td>
	</tr>
	<tr>
		<td width="132"><b>Position</b></td>
		<td>	<input name='position' type='text' /></td>
	</tr>
	<tr>
		<td width="132"><b>Company</b></td>
		<td><input name='company' type='text' /></td>
	</tr>
	<tr>
		<td width="132"><b>Address L1</b></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td width="132"><b>Address L2</b></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td width="132"><b>Town</b></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td width="132"><b>City</b></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td width="132"><b>Postcode</b></td>
		<td><input name='postcode' type='text' /></td>
	</tr>
	<tr>
		<td width="132"><b>Country</b></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td width="132"><b>Email</b></td>
		<td><input name='email' type='text' /></td>
	</tr>
	<tr>
		<td width="132"><b>Tel</b></td>
		<td><input name='tel' type='text' /></td>
	</tr>
	<tr>
		<td width="132"><b>Fax</b></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td width="132"><b>Requested Date</b></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td width="132"><b>Requested Time</b></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td width="132"><b>Message</b></td>
		<td><textarea name='more' rows='15' cols='40'></textarea></td>
	</tr>
	<tr>
		<td width="132">&nbsp;</td>
		<td><input type='submit' /></td>
	</tr>
</table>
</form>";
}
?>

Posted: Mon May 15, 2006 10:06 am
by spudmclard
New to all this stuff myself but try changing the double quotes inside the html form to singles..

Posted: Mon May 15, 2006 10:10 am
by Grifter79
not the problem....can be sure of it

it worked fine....until i put in the table in order to put some layout to the form....

as you can see the double quotes are not inside the table

Posted: Mon May 15, 2006 10:12 am
by spudmclard
td width tags ???

Posted: Mon May 15, 2006 10:17 am
by Grifter79
figured you meant the string concatenation

but to put your mind at rest, have tried it.....did a find/replace for them.....still get the same error

Posted: Mon May 15, 2006 10:48 am
by JayBird
You need to escape all your double quotes

eg

Code: Select all

echo "<td width="132"><b>Name</b></td>";
Should be

Code: Select all

echo "<td width=\"132\"><b>Name</b></td>";
or you can do...

Code: Select all

echo '<td width="132"><b>Name</b></td>';
...without having to escape them

Posted: Mon May 15, 2006 11:08 am
by Grifter79
still gettin same error??? is this right???

Code: Select all

<html>
<body>
<?php
if (isset($_REQUEST['email']))
  {
  $clientname = $_REQUEST['clientname'] ;
  $position = $_REQUEST['position'] ;
  $company = $_REQUEST['company'] ;
  $postcode = $_REQUEST['postcode'] ;
  $tel = $_REQUEST['tel'] ;
  $email = $_REQUEST['email'] ; 
  $subject = "Demo Request" ;
  $more = $_REQUEST['more'] ; 
  $message = " Name: $clientname\n Position: $position\n Company: $company\n Postcode: $postcode\n Tel: $tel\n Message: $more\n";
  
  mail( "me@mydomain.com", "Subject: $subject", $message, "From: $email" );

  echo "Thank you for using our mail form";
  }

else
{
echo "<form method='post' action='test.php'>
echo '<table border="0" width="36%" id="table1" cellspacing="0" cellpadding="2">';
	<tr>
		echo '<td width="132"><b>Name</b></td>';
		<td>	<input name='clientname' type='text' /></td>
	</tr>
	<tr>
		echo '<td width="132"><b>Position</b></td>';
		<td>	<input name='position' type='text' /></td>
	</tr>
	<tr>
		echo '<td width="132"><b>Company</b></td>';
		<td><input name='company' type='text' /></td>
	</tr>
	<tr>
		echo '<td width="132"><b>Address L1</b></td>';
		<td>&nbsp;</td>
	</tr>
	<tr>
		echo '<td width="132"><b>Address L2</b></td>';
		<td>&nbsp;</td>
	</tr>
	<tr>
		echo '<td width="132"><b>Town</b></td>';
		<td>&nbsp;</td>
	</tr>
	<tr>
		echo '<td width="132"><b>City</b></td>';
		<td>&nbsp;</td>
	</tr>
	<tr>
		echo '<td width="132"><b>Postcode</b></td>';
		<td><input name='postcode' type='text' /></td>
	</tr>
	<tr>
		echo '<td width="132"><b>Country</b></td>';
		<td>&nbsp;</td>
	</tr>
	<tr>
		echo '<td width="132"><b>Email</b></td>';
		<td><input name='email' type='text' /></td>
	</tr>
	<tr>
		echo '<td width="132"><b>Tel</b></td>';
		<td><input name='tel' type='text' /></td>
	</tr>
	<tr>
		echo '<td width="132"><b>Fax</b></td>';
		<td>&nbsp;</td>
	</tr>
	<tr>
		echo '<td  width="132"><b>Requested Date</b></td>';
		<td>&nbsp;</td>
	</tr>
	<tr>
		echo '<td width="132"><b>Requested Time</b></td>';
		<td>&nbsp;</td>
	</tr>
	<tr>
		echo '<td width="132"><b>Message</b></td>';
		<td><textarea name='more' rows='15' cols='40'></textarea></td>
	</tr>
	<tr>
		echo '<td width="132">&nbsp;</td>';
		<td><input type='submit' /></td>
	</tr>
</table>
</form>";
}
?>
</body>
</html>

Posted: Mon May 15, 2006 11:22 am
by JayBird
Not what i meant at all

This is what i meant

Code: Select all

echo '<form method="post" action="test.php">
<table border="0" width="36%" id="table1" cellspacing="0" cellpadding="2">
        <tr>
                <td width="132"><b>Name</b></td>
                <td>    <input name="clientname" type="text" /></td>
        </tr>
        <tr>
                <td width="132"><b>Position</b></td>
                <td>    <input name="position2 type="text" /></td>
        </tr>
        <tr>
                <td width="132"><b>Company</b></td>
                <td><input name="company" type="text" /></td>
        </tr>
        <tr>
                <td width="132"><b>Address L1</b></td>
                <td>&nbsp;</td>
        </tr>
        <tr>
                <td width="132"><b>Address L2</b></td>
                <td>&nbsp;</td>
        </tr>
        <tr>
                <td width="132"><b>Town</b></td>
                <td>&nbsp;</td>
        </tr>
        <tr>
                <td width="132"><b>City</b></td>
                <td>&nbsp;</td>
        </tr>
        <tr>
                <td width="132"><b>Postcode</b></td>
                <td><input name="postcode" type="text" /></td>
        </tr>
        <tr>
                <td width="132"><b>Country</b></td>
                <td>&nbsp;</td>
        </tr>
        <tr>
                <td width="132"><b>Email</b></td>
                <td><input name="email" type="text" /></td>
        </tr>
        <tr>
                <td width="132"><b>Tel</b></td>
                <td><input name="tel" type="text" /></td>
        </tr>
        <tr>
                <td width="132"><b>Fax</b></td>
                <td>&nbsp;</td>
        </tr>
        <tr>
                <td width="132"><b>Requested Date</b></td>
                <td>&nbsp;</td>
        </tr>
        <tr>
                <td width="132"><b>Requested Time</b></td>
                <td>&nbsp;</td>
        </tr>
        <tr>
                <td width="132"><b>Message</b></td>
                <td><textarea name="more" rows="15" cols="40"></textarea></td>
        </tr>
        <tr>
                <td width="132">&nbsp;</td>
                <td><input type="submit" /></td>
        </tr>
</table>
</form>';
I seriously recommend some more reading, becuase this is quite basic.

Posted: Mon May 15, 2006 11:31 am
by Grifter79
Pimptastic wrote:I seriously recommend some more reading, becuase this is quite basic.
I realise that....i've literally only just touched PHP a matter of hours ago.....and that was only because i had a need for this.....but i do intend to push on with it a bit more......will have to find some decent tutorials.....

but thanks....sorted me out