把div放在MYSQL中死 [英] Put div in MYSQL die

查看:109
本文介绍了把div放在MYSQL中死的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个mysql请求:

I have this mysql request:

mysql_query($query) or die(mysql_error());

很简单,但我想更改 mysql_error / code> for this div:

It´s simple, but I want to change the mysql_error() for this div:

<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>


推荐答案

p>

It's better to make function for showing errors :

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');

这篇关于把div放在MYSQL中死的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆