小编jcs*_*lzr的帖子

什么是+ =用于?

我认为这是一个愚蠢的问题,但我无法在PHP上找到它.为什么在以下代码中带有=的+:

function calculateRanking()
{
    $created = $this->getCreated();

    $diff = $this->getTimeDifference($created, date('F d, Y h:i:s A'));

    $time = $diff['days'] * 24;
    $time += $diff['hours'];
    $time += ($diff['minutes'] / 60);
    $time += (($diff['seconds'] / 60)/60);

    $base = $time + 2;        

    $this->ranking = ($this->points - 1) / pow($base, 1.5);

    $this->save();
}
Run Code Online (Sandbox Code Playgroud)

这是多少时间有所有这些值,或者更确切地说它是将所有值添加到$ time?

谢谢

php

9
推荐指数
3
解决办法
2927
查看次数

PHP中的异常处理:$ e在哪里?

我一直在寻找这个,我似乎只是遇到了相同的文章,在这段代码中:

   try
    {
        //some code

    }
    catch(Exception $e){
        throw $e;
    }
Run Code Online (Sandbox Code Playgroud)

$ e存储在哪里或网站管理员如何看待它?我应该寻找特殊功能吗?

php exception

5
推荐指数
2
解决办法
720
查看次数

链接css下划线

在我的css文件中,我的页脚有以下样式:

#footer { 
    text-align: center;
    font-size: .7em;
    color:#000000;
}
Run Code Online (Sandbox Code Playgroud)

这是页脚部分的html:

<div id="footer">
   <br> //google ad
   <br>
   <br>
   <A HREF="http://www.site1.com">Blog</A>&nbsp;&nbsp;&nbsp;<A     
   HREF="http://site1/rss.xml">RSS</A>&nbsp;&nbsp;&nbsp;<A 
   HREF="http://www.mexautos.com">Autos Usados</A>&nbsp;&nbsp;&nbsp;<A 
   HREF="http://www.site2">Videos Chistosos</A>&nbsp;&nbsp;&nbsp;<A 
   HREF="http:/s.blogspot.com">Fotos de Chavas</A><br>
   Derechos Reservados &copy; 2008-<?=date('Y')?> address<br>
</div>
Run Code Online (Sandbox Code Playgroud)

但出于某种原因,一些链接显示有下划线.

任何想法我怎么能这样做链接不会出现下划线?

谢谢

html css hyperlink underline

4
推荐指数
3
解决办法
4067
查看次数

如何在我的网站上实施投票系统,将投票限制为一票?

我正在尝试建立一个可以投票的新闻链接的网站,我有以下代码:

 case 'vote':
                require_once('auth/auth.php');
                if(Auth::isUserLoggedIn())
                {
                    require_once('data/article.php');
                    require_once('includes/helpers.php');

                    $id = isset($_GET['param'])? $_GET['param'] : 0;
                    if($id > 0)
                    {
                        $article = Article::getById($id);
                        $article->vote();
                        $article->calculateRanking();
                    }
                    if(!isset($_SESSION)) session_start();
                    redirectTo($_SESSION['action'], $_SESSION['param']);
                }
                else
                {
                    Auth::redirectToLogin(); 
                }
                break;
Run Code Online (Sandbox Code Playgroud)

现在的问题是如何检查所以同一个用户不投票两次,这里是文章文件:

<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/config.php'); 
require_once(SITE_ROOT.'includes/exceptions.php'); 
require_once(SITE_ROOT.'data/model.php');
require_once(SITE_ROOT.'data/comment.php');

class Article extends Model 
{
    private $id;
    private $user_id;
    private $url;
    private $title;
    private $description;
    private $ranking;
    private $points;

    function __construct($title = ' ', $description = ' ', $url = ' ', $username = ' ', $created = ' ', …
Run Code Online (Sandbox Code Playgroud)

php

1
推荐指数
1
解决办法
1104
查看次数

访问过的链接颜色变化

我有这门课:

.news_item_info 
{
    font-size: .7em; 
    color:#000000; 
    text-indent: 30px;
    a:link { color: #000000; }
    a:visited { color: #000000; }   
}
Run Code Online (Sandbox Code Playgroud)

这里有代码:

<div class="news_item_info">
    <?php echo $articles[$index]->getPoints(); ?> puntos por <span class="news_item_user"><a href="/index.php?action=user&param=<?php echo $articles[$index]->getUsername(); ?>">
    <?php echo $articles[$index]->getUsername(); ?></a> </span>
    <?php echo $articles[$index]->getElapsedDateTime(); ?> | <span class="comments_count"><a href="<?php echo "/index.php?action=comments&param=".$articles[$index]->getId(); ?>"><?php echo $articles[$index]->getNumberOfComments($articles[$index]->getId()); ?> comentarios</a></span>
</div>
Run Code Online (Sandbox Code Playgroud)

问题是,在我访问用户配置文件后,它显示为灰色,我想保持黑色.

如果有人知道答案我会很感激.

html css php

1
推荐指数
1
解决办法
2658
查看次数

数据库错误:[mysqli.mysqli]:用户已经有超过'max_user_connections'活动连接

我有一个每天只有大约100人的网站但是当我以用户身份登录时收到此错误消息:

Warning: mysqli::mysqli() [mysqli.mysqli]: (42000/1203): User mexautos_Juan already has more than 'max_user_connections' active connections in /home/mexautos/public_html/kiubbo/data/model.php on line 26

Warning: mysqli::query() [mysqli.query]: Couldn't fetch mysqli in /home/mexautos/public_html/kiubbo/data/model.php on line 87
Query failed 
Run Code Online (Sandbox Code Playgroud)

我刷新页面几次,现在还可以,但是由于我没有那么多用户,我怀疑我的代码中出现了错误,我应该在哪里寻找它?

谢谢

编辑:这是模型文件:

<?php
/* 

    Model is the base class from which the other
    model classes will be derived. It offers basic
    functionality to access databases

*/ 
require_once($_SERVER['DOCUMENT_ROOT'].'/config.php'); 
require_once(SITE_ROOT.'includes/exceptions.php'); 

class Model {

    private $created;
    private $modified;

    static function getConnection()
    {
        /* 

            Connect to the database and return a …
Run Code Online (Sandbox Code Playgroud)

php mysql database mysqli

0
推荐指数
1
解决办法
681
查看次数

不同的图像取决于用户是否已经投票

我正在开发一个链接投票网站,我有这个功能,检查用户是否已经投票链接:

function  has_voted($user) 
    {
       try
        {
            $db = parent::getConnection();
            $query = "select id from votes where username = '$user' and article_id  = $this->id";
            $results = parent::execSQL($query);
            if($results->num_rows == 1) {
                return true;                 
            }
            else 
            {
                return false;
            }            
            parent::closeConnection($db);

        }
        catch(Exception $e){
            throw $e;
        }       
    }
Run Code Online (Sandbox Code Playgroud)

在首页我显示一个图像用这行投票:

  <a href="/index.php?action=vote&amp;param=<?php echo $articles[$index]->getId(); ?>">
<img class="vote_button" src="assets/images/triangulo.png" />
</a>
Run Code Online (Sandbox Code Playgroud)

如果用户已经投票,我希望它插入"if"来显示不同的图像,我尝试了这个,但它显示错误:

    <a href="/index.php?action=vote&amp;param=<?php echo $articles[$index]->getId(); ?>">
<?php if($articles[$index]->has_voted($articles[$index]->getUsername()) == true) 
{ ?><img src="assets/images/triangulo.png"/></a><?php } 
else 
{ ?><img class="vote_button"  src="assets/images/triangulo2.png" /></a><?php } ?>
Run Code Online (Sandbox Code Playgroud)

+++编辑: …

php

0
推荐指数
1
解决办法
370
查看次数

在PHP中清理发往数据库的用户输入

我有这个代码:

$query = "select id from votes where username = '$user' and article_id  = $this->id";
Run Code Online (Sandbox Code Playgroud)

我尝试使用此代码来清理它:

$query = sprintf("select id from votes where username = '$user' and article_id = $this->id", 
    mysql_real_escape_string($user), 
    mysql_real_escape_string($password));
Run Code Online (Sandbox Code Playgroud)

但我得到mysql_real_escape行的这个错误:

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'mexautos'@'localhost' (using password: NO) in /home/mexautos/public_html/kiubbo/data/article.php on line 145 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/mexautos/public_html/kiubbo/data/article.php on line 145 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'mexautos'@'localhost' (using password: NO) in /home/mexautos/public_html/kiubbo/data/article.php on …
Run Code Online (Sandbox Code Playgroud)

php sanitization sql-injection code-injection sanitize

0
推荐指数
2
解决办法
2822
查看次数