Jump to content

Recommended Posts

Hi there,

I was trying to modify the code from the tutorial "PHP Basic Database Handling" and the code uses something I haven't seen before, but looks intriguing.

 

Can someone explain how to use this:

 

echo <<<SOMELABEL

stuff

SOMELABEL;

 

Or let me know why my code didn't work? The error is an unexpected end statement on the last line of the file.

 

My Code:

<?php
$mystring = $_GET['FirstLast'];
if($mystring == "")	
{
	echo "You reached this page by mistake, click on the link in your email";
}else
{
	//echo $mystring;
	// connect to db
	$conn = mysql_connect('localhost','user','pw') or trigger_error("SQL",E_USER_ERROR);
	$db = mysql_select_db('tsec',$conn) or trigger_error("SQL",E_USER_ERROR);
	$sql = "SELECT `First Name`, `Last Name`, `Title`, `Org Parameter 1`, `Org/Person Name`, 
			`Attendee Parm Value 1`, `Attendee Parm Value 2`, `Attendee Parm Value 3`, `Attendee Parm Value 4`,
			`Attendee Parm Value 5`, `Attendee Parm Value 6`, `Attendee Parm Value 7`, `Attendee Parm Value 8`
			FROM `attendees` WHERE FirstLast = '$mystring'";
	$result = mysql_query($sql,$conn) or trigger_error("SQL", E_USER_ERROR);
	$list = mysql_fetch_assoc($result);
	echo <<<LISTNAME
	<form action = '{$_SERVER['PHP_SELF']}' method = 'post'>
	<table border = '1'><tr><td colspan = '2'>{$list['First Name']} {$list['Last Name']}</td></tr>
	<tr><td>Title</td><td><input type = 'text' name = 'Title' value = {$list['Title']}</td></tr>
	</table></form>
	LISTNAME;
	mysql_close($conn);
}
?>

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/256066-syntax-help/
Share on other sites

from the manual:

 

Warning
It is very important to note that the line with the closing identifier must contain no other characters, except possibly a semicolon (.
That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon. 
It's also important to realize that the first character before the closing identifier must be a newline as defined by the local operating system. 
This is \n on UNIX systems, including Mac OS X. The closing delimiter (possibly followed by a semicolon) must also be followed by a newline.

 

you have tabbed your closing identifier.

Link to comment
https://forums.phpfreaks.com/topic/256066-syntax-help/#findComment-1312715
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.