Jump to content

Parse error: syntax error, unexpected 'name' (T_STRING) in C:\wamp\www\1066mk4\Alt_in


rocky48
Go to solution Solved by rocky48,

Recommended Posts

I am trying to tidy up my code and make it able to run using PHP 5.5.12.

I have a syntax error that I can't see why it is giving this error.

The code is being run on localhost with php.ini error set to E_ALL.

$optionsHTML = "<select name=\"Event\">\r\n";

This works on the live file, but it has a very limited php.ini file.
I don't think you will need all of the code, but I will post just in case:

<?php
include ("connect_Verses4Cards_LOCAL.php");
$conn = get_db_conn_verse();


$display_block="";
$Events ="";
$Events_info['id'] ="";
$Events_info['Event_Type'] ="";
$Mood_info['id'] ="";
$Mood_info['Event_Sub_Type'] ="";"
//Function to build select options based on passed array
$Events = array($Events_info[id], $Events_info[Event_Type]); 
buildSelectOptions($Events);
function buildSelectOptions($options)
{
$optionsHTML = "<select name=\"Event\">\r\n";

foreach($options as $id => $label)
{
$optionsHTML .= "<option value='{$id}'>{$label}</option>\n";
}
return $optionsHTML;
}   
 
//Run query to get the ID and Name from the table
//Then populate into an array
$clist_sql = "SELECT id, Event_Type FROM Events ORDER BY id";
$clist_res= mysqli_query($conn, $clist_sql) or die(mysqli_error($conn));
if (mysqli_num_rows($clist_res) < 1) {
	//this Event not exist
	$display_block = "<p><em>You have selected an invalid Event.<br/>
	Please try again.</em></p>";
}
$Events = array();
while($Events_info = mysqli_fetch_array($clist_res)) {
       
        $Events [$Events_info['id']] = $Events_info['Event_Type'];
}
$EventOptions = buildSelectOptions($Events);

//Function to build select options based on passed array
$Mood[] = array($Mood_info['id'], $Mood_info['Event_Sub_Type']); 
buildSelectOptions1($Mood);
function buildSelectOptions1($options)
{
$optionsHTML = "<select name=\"Mood\">\r\n";

foreach($options as $id => $label)
{
$optionsHTML .= "<option value='{$id}'>{$label}</option>\n";
}


return $optionsHTML;
}   
 
//Run query to get the ID and Name from the table
//Then populate into an array
$clist1_sql = "SELECT id, Event_Sub_Type FROM Event_Sub ORDER BY id";
$clist1_res= mysqli_query($conn, $clist1_sql) or die(mysqli_error($conn));
if (mysqli_num_rows($clist1_res) < 1) {
	//this Mood not exist
	$display_block = "<p><em>You have selected an invalid Mood.<br/>
	Please try again.</em></p>";
}
$Mood = array();
while($Mood_info = mysqli_fetch_array($clist1_res)) {
       
        $Mood [$Mood_info['id']] = $Mood_info['Event_Sub_Type'];
}
$MoodOptions = buildSelectOptions1($Mood);
		
		
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License

Name       : Yosemite  
Description: A two-column, fixed-width design with dark color scheme.
Version    : 1.0
Released   : 20091106

-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="Input form for getting Verse output" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>1066 Cards 4U - Verse Input Form</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="menu">
		<ul>
			<li class="current_page_item"><a href="index.php">Home</a></li>
			<li><a href="Links.html">Links</a></li>
			<li><a href="Verse_Menu.html">Verses</a></li>
			<li><a href="Techniques.html">Techniques</a></li>
			<li><a href="blog.html">Blog</a></li>
			<li><a href="Gallery.html">Gallery</a></li>
			<li><a href="contact.html">Contact</a></li>
			<li><a href="AboutUs.html">About Us</a></li>
			<li><a href="stats1.html">Stats</a></li>
		</ul>
</div><!-- end #menu -->
<div id="header">
		<div id="logo">
			<h1><a href="http://www.1066cards4u.co.uk">1066 Cards 4U</a></h1>
</div><!-- end #wrapper -->
</div><!-- end #header -->
<div id="page">
<div id="page-bgtop">
<div id="page-bgbtm">
<div id="content">
		 <h1>Verse Choices Form</h1>
<p>
<br></br>
<br></br>
	You can filter the database, by selecting one of the items in each drop down menu and clicking the submit button.<br></br>
	This will list all greetings of the chosen type of Event and Mood.<br></br>
	If you do not make a choice the default selections will be used.</p>
	<br></br>
	<h3>BASIC VERSION</h3>
<br></br>	
<!-- Start of FORM -->
<form action="VerseQuery.php" method="post">
<select name="Event_Type">
	
<option value= "<?php echo $EventOptions;?>"  </option>
</select>
<select name="Mood">
<option value= "<?php echo $MoodOptions;?>"  </option>
</select>
<input type="submit" value="submit"/>
</form><!-- End of FORM -->
<br></br>
<h3>ADVANCED VERSION</h3>
<p>If you wish to change the Font color to any color, use the following button</p>
<br></br>
<!-- Start of FORM -->
<form action="AltVerseQuery1.php" method="post">
<select name="Event_Type">
	
<option value= "<?php echo $EventOptions;?>"  </option>
</select>
<select name="Mood">
<option value= "<?php echo $MoodOptions;?>"  </option>
</select>
<input type="submit" value="submit"/>

</form><!-- End of FORM -->

<br></br><br></br>
<form method="post" action="Verse_Menu.html">
 <input type="submit" value="Return To Verse Menu"/>
 </form>
</div><!-- end #content -->

<div id="sidebar">
			
					<div id="search" >
					<form method="get" action="http://1066cards4u.co.uk">
						<div>
							<input type="text" name="s" id="search-text" value="" />
							<input type="submit" id="search-submit" value="GO" />
						</div>
					</form>
					</div>
					<div style="clear: both;"> </div>
				<h2>Useful Links</h2>
				<ul.a>
				<li><p><a href="Articles/Instructions for Using Verse Database-V2.12.pdf" target="_blank">Insructions for  using Verse Printing UtilityPrintable PDF Version</a></p></li>
				<li><p><a href="Articles/Nominal Settings.PDF" target="_blank">Nominal Settings and Cutting List for Verse Database PDF Version</a></p></li>
<li><p><a href="Articles/How to use the Color Chooser_rasterized.PDF" target="_blank">How to use the Color Picker</a></p></li>
				</ul.a>
				
		</div><!-- end #sidebar -->
		<div style="clear: both;"> </div>
	</div><!-- end #page-bgtop -->
	</div><!-- end #page-bgbtm -->
	</div><!-- end #page -->
</div>

<div id="footer">
		<p>Copyright (c) 2008 Sitename.com. All rights reserved. Design by <a href="http://www.freecsstemplates.org/" rel="nofollow">FreeCSSTemplates.org</a>.</p>
</div><!-- end #footer -->
</body>
</html>
		

My experience is limited, so any help would be appreciated! :confused:

Link to comment
Share on other sites

I have corrected that typo, but still getting errors:
Notice: Use of undefined constant id - assumed 'id' in C:\wamp\www\1066mk4\Alt_inputform3.php on line 15
&
Notice: Use of undefined constant Event_Type - assumed 'Event_Type' in C:\wamp\www\1066mk4\Alt_inputform3.php on line 15
&
Notice: Array to string conversion in C:\wamp\www\1066mk4\Alt_inputform3.php on line 53
Errors 1 & 2,  I have defined these constants in lines 8 & 9.  Have I not done this correctly?

As for the 3rd error I have a similar line on line 23, but it does not error on that line.
I thought it may be the constant $optionHTML were the same in both cases so I added a 1 to the second instance.

Here is the modified code:

<?php
include ("connect_Verses4Cards_LOCAL.php");
$conn = get_db_conn_verse();


$display_block="";
$Events ="";
$Events_info['id'] ="";
$Events_info['Event_Type'] ="";
$Mood_info['id'] ="";
$Mood_info['Event_Sub_Type'] ="";
$optionsHTML ="";
$optionsHTML1 ="";
//Function to build select options based on passed array
$Events = array($Events_info[id], $Events_info[Event_Type]); 
buildSelectOptions($Events);
function buildSelectOptions($options)
{
$optionsHTML = "<select name=\"Event\">\r\n";

foreach($options as $id => $label)
{
$optionsHTML .= "<option value='{$id}'>{$label}</option>\n";
}
return $optionsHTML;
}   
 
//Run query to get the ID and Name from the table
//Then populate into an array
$clist_sql = "SELECT id, Event_Type FROM Events ORDER BY id";
$clist_res= mysqli_query($conn, $clist_sql) or die(mysqli_error($conn));
if (mysqli_num_rows($clist_res) < 1) {
	//this Event not exist
	$display_block = "<p><em>You have selected an invalid Event.<br/>
	Please try again.</em></p>";
}
$Events = array();
while($Events_info = mysqli_fetch_array($clist_res)) {
       
        $Events [$Events_info['id']] = $Events_info['Event_Type'];
}
$EventOptions = buildSelectOptions($Events);

//Function to build select options based on passed array
$Mood[] = array($Mood_info['id'], $Mood_info['Event_Sub_Type']); 
buildSelectOptions1($Mood);
function buildSelectOptions1($options)
{
$optionsHTML1 = "<select name=\"Mood\">\r\n";

foreach($options as $id => $label)
{
$optionsHTML1 .= "<option value='{$id}'>{$label}</option>\n";
}


return $optionsHTML1;
}   
 
//Run query to get the ID and Name from the table
//Then populate into an array
$clist1_sql = "SELECT id, Event_Sub_Type FROM Event_Sub ORDER BY id";
$clist1_res= mysqli_query($conn, $clist1_sql) or die(mysqli_error($conn));
if (mysqli_num_rows($clist1_res) < 1) {
	//this Mood not exist
	$display_block = "<p><em>You have selected an invalid Mood.<br/>
	Please try again.</em></p>";
}
$Mood = array();
while($Mood_info = mysqli_fetch_array($clist1_res)) {
       
        $Mood [$Mood_info['id']] = $Mood_info['Event_Sub_Type'];
}
$MoodOptions = buildSelectOptions1($Mood);
		
		
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License

Name       : Yosemite  
Description: A two-column, fixed-width design with dark color scheme.
Version    : 1.0
Released   : 20091106

-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="Input form for getting Verse output" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>1066 Cards 4U - Verse Input Form</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="menu">
		<ul>
			<li class="current_page_item"><a href="index.php">Home</a></li>
			<li><a href="Links.html">Links</a></li>
			<li><a href="Verse_Menu.html">Verses</a></li>
			<li><a href="Techniques.html">Techniques</a></li>
			<li><a href="blog.html">Blog</a></li>
			<li><a href="Gallery.html">Gallery</a></li>
			<li><a href="contact.html">Contact</a></li>
			<li><a href="AboutUs.html">About Us</a></li>
			<li><a href="stats1.html">Stats</a></li>
		</ul>
</div><!-- end #menu -->
<div id="header">
		<div id="logo">
			<h1><a href="http://www.1066cards4u.co.uk">1066 Cards 4U</a></h1>
</div><!-- end #wrapper -->
</div><!-- end #header -->
<div id="page">
<div id="page-bgtop">
<div id="page-bgbtm">
<div id="content">
		 <h1>Verse Choices Form</h1>
<p>
<br></br>
<br></br>
	You can filter the database, by selecting one of the items in each drop down menu and clicking the submit button.<br></br>
	This will list all greetings of the chosen type of Event and Mood.<br></br>
	If you do not make a choice the default selections will be used.</p>
	<br></br>
	<h3>BASIC VERSION</h3>
<br></br>	
<!-- Start of FORM -->
<form action="VerseQuery.php" method="post">
<select name="Event_Type">
	
<option value= "<?php echo $EventOptions;?>"  </option>
</select>
<select name="Mood">
<option value= "<?php echo $MoodOptions;?>"  </option>
</select>
<input type="submit" value="submit"/>
</form><!-- End of FORM -->
<br></br>
<h3>ADVANCED VERSION</h3>
<p>If you wish to change the Font color to any color, use the following button</p>
<br></br>
<!-- Start of FORM -->
<form action="AltVerseQuery1.php" method="post">
<select name="Event_Type">
	
<option value= "<?php echo $EventOptions;?>"  </option>
</select>
<select name="Mood">
<option value= "<?php echo $MoodOptions;?>"  </option>
</select>
<input type="submit" value="submit"/>

</form><!-- End of FORM -->

<br></br><br></br>
<form method="post" action="Verse_Menu.html">
 <input type="submit" value="Return To Verse Menu"/>
 </form>
</div><!-- end #content -->

<div id="sidebar">
			
					<div id="search" >
					<form method="get" action="http://1066cards4u.co.uk">
						<div>
							<input type="text" name="s" id="search-text" value="" />
							<input type="submit" id="search-submit" value="GO" />
						</div>
					</form>
					</div>
					<div style="clear: both;"> </div>
				<h2>Useful Links</h2>
				<ul.a>
				<li><p><a href="Articles/Instructions for Using Verse Database-V2.12.pdf" target="_blank">Insructions for  using Verse Printing UtilityPrintable PDF Version</a></p></li>
				<li><p><a href="Articles/Nominal Settings.PDF" target="_blank">Nominal Settings and Cutting List for Verse Database PDF Version</a></p></li>
<li><p><a href="Articles/How to use the Color Chooser_rasterized.PDF" target="_blank">How to use the Color Picker</a></p></li>
				</ul.a>
				
		</div><!-- end #sidebar -->
		<div style="clear: both;"> </div>
	</div><!-- end #page-bgtop -->
	</div><!-- end #page-bgbtm -->
	</div><!-- end #page -->
</div>

<div id="footer">
		<p>Copyright (c) 2008 Sitename.com. All rights reserved. Design by <a href="http://www.freecsstemplates.org/" rel="nofollow">FreeCSSTemplates.org</a>.</p>
</div><!-- end #footer -->
</body>
</html>

Any other sugestions?
 

Link to comment
Share on other sites

You need to surround associative array indexes with quotes, unless they're a variable. So,

$Events_info[id], $events_info[Event_Type]

needs to be either

$Events_info['id'], $events_info['Event_Type']

or

$Events_info[$id], $events_info[$Event_Type]

As for the second error type, you're assigning an associative array into an indexed array on line 45, so $label in your foreach() on line 53 is actually an array still.

Edited by maxxd
Link to comment
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.