• 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”>‘.”</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”>‘.”</td>
    </tr>”;

    echo”</table>”;

    [/insert_php]

    This code works fine outside of wordpress.

    https://wordpress.org/plugins/insert-php/

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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

    Will

    Thread Starter richardsonje

    (@richardsonje)

    Thank you! I stared at that code way too long for it to have just been something so silly. Thank you!!

    where can i find the error log in my wordpress site

    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]

    The instructions page

    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.