Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将div放入模具中_Php_Html_Mysql_Css - Fatal编程技术网

Php 将div放入模具中

Php 将div放入模具中,php,html,mysql,css,Php,Html,Mysql,Css,我有一个mysql请求: mysql_query($query) or die(mysql_error()); 这很简单,但我想更改此div的mysql\u error(): <div class="ui-widget"> <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;"> <p><span class

我有一个mysql请求:

mysql_query($query) or die(mysql_error());
这很简单,但我想更改此div的
mysql\u error()

<div class="ui-widget">
    <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
        <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
        <strong>Error!</strong></p>
    </div>
</div>


错误


您可以将整个html代码放入一个变量中,如下所示:

$var = '<div class="ui-widget">
    <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
        <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
        <strong>Error!</strong></p>
    </div>
</div>';

最好使用显示错误的函数:

function show_error($error_text){
    $var = '<div class="ui-widget">
        <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
        <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
        <strong>'.$error_text.'</strong></p>
        </div>
        </div>';
    die($var);
}

如果插入工作正常,除了文本,我怎么做呢。示例:使用该函数显示插入是否正确,如此查询OK!在我的项目中,你会发现3个函数,一个用于显示和记录错误,通常称为report_error,一个用于警告,另一个用于向用户报告成功,因此你应该自己制作一些东西。有关更多信息,请与我联系。:)不要使用die()进行错误处理。曾经使用异常,它们内置在PHP中,错误处理是它们存在的唯一原因。mysql_*函数不推荐使用。
function show_error($error_text){
    $var = '<div class="ui-widget">
        <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
        <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
        <strong>'.$error_text.'</strong></p>
        </div>
        </div>';
    die($var);
}
mysql_query($query) or show_error('Query execute failed');