• Hi,

    I downloaded the plugin, pasted my code in, and there is an error: Parse error: syntax error, unexpected ‘if’ (T_IF) in /home/content/a2pnexwpnas01_data01/13/3468913/html/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 4.

    Here is my code:
    [insert_php]
    $db = new mysqli(‘ip’, ‘user’, ‘password’, ‘database’);
     
    if($db->connect_errno > 0){
        die(‘Unable to connect to database [‘ . $db->connect_error . ‘]’);
    }
    $sql = “SELECT * FROM banlist ORDER BY banTime DESC”;
     
    if(!$result = $db->query($sql)){
        die(‘There was an error running the query [‘ . $db->error . ‘]’);
    }
     
    function convertToHumanReadableTime($seconds)
    {
        $ret = “”;
        if (empty($seconds))
        {
            return “Permanent”;
        }
        /*** get the days ***/
        $days = intval(intval($seconds) / (3600*24));
        if($days> 0)
        {
            $ret .= “$days days “;
        }
     
        /*** get the hours ***/
        $hours = (intval($seconds) / 3600) % 24;
        if($hours > 0)
        {
            $ret .= “$hours hours “;
        }
     
        /*** get the minutes ***/
        $minutes = (intval($seconds) / 60) % 60;
        if($minutes > 0)
        {
            $ret .= “$minutes minutes “;
        }
     
        /*** get the seconds ***/
        $seconds = intval($seconds) % 60;
        if ($seconds > 0) {
            $ret .= “$seconds seconds”;
        }
     
        return $ret;
    }
     
    echo ‘<table class=”table table-striped”>
     <tr>
       <th>Character Name</th>
        <th>Ban Reason</th>
       <th>Ban Length</th>
        <th>Banned On</th>
     </tr>’;
     
    while($row = $result->fetch_assoc()){
        echo ‘<tr>
       <td>‘.$row[‘charactername’].’</td>
        <td>’.$row[‘banMessage’].'</td>
       <td>’.convertToHumanReadableTime($row[‘banDuration’]).'</td>
        <td>’.date(“m/d/Y”, strtotime($row[‘banTime’])).'</td>
     </tr>’;
    }
    echo ‘</table>’;
    [/insert_php]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Error on line 4?’ is closed to new replies.