Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAnabel Gonzalez
3,937 PointsI am having problem with this exercise. I just did what the task asked me to and it is displaying an error
The error says that i should put a value attribute to the input text, but it ois already there.
<?php
require_once("inc/config.php");
$name=$_GET["s"];
$search_term = "";
if (isset($_GET["s"])) {
$search_term = trim($_GET["s"]);
if ($search_term != "") {
require_once(ROOT_PATH . "inc/products.php");
$products = get_products_search($search_term);
}
}
$pageTitle = "Search";
$section = "search";
include(ROOT_PATH . "inc/header.php"); ?>
<div class="section shirts search page">
<div class="wrapper">
<h1>Search</h1>
<form method="get" action="./">
<input type="text" name="s" value="<?php if (isset($name)) { echo htmlspecialchars($name); } ?>">
<input type="submit" value="Go">
</form>
<?php
if ($search_term != "") {
if (!empty($products)) {
echo '<ul class="products">';
foreach ($products as $product) {
echo get_list_view_html($product);
}
echo '</ul>';
} else {
echo '<p>No products were found matching that search term.</p>';
}
}
?>
</div>
</div>
<?php include(ROOT_PATH . "inc/footer.php"); ?>
Shawn Jones
15,579 PointsShawn Jones
15,579 PointsLooks like you have a conditional on value which could make it unset if $name isn't set to anything. considering that it's a get variable that's setting name, I would check the url to see if you can see the variable set, if so, then do a var dumb on $name to check to see if it's being stored there. If it's stored there, I would try to remove the conditional from the value by maybe cleaning it up at the top after retrieving the $GET variable and then storing the stripped version and then simply echoing the variable for value down below instead of right then. either way, I would probably do a var dumb after it's cleaned to be sure I was getting what I wanted for value. Example would be something like this :
Don't know what your working on, but it's worth a shot removing the conditional as it could be the reason why you have no value set and causing the error. If you want to elaborate more on the question I'm here.