Syntax error in code forms.

General discussions related to php

Moderators: macek, egami, gesf

xymalf99
New php-forum User
New php-forum User
Posts: 1
Joined: Mon Jun 30, 2014 1:30 pm

Syntax error in code forms.

Postby xymalf99 » Mon Jun 30, 2014 1:38 pm

Code: Select all

//  Then you actually have to declare the functions that will generate the pages/page content.
function boj_menuexample_settings_page() {

  echo "<h1>Settings Page</h1>";

}
function boj_menuexample_about_page() {

  echo "<h1>APPLICATION</h1>";

function displayBook ($resultItems)
{
foreach ($resultItems AS $item)
{
$title = $item['ProductName'];
$url = $item['Url'];
$image = $item['ImageUrlSmall'];
$authorList = implode($item['Authors'], ", ");
$price = $item['ListPrice'];
if ($url != "") echo "<img src=\"$image\" align=\"left\">";
echo "<a href=\"$url\" title=\" Learn More at Amazon.com\">$title<a><br>";
echo "Author(s): ". $authorList. "<br>";
echo "List Price:" . $price;
echo "<br>";
}
}

function runSearchQuery($client, $keywords, $page, $mode , $type='lite')

{
$params = array(
'keyword' => $keywords,
'page' => $page,
'mode' => $mode,
'tag' => 'xymalfsentert-',
'type' => $type,
'devtag' => 'AKIAIQ2ZQ6',

);

$namespace = 'http://soap.amazon.com';
$action = 'http://soap.amazon.com';
$method = "KeywordSearchRequest";
$result = $client->call($methos, array('KeywordSearchRequest' =>$params),
$namespace, $action);

return $result;

}


<form action="./soap.search.php" method ="get">  ## syntax error here ##
<input type="text" name="query">
<input type="hidden" name="page" value="1">
<select name="mode">

$modes = array();
$modes[] = "books";


foreach ($modes as $mode)
{
echo "<option value =\"$mode\">$mode</option>";
}
</select>
<input type="submit">
</form> ## syntax error here ##



$resultItems = $result['Details'];

switch ($mode)
{
case "books":
displayBook($resultItems);
break;
}
if ($result['TotalPages'] > $page)
{
$page++;
echo "<a href=\"soap.search.php?query&mode&page=$page\"> Next 10 Results</a>";
}




}
function boj_menuexample_uninstall_page() {

  echo "<h1>Uninstall Page</h1>";

}

?>


I am trying to develop a Wordpress Plugin but so far have hit a brick wall as it is saying syntax error where my Form code is. Also ideally I want to store the Amazon Affiliate tag and Access key on my settings page and then have the Application get these settings. Any idea what the syntax error is? How can I store users setting on the settings page but then use them? Is using SOAP the best way to access Amazon API as ideally I want to store the results in a table that the user can use in a wordpress post with his Affiliate ID attached to a buy now button. :o

landi
php-forum Active User
php-forum Active User
Posts: 263
Joined: Thu Mar 15, 2012 3:59 pm

Re: Syntax error in code forms.

Postby landi » Tue Aug 05, 2014 9:22 am

It's a bit old, but in case anyone else reads this...

1) You need to close and re-open your php tags appropriately. e.g.

You have:

Code: Select all

}
<form action="./soap.search.php" method ="get">  ## syntax error here ##
<input type="text" name="query">
<input type="hidden" name="page" value="1">
<select name="mode">

$modes = array();


You should have:

Code: Select all

}
?>
<form action="./soap.search.php" method ="get">  ## syntax error here ##
<input type="text" name="query">
<input type="hidden" name="page" value="1">
<select name="mode">
<?php
$modes = array();


Plus you have several undefined variables further down.
phpStorm told me this - it's my third php editor, and it's really magic. If you are a home user it costs less than a good night out...


Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 1 guest