Note that there are some explanatory texts on larger screens.

plurals
  1. POIF ELSE in PHP is not executing, debugged and still cannot find issue
    text
    copied!<p>I've used php before and never run into this problem....</p> <p>I have radio buttons which pass on their own value. When my form is submitted I have verified that the value passed matches the if statement condition in my code. However, it will not execute that path.</p> <p>For example, when the city radio button is selected, the if condition pertaining to city does not execute. I have debugged by placing an echo statement ahead of the if statement and it matches the value in the if statement, hence my confusion on why it does not execute.</p> <p>If anyone can help I'd be grateful... I'm quite baffled.</p> <p>Heres the html:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Lab 5&lt;/title&gt; &lt;link rel='stylesheet' href='SearchForm.css' type='text/css' media='all' /&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;You may use % as a wildcard character in your search.&lt;/p&gt; &lt;form method='POST' action='index.php?type=search'&gt; &lt;input type='text' name='search_param' value='' /&gt; &lt;input type='radio' name='search-type' value='City' id='city' /&gt; &lt;label for='city'&gt;City&lt;/label&gt; &lt;input type='radio' name='search-type' value='Country' id='country' /&gt; &lt;label for='country'&gt;Country&lt;/label&gt; &lt;input type='radio' name='search-type' value='Language' id='language' /&gt; &lt;label for='language'&gt;Language&lt;/label&gt; &lt;br /&gt;&lt;br /&gt; &lt;input type='submit' name='submit' value='Search' /&gt; &lt;/form&gt; &lt;p&gt;Or, &lt;a href='index.php?type=insert'&gt;perform an insertion.&lt;/a&gt;&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and the php: </p> <pre><code>&lt;?php include 'connect.php'; $table = $_POST['search-type']; $search = $_POST['search_param']; if($table != NULL) { echo '&lt;table&gt;'; if($table == 'City') { $query = "SELECT * FROM city WHERE name ILIKE $1 ORDER BY name;"; $stmt = pg_prepare($connection, "city", $query); $result = pg_execute($connection, "city", array($search)); while($row = pg_fetch_assoc($result)) { cityTable($row); } echo '&lt;/table&gt;'; } } else { echo 'Please select a table to query!'; } </code></pre> <p>As you can see, I've even removed the variable <code>$search</code> from my if condition, instead going straight to the post.</p> <p>When I've echoed <code>$search</code> it yields "city" so..... please help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload