小编Pau*_*ert的帖子

PDO PARAM_STR和长度

我不明白PDO PARAM_*声明中的长度选项.

长度是表示所需字符的数量,还是最大值?

例:

$sth->bindParam(2, $color, PDO::PARAM_STR, 12);
Run Code Online (Sandbox Code Playgroud)

这需要12个字符,还是将其限制为12个字符?或者,我完全误解了这是做什么的?

php pdo

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

localhost上的dirname(__ FILE__)

我正在使用WAMP并在www目录中有一个开发站点.我想用来dirname(__FILE__)定义服务器根目录的路径.

目前我正在使用包含以下内容的配置文件:

define('PATH', dirname(__FILE__));
Run Code Online (Sandbox Code Playgroud)

我将配置文件包含在我的header.php文件中,如下所示:

<?php require_once("config.php") ?>
Run Code Online (Sandbox Code Playgroud)

然后,在我的子页面上,我使用常量PATH来通过包含来定义路径header.php.

<?php require_once("../inc/header.php"); ?> 
Run Code Online (Sandbox Code Playgroud)

但是,我的链接是这样的:

<link rel="stylesheet" href="C:\wamp\www/css/style.css" />
Run Code Online (Sandbox Code Playgroud)

我需要做些什么来解决这个问题?因为我在header.php文件中包含了我的常量,所以我无法访问初始中的常量.require_once("../inc/header.php");我可以使用什么其他方法来查找根目录header.php

php wamp constants

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

localhost上的$ _SERVER ['PATH_INFO']

我在$_SERVER['PATH_INFO']本地主机上使用时出现以下错误:

Notice: Undefined index: PATH_INFO
Run Code Online (Sandbox Code Playgroud)

我正在使用WAMP.有人能告诉我为什么会这样吗?

php

4
推荐指数
2
解决办法
1万
查看次数

限制数组中的项目数

我有一个通过foreach循环处理的数组.

foreach($images as $imageChoices) {
    Do stuff here
}
Run Code Online (Sandbox Code Playgroud)

如何限制循环只处理数组中的前4项?

php

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

JqPlot 1.0如何使用日期轴和图例创建折线图

首先,提前感谢您的答案.

这是我的问题.我有一个JqPlot的线性图表,我需要显示图例,但我不知道如何更改系列名称.我们怎么做?

这是我的代码.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.jqplot.min.js"></script>
<script type="text/javascript" src="plugins/jqplot.dateAxisRenderer.min.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.jqplot.css" />

<script type="text/javascript" language="javascript">
$(document).ready(function(){
  var line1=[['2008-06-30',4], ['2008-7-14',6.5], ['2008-7-28',5.7], ['2008-8-11',9],     ['2008-8-25',8.2]];
  var line2=[['2008-06-30',8], ['2008-7-14',5], ['2008-7-28',7], ['2008-8-11',2],     ['2008-8-25',2]];
  var plot2 = $.jqplot('conteneur', [line1,line2], {
      title:'Customized Date Axis', 
      seriesDefaults: {
            rendererOptions: {
                //////
                // Turn on line smoothing.  By default, a constrained cubic spline
                // interpolation algorithm is used which will not overshoot or
                // undershoot any data points.
                ////// …
Run Code Online (Sandbox Code Playgroud)

jquery date legend jqplot

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

PHP安全和XSS攻击 - 拒绝错误执行JavaScript脚本.在请求中找到的脚本的源代码

我正在浏览我的网站并进行安全审核.我只是接受了这样一个事实,即我需要清理所有用户输入,但我从未真正停止并尝试过真正发生的事情.我现在开始尝试了.

我在PHP页面上有一个典型的联系表单.这是_POST数据.$_POST["first_name"];等等

我这样做是$firstName = htmlspecialchars($_POST["first_name"]);为了清理和显示如下所示的消息.

echo $firstName . ', thank you for your interest. We'll be in touch soon!'
Run Code Online (Sandbox Code Playgroud)

我开始玩这个,如果我输入诸如<script>alert('hello')</script>名字字段之类的内容,htmlspecialchars它是否有工作并且会隐藏标签.

当我删除htmlspecialchars脚本时没有转换它并在源中显示为<script>alert('hello')</script>BUT,它不会执行.

我的问题是,为什么不执行?这基本上不是XSS攻击会做的吗?我误会了什么吗?

php security xss code-injection

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

Jquery - 自动计算输入字段

我正在尝试使此代码在下面工作,我将非常感谢您的帮助。基本上它是计算三个输入字段的总和,然后与其他两个字段相乘。最终结果应显示在输入字段 pcamount 中。

这是 jsFiddle 中的示例:http : //jsfiddle.net/D98PW/

波纹管是jquery脚本和html

在此先感谢您的帮助!

 $(document).ready(function() {
   $('input[name=deposit], input[name=minpremium], input[name=adjpremium],input[name=procombaserate], input[name=profcomper], input[name=pcamount]').change(function(e)  {
        var total_mnozi = 0;
        var total=0;
        var $row = $(this).parent();
        var dep = $row.find('input[name=deposit]').val();
        var minpre = $row.find('input[name=minpremium]').val();
        var adjpre = $row.find('input[name=adjpremium]').val();
        var procombase = $row.find('input[name=procombaserate]').val();
        var profcomper = $row.find('input[name=profcomper]').val();
       // var pcamount= $row.find('input[name=pcamount]').val();
       // total_mnozi= procombase * profcomper;
         $('dep, minpre, adjpre').each(function() {
       total += parseFloat($(this));
          total_mnozi = total * procombase * profcomper;
          $row.find('input[name=pcamount]').val( total_mnozi);

  });   
    });
   });
Run Code Online (Sandbox Code Playgroud)

和 html

<table …
Run Code Online (Sandbox Code Playgroud)

html jquery

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

::在边距和填充之后

我正在创建一个这样的水平菜单:

.leftNav li{
    list-style: none;
    padding: 1em;
    font-size: 1em;
    display: inline;
    color: #fff;
}
.leftNav li::after{
    content: " | ";
}
Run Code Online (Sandbox Code Playgroud)

我得到:

menu item 1 |      menu item 2 |      menu item 3 |
Run Code Online (Sandbox Code Playgroud)

我希望每个之间的间距相等:

menu item 1   |   menu item 2   |   menu item 3 |
Run Code Online (Sandbox Code Playgroud)

我想marginpadding会处理这个问题,但事实并非如此。

html css

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

PDO阵列和array_unique

我正在尝试使用从数据库返回课程ID的列表PDO。我可以访问数据,但是,我只想返回唯一ID的数组,即

这个

1,2,2,3,4,4
Run Code Online (Sandbox Code Playgroud)

成为

1,2,3,4
Run Code Online (Sandbox Code Playgroud)

我正在使用下面的代码

$sth = $dbh->prepare('SELECT courseId from training');  
    $sth->execute();  
        $row = $sth->fetchAll();
        $result = array_unique($row);
        print_r($result); 
Run Code Online (Sandbox Code Playgroud)

但是,它仅返回1个id:

Array ( [0] => Array ( [courseId] => 8 [0] => 8 ) )
Run Code Online (Sandbox Code Playgroud)

如果我print_r $row能看到我所有的课程编号

我究竟做错了什么?

php pdo

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

array_unique只返回一条记录

在下面的代码中:

$sth = $dbh->query('SELECT DISTINCT title,courseId,location from training');  
$sth->setFetchMode(PDO::FETCH_ASSOC); 
$results = $sth->fetchAll();
$uu = array_unique($results);

echo "<pre>";
print_r($uu);
echo "</pre>";
Run Code Online (Sandbox Code Playgroud)

我只得到1个结果 print_r($uu);

如果我删除array_unique所有(30+)行返回.(不,并非所有这些都是重复的):)

我究竟做错了什么?

编辑var_dump()结果:

array(23) {
  [0]=>
  array(3) {
    ["title"]=>
    string(26) "String Here"
    ["courseId"]=>
    string(1) "8"
    ["location"]=>
    string(1) "1"
  }
  [1]=>
  array(3) {
    ["title"]=>
    string(26) "Another String Here"
    ["courseId"]=>
    string(1) "8"
    ["location"]=>
    string(1) "2"
  }
  [2]=>
  array(3) {
    ["title"]=>
    string(24) "Third String Here"
    ["courseId"]=>
    string(1) "5"
    ["location"]=>
    string(1) "2"
  }
Run Code Online (Sandbox Code Playgroud)

等等...

php array-unique

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

标签 统计

php ×7

html ×2

jquery ×2

pdo ×2

array-unique ×1

code-injection ×1

constants ×1

css ×1

date ×1

jqplot ×1

legend ×1

security ×1

wamp ×1

xss ×1