小编Mas*_*ile的帖子

如何计算每个学期的营业额

我有一个column在SQL table.这包含一个date交货单.

所以相同的日期可以重复(在一天我们交付几个订单),像这样:

05-01-16
05-01-16
05-01-16
08-01-16
08-01-16
14-01-16
22-01-16
22-01-16
04-02-16
05-02-16
05-02-16
Run Code Online (Sandbox Code Playgroud)

我想,计算每篇文章的营业额的AVG each 6 months,我解释一下:

From January to June ==> Turnover 1
From Febrary to July ==> Turnover 2
From March to August ==> Turnover 3
From April to September ==> Turnover 4
From May to Obtober ==> Turnover 5
From June to November ==> Turnover 6
From July to December ==> Turnover 7
Run Code Online (Sandbox Code Playgroud)

我已经通过下面的请求提取了月份,但是我无法动态计算(因为我的数据应该每个月更改一次)营业额如上例所示:

select distinct extract (month from …
Run Code Online (Sandbox Code Playgroud)

mysql sql

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

WebSocket 连接失败:连接建立错误:net::ERR_CONNECTION_TIMED_OUT

美好的一天

我正在使用棘轮构建聊天应用程序并将数据保存到 mysql 数据库。在本地主机上一切正常,连接已建立。

现在我已经在实时服务器上加载了应用程序并使用 SSH (Putty) 登录,然后php bin/chat-server.php在浏览器控制台上导航到我收到此错误:

WebSocket 连接到“wss://donorgametes.com:8080/”失败:连接建立错误:net::ERR_CONNECTION_TIMED_OUT

这是我的应用程序网址

https://donorgametes.com/MyApp/

我的代码:

<script>
    var conn = new WebSocket('wss://donorgametes.com:8080');
    conn.onopen = function (e) {
        console.log("Connection established!");

    };

    conn.onmessage = function (e) {
        showMessage(e.data, 'Others');
    };

    document.querySelector('#chat-form').addEventListener('submit', function (e) {
        e.preventDefault();

        var messageElement = document.querySelector('#message');
        var message = messageElement.value;

        var messageData = {
            'userId': '12',
            'content': message
        }
        var messageDataJson = JSON.stringify(messageData);

        conn.send(JSON.stringify(messageDataJson));
        showMessage(message, 'Me');
        messageElement.value = '';
    });

    function showMessage(msg, sender) {
        var messageItem = document.createElement('li');
        var …
Run Code Online (Sandbox Code Playgroud)

php websocket ratchet

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

致命错误:调用未定义函数mysql_real_escape_string()

致命错误:在第38行的/var/www/engine/database.php中调用未定义的函数mysql_real_escape_string()

我仍然可以连接到数据库。为什么不可用?

我正在使用PHP版本7.1.4

php mysql

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

Type error: Argument 1 passed to Illuminate\Database\Eloquent\Builder::create() must be of the type array, null given

i am trying to post title and article in laravel rest api i am getting this error

Type error: Argument 1 passed to Illuminate\Database\Eloquent\Builder::create() must be of the type array, null given, called in C:\xampp\htdocs\LaravelProject\cpapi\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 1440

This is my route/api.php file of post article data

Route::post('articles', 'ArticleController@store');

Route::post('articles', function(Request $request) {
   return Article::create($request->all);
});
Run Code Online (Sandbox Code Playgroud)

And this store function of ArticleController.php file

 public function store(Request $request)
    {
        $article = Article::create($request->all());

        return response()->json($article, 201);
    }
Run Code Online (Sandbox Code Playgroud)

This is article model class …

php laravel-5 laravel-eloquent

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

PHP和FPDI/FPDF:致命错误:未捕获异常:FPDF错误:输出目标不正确

我有一个PDF文件,我想用FPDI/FPDF添加一个新页面

致命错误:未捕获异常:FPDF错误:输出目标不正确:第271行中的C:\ wamp\www\pdf\fpdi\fpdf.php中的outfiles/111111.pdf(!)异常:FPDF错误:输出目标不正确:outfiles /第271行的C:\ wamp\www\pdf\fpdi\fpdf.php中的111111.pdf

require_once('fpdi/fpdf.php');
require_once('fpdi/fpdi.php');

foreach(glob('infiles/*.pdf') as $file)
{
    $filename = basename($file);
    $fileout = 'outfiles/' . $filename;
    //echo $fileout;
    $out = new FPDI();

    $pagecount = $out->setSourceFile($file);

    for($i = 1; $i <= $pagecount; $i++)
    {
        $tpl = $out->importPage($i); 

        $out->addPage($format);
        $out->useTemplate($tpl);

        if($i < $pagecount)
        {
            $out->addPage($format);
        }
    }

    $out->Output($fileout);
}
Run Code Online (Sandbox Code Playgroud)

php pdf fpdf fpdi

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

使用fpdf将html内容写入pdf

我正在尝试使用 fpdf 和 html2pdf 将 div 的内容写入 pdf 文件。但 WriteHTML 功能似乎不起作用。代码有什么问题吗?

它说

在 demo.php 第 43 行调用未定义函数 WriteHTML()

下面是我的代码。

<?php

$contents = $_POST['divContent'];


require_once('fpdf/fpdf.php') ;
require('html2pdf/html2pdf.php');

class PDF extends PDF_HTML
{
// Page header
function Header()
{
    // Logo
    $this->Image('fpdf/logo.png',10,6,30);
    // Arial bold 15
    $this->SetFont('Arial','B',15);
    // Move to the right
    $this->Cell(80);
    // Title
    $this->Cell(60,10,'Report',1,0,'C');
    // Line break
    $this->Ln(20);
}

// Page footer
function Footer()
{
    // Position at 1.5 cm from bottom
    $this->SetY(-15);
    // Arial italic 8
    $this->SetFont('Arial','I',8);
    // Page …
Run Code Online (Sandbox Code Playgroud)

php

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

无法在 PHP 中回显 JSON 数组

我无法访问我的 json,想知道错误在哪里。

$json = json_encode($data);
// string(1065) "[{"id":"test123","key":["one",...
Run Code Online (Sandbox Code Playgroud)

然后我对其进行解码以使其可以通过以下命令访问:

$json = json_decode($json, true);

// Output:
array(3) {
  [0]=>
  array(4) {
    ["id"]=>
    string(14) "test123"
Run Code Online (Sandbox Code Playgroud)

当我想回应它时,它给了我:

echo $json[0];
Run Code Online (Sandbox Code Playgroud)

数组到字符串的转换

php json

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

标签 统计

php ×6

mysql ×2

fpdf ×1

fpdi ×1

json ×1

laravel-5 ×1

laravel-eloquent ×1

pdf ×1

ratchet ×1

sql ×1

websocket ×1