谁一开始就是大神?

PHP 第81页

PHP

ubuntu上的mysql启动不了了

ecyCherry阅读(84)

sbw@~$mysql -uroot -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

错误日志显示

150907 14:23:02 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
150907 14:23:02 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
150907 14:23:02 [Note] /usr/sbin/mysqld (mysqld 5.5.44-0ubuntu0.14.04.1) starting as process 11631 ...
150907 14:23:02 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
150907 14:23:02 [Note] Plugin 'FEDERATED' is disabled.
150907 14:23:02 [ERROR] Function 'innodb' already exists
150907 14:23:02 [Warning] Couldn't load plugin named 'innodb' with soname 'ha_innodb.so'.
150907 14:23:02 [ERROR] Function 'federated' already exists
150907 14:23:02 [Warning] Couldn't load plugin named 'federated' with soname 'ha_federated.so'.
150907 14:23:02 [ERROR] Function 'blackhole' already exists
150907 14:23:02 [Warning] Couldn't load plugin named 'blackhole' with soname 'ha_blackhole.so'.
150907 14:23:02 [ERROR] Function 'archive' already exists
150907 14:23:02 [Warning] Couldn't load plugin named 'archive' with soname 'ha_archive.so'.
150907 14:23:02 InnoDB: The InnoDB memory heap is disabled
150907 14:23:02 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150907 14:23:02 InnoDB: Compressed tables use zlib 1.2.8
150907 14:23:02 InnoDB: Using Linux native AIO
150907 14:23:02 InnoDB: Initializing buffer pool, size = 128.0M
150907 14:23:02 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
150907 14:23:02 [ERROR] Plugin 'InnoDB' init function returned error.
150907 14:23:02 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
150907 14:23:02 [ERROR] Unknown/unsupported storage engine: InnoDB
150907 14:23:02 [ERROR] Aborting

150907 14:23:02 [Note] /usr/sbin/mysqld: Shutdown complete

150907 14:23:02 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

重装,紫薯布丁~

redirect无法打开网页[2.0]

fationsea阅读(82)

if ($model->load(Yii::$app->request->post()) && $model->login()) {
    return $this->redirect(['panel/home/index']);
}

代码如上很简单,就是登录验证通过就redirect到http://host/panel/home/index,但是在本地和测试服务器上正常跳转了,在正式服务器上却会产生了网页刷新的动作却没有跳转到http://host/panel/home/index,我在return $this->redirect(['panel/home/index']);前加上echo"success";die();后成功输出了success,说明的确是运行到了redirect这里的,但是为什么会正式服务器上无法跳转?

两个环境服务器配置不一样。
试试
header(“Location:$url”);exit;
试试
return $this->redirect(‘panel/home/index’);
试试 return $this->redirect(['/panel/home/index']);
多了一个斜杠。
打开浏览器,切换到调试中的“network”看看 response中的header中是否有重定向302的状态码

Yii2.0接受接口信息[2.0]

NiceStone阅读(79)

SiteController代码:

public function actionIndex()
{
    $data = json_decode(api_request(url), true);
    return $this->render('index', [
        'list' => $data
    ]);
}

common/functions.php里面的方法:

const API_HEAD = 'http://api.weidu51.com/v2000/';
function api_request($uri, $params, $method = 'GET'){
    $apiUrl = API_HEAD . $uri;
    if($method == 'get'){
        $url = $apiUrl."page=10&psize=10&amp";
    }

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $apiUrl);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
    //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
    if($method == 'POST') {
        curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
    }
    curl_setopt($ch, CURLOPT_POSTFIELDS, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $result = json_decode(curl_exec($ch), true);
    
}

这个是要把这个接口的信息接收过来,转化成数组形式的,然后视图页面循环输出,但我看不懂,哪位大神指点一下什么意思?

就是用curl模拟get请求和post请求去接口请求数据,然后把拿到的json数据decode一下,curl_setopt的那一段是配置http请求的参数。

yiicreateCommand从数据库查出来的数据都变成了字符串格式[2.0]

Wendylemon阅读(81)

最近用YII做一个后台项目, 因为要转化成json呈现出来,发现直接用php的 json_encode()直接转化createCommand()->…出来的数据都变成了字符串格式,原本很普通的int也被加了引号.

ps: 自己手写数组就用json_encode()就不会.

这个createCommand官方文档也没说.

这个与YII没关系,是PDO的默认处理,解决方法只需在配置中的db配置中加上attributes的相关配置就行了,如下:
你确定int不是字符整型数? 你可以指定json_encode的第二个参数为JSON_NUMERIC_CHECK试一下能否解决这个问题。

YII2中markdown编辑器的使用[2.0]

Niceyak阅读(78)

本人看到了论坛里面有个朋友发了markdown的安装教程,现在也能成功显示了,现在不清楚如何在编辑页面显示文章原来的内容,以达到修改的目的。
现在已有视图代码

<?php $form = ActiveForm::begin(); ?>
    <?= Markdowneditor::widget(['model' => $model, 'attribute' => 'body']) ?>
    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

现在已有控制器代码

public function actionUpdate($id){
        $model=new Post();
        return $this->render('update',['model'=>$model]);
    }

数据库存的是md源代码,输出的也是md源代码,但是输出前需要format一下,可以使用 yii\helpers\Markdown::process(“内容”)

来玩个一句话描述的游戏,RESTful风格是啥[2.0]

foreverdear阅读(90)

四面八方的小伙伴看过来,被各种文档写得老长老长RESTful 风格,小伙伴们可否用一句简单的话描述下,简单粗暴无所谓,关键的让人印象深刻容易懂

提供了以get,post,delete等请求方式并根据请求方式的不同来响应不同的动作的一个接口地址
接口规范.

请问如何detailview里面如何设图片宽度?[2.0]

Bravequeen阅读(81)

<?= DetailView::widget([
    'model' => $model,
    'attributes' => [
        'id',
        'time',
        'location',
        array(
            'label' => '照片',
            'value' =>'uploads/'.$model->photo,
            'format' => 'image',
        ),
        'car_id',
        'admin_user',
        'status',
        'memo',
    ],
]) ?>

请问如何设定图片宽度?

源码里有范例

弹出框代码谁有啊?[2.0]

CGlovely阅读(93)

哪位大神给段弹出框或者弹出层代码啊?我现在需要把修改做成弹出层格式的,哪位大神能帮帮忙啊?

就像这种 很容易自己写出来了 样式的话 只要你项目引入了bootstrap.js就可以了
你应该先去百度或则google
看这个: http://layer.layui.com/
bootstrap的model 可以自己定义样式 很多的 调用也很方便 因为yii本来就支持bootstrap

上传大文件的问题[2.0]

youthsea阅读(86)

我上传文件的时候做测试,2.3M的文件会给我我想要的提示,然后上传25M的文件的时候既没有提示,做输出查看的时候也没有反应,直接跳转到上传前的状态,修改PHP.ini也没有效果。求大神指点一下

确定设置了post_max_size 和 upload_max_filesize 这两个参数吗?

round奇怪的问题,保留小数无效了。[2.0]

Kimbubble阅读(89)

一组计算数字,只有1-2个会出现这种问题,我本地PHP5.5是没问题的,线上是PHP5.4。
1.png
2.png
还是有那么多位小数

2.jpg

1.jpg

剛剛上PHP官網看了看
從 5.2.7 以後都支援 precision 這方式 (應該不適版本問題)
或者是線上某些設定導致的, 我PHP5.4 是可執行
有可能是 php.ini setting precision = 14;(這邊可能被更動了)
在你的code下
目前只知道有這種辦法可以設定 (可以上網爬一下類似的 php.ini percision 怎麼設定)

登录

找回密码

注册