在PHP代码上发送HTML电子邮件会给我一个语法错误

时间:2019-01-26 05:50:14

标签: php html mysql database syntax

早上好,我在执行代码时遇到问题,我认为引号等问题。

到目前为止,这是我已经尝试过的方法,但是对于这行特定的代码,我仍然感到语法错误。

$message .= "if ($row['status']) :
        		$output .= '<td>'.$row["status"].'</td> ';
    			else:
        		$output .= '
                <td>
                    <form method="post" action="update-request-status.php">
                        <input type="hidden" name="reqnumber" value="'.$row['reqnumber'].'" />
                        <button class="button" type="submit" name="completed" value=""><span>New Request!</span></button>
                    </form>
                </td>";

这是现在的样子:

Summary

Error

2 个答案:

答案 0 :(得分:1)

您的逻辑和引号有误,也许这就是您想要的:

if ($row['status']) :
            $output .= '<td>'.$row["status"].'</td> ';
            else:
            $output .= '
            <td>
                <form method="post" action="update-request-status.php">
                    <input type="hidden" name="reqnumber" value="'.$row['reqnumber'].'" />
                    <button class="button" type="submit" name="completed" value=""><span>New Request!</span></button>
                </form>
            </td>';
endif;
$message .= $output;

答案 1 :(得分:0)

正如Hasta Dhana回答的那样,这是有关为什么他完全更改代码的一些细节。

您使用的这段代码

    month year GrandTotal   Date         
1     6  2014   15172331    2014-06-30
2     7  2014   24381383    2014-07-31
3     8  2014   24351338    2014-08-31
...
46     3  2018   85980914    2018-03-31
47     4  2018   72723488    2018-04-30


y <- ts(briskaranged, start=2014, frequency=12)
library(ggplot2)
#ploting of variables
autoplot(y) + 
labs(x ="Date", y = "GrandTotal", title = "Amount, ggplot2")
#seasonalplot
ggseasonplot(y, year.labels=TRUE, year.labels.left=TRUE) +
ylab("amount") +
ggtitle("Seasonal plot: amount transaction per day")

使$ message输出与您编写代码的方式完全相同,因为php并未将其定义为过程代码。 $message .= "if ($row['status']) : $output .= '<td>'.$row["status"].'</td> '; else: $output .= ' <td> <form method="post" action="update-request-status.php"> <input type="hidden" name="reqnumber" value="'.$row['reqnumber'].'" /> <button class="button" type="submit" name="completed" value=""><span>New Request!</span></button> </form> </td>";的目的是通知php代码处理器您编写的是字符串而不是进程。另请参阅INFO,以了解有关如何在php中使用html的更多信息。

编辑后 您可以检查数组的拼写吗?