Title: PHP/HTML Form
Last modified: August 30, 2016

---

# PHP/HTML Form

 *  [richardsonje](https://wordpress.org/support/users/richardsonje/)
 * (@richardsonje)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/phphtml-form/)
 * I see the post that was on here the other day about PHP and HTML form but it 
   doesn’t seem to be working for me. When I view the page it just doesn’t show 
   anything. I put the same php into a template and that seems to execute, just 
   without any of the formatting. Here’s the code:
 * >  [insert_php]
   > mysql_connect(“sql”, “login”, “supersecret”)
   >  or die(mysql_error());
   > mysql_select_db(“mycars”)
   >  or die(mysql_error());
   > $sql = ” SELECT vehicles.VYear,
   >  vmake.VMake, vmodel.VModel, vehicles.VTrim,
   > vehicles.VehicleID, vehicles.VThumbnail
   >  FROM vehicles
   >  INNER JOIN mycars.vmake ON vehicles.VMakeID = vmake.VMakeID
   > INNER JOIN mycars.vmodel ON vehicles.VModelID = vmodel.VModelID
   >  WHERE vehicles.VCurrentlyOwn = ‘1’”;
   >  $result = mysql_query($sql)or die(mysql_error());
   >  while($row = mysql_fetch_array($result)){
   >  $year = $row[‘VYear’];
   >  $make = $row[‘VMake’]; $model = $row[‘VModel’]; $trim
   > = $row[‘VTrim’]; $vid = $row[‘VehicleID’]; $pic = $row[‘VThumbnail’];
   >  echo “<table>”;
   >  echo ” <tr> <th>Year</th> <th>Make</th> <th>Model</th> <th
   > >Trim</th> <th>”.’[<img src=”images/addnew.png” width=”33px” height=”25px”>](https://wordpress.org/support/topic/phphtml-form/newcar.php?output_format=md)‘.”
   > </th> </tr>”;
   >  echo ” <tr>
   >  <td style=’width: 50px;’>”.$year.”</td> <td style=’width: 175px;’
   > >”.$make.”</td> <td style=’width: 200px;’>”.$model.”</td> <td style=’width:
   > 100px;’>”.$trim.”</td> <td style=’width: 25px;’>”.’[<img src=”images/document.png” width=”33px” height=”25px”>](https://wordpress.org/support/topic/phphtml-form/mycarsprofile.php?id=&apos; .$vid. &apos;)‘.”
   > </td> </tr>”;
   >  echo”</table>”;
   > [/insert_php]
 * This code works fine outside of wordpress.
 * [https://wordpress.org/plugins/insert-php/](https://wordpress.org/plugins/insert-php/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/phphtml-form/#post-6310153)
 * Hi Richard,
 * It looks like the closing brace “}” for the while() loop is missing.
 * Funny you didn’t get an error on the web page. Maybe error messages have been
   turned off. Still, there should have been an error message in your error log.
 * If the code works in a separate page with <?php … ?>, then it should also work
   in a post with [insert_php] … [/insert_php]. There are a few exceptions:
 * [http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php#nonworkingelements](http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php#nonworkingelements)
 * Will
 *  Thread Starter [richardsonje](https://wordpress.org/support/users/richardsonje/)
 * (@richardsonje)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/phphtml-form/#post-6310154)
 * Thank you! I stared at that code way too long for it to have just been something
   so silly. Thank you!!
 *  [siddhartha dasar](https://wordpress.org/support/users/siddhartha-dasar/)
 * (@siddhartha-dasar)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/phphtml-form/#post-6310404)
 * where can i find the error log in my wordpress site
 *  [petewale](https://wordpress.org/support/users/petewale/)
 * (@petewale)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/phphtml-form/#post-6310405)
 * Hi guys,
 * Sorry to bother you with this but I am getting nothing outputted in my WP page
   and I am at a loss as to why. Would one of you kind people help me out?
 * Here is my code
 * [insert_php]
    mysql_connect(“localhost”,”USERNAME”,”PASSWORD”) or die(mysql_error());
 * mysql_select_db(“DB”)
    or die(mysql_error());
 * $result = mysql_query(“SELECT * FROM activities WHERE id=6”);
 * while($row = mysql_fetch_array($result))
    {
 * $day=$row[‘DAY’];
    $course=$row[‘Course’]; $location=$row[‘Location’]; $price
   =$row[‘Price’]; $duration=$row[‘Duration’]; $startDate=$row[‘StartDate’]; $startTime
   =$row[‘StartTime’]; $courseDes=$row[‘CourseDes’]; $sessionDes=$row[‘SessionDes’];
   $contactName=$row[‘ContactName’]; $contactEmail=$row[‘ContactEmail’]; $contactNumber
   =$row[‘ContactNumber’];
 * echo “<table>”;
    echo “<tr><td>Day:</td><td>”.$day.”</td></tr>”; echo “<tr><td
   >Course:</td><td>”.$course.”</td><td>Location:</td><td>”.$location.”</td></tr
   >”; echo “<tr><td>Price:</td><td>”.$day.”</td><td>Duration:</td><td>”.$duration.”
   </td></tr>”; echo “<tr><td height=”10″> </td></tr>”; echo “<tr><td>Description:
   </td><td>”.$courseDes.”</td></tr>”; echo “<tr><td height=”10″> </td></tr>”; echo“
   <tr><td>Each Session Includes:</td><td>”.$sessionDes.”</td></tr>”; echo “<tr>
   <td height=”10″> </td></tr>”; echo “<tr><td>Coach:</td><td>”.$contactName.”</
   td></tr>”; echo “<tr><td>Email:</td><td>”.$contactEmail.”</td></tr>”; echo “<
   tr><td>Number:</td><td>”.$contactNumber.”</td></tr>”; echo “<tr><td height=”20″
   > </td></tr>”; echo “</table>”;
 * }
    [/insert_php]
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/phphtml-form/#post-6310406)
 * The instructions page
 * [http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php](http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php)
 * describes how to deal with error messages. If you don’t get error messages or
   don’t know where to find them, put the PHP code into a standalone .php web page
   to debug it.
 * When the PHP code is debugged and it works as you want it to, then put it back
   into your WordPress post or page for Insert PHP to process.
 * Will

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘PHP/HTML Form’ is closed to new replies.

 * ![](https://ps.w.org/insert-php/assets/icon-256x256.gif?rev=3523853)
 * [Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts](https://wordpress.org/plugins/insert-php/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-php/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-php/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-php/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-php/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-php/reviews/)

 * 5 replies
 * 4 participants
 * Last reply from: [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/phphtml-form/#post-6310406)
 * Status: not resolved