精华内容
下载资源
问答
  • 如何更正此非法字符串偏移
    2021-04-28 07:35:42

    gabearnold

    26

    php

    wordpress

    我在第32行的/home/mysite/public_html/wp-content/themes/evento/lib/php/extra.class.php中收到此错误"警告:非法字符串偏移'类型'

    并且我意识到文件中的这段代码是错误的,但是我在PHP中并不是那么好,我想知道是否有人可以帮我重新编写这一部分以消除错误.谢谢!(错误从第32行开始,这是下面if语句的开头)

    这是代码:

    /* new version */

    function get_attachment_struct( $inputs ){

    $attach = array();

    if( $inputs['type'] == 'attach' ){

    $name = $inputs['name'];

    $attach = array(

    0 => array(

    'name' => $name,

    'type' => 'text',

    'label' => 'Attachment URL',

    'lvisible' => false,

    'upload' => true,

    ),

    1 => array(

    'name' => $name .'_id',

    'type' => 'hidden',

    'upload' => true

    ),

    );

    if( isset( $inputs[ 'classes' ] ) ){

    $attach[0]['classes'] = $inputs[ 'classes' ];

    $attach[1]['classes'] = $inputs[ 'classes' ] . '_id';

    }

    }

    return $attach;

    }

    /* new version */

    更多相关内容
  • 您一直在尝试从我的数据库中检索记录,但我在几个字段中不断收到此错误“严重性:警告消息:非法字符串偏移”.这是我的控制器view_logs.phpclass View_Logs extends CI_Controller {function View_Logs(){parent::__...

    您一直在尝试从我的数据库中检索记录,但我在几个字段中不断收到此错误“严重性:警告消息:非法字符串偏移”.

    这是我的控制器view_logs.php

    class View_Logs extends CI_Controller {

    function View_Logs()

    {

    parent::__construct();

    }

    function Logs(){

    $id = $this->uri->segment(3);

    $this->load->model('log_listmodel');

    $this->log_listmodel->log_list_get($id);

    }

    }

    ?>

    这是我的模型log_listmodel.php

    class Log_Listmodel extends CI_Model{

    function Log_Listmodel()

    {

    parent::__construct();

    }

    function log_list_get($id){

    $query = $this->db->get_where('test_request_log', array('test_request_id' => $id));

    //return $query->result();

    $results=$query->result_array();

    $data['query']=$results[0];

    $this->load->view('logs_list_view',$data);

    }

    }

    ?>

    这是我的视图页面log_list_view.php

    Updated<?php echo $row['id'];?>.<?php echo $row['new_testing_reason'];?><?php echo $row['new_applicant_name'];?><?php echo $row['new_authorizer_name'];?><?php echo $row['new_received_by'];?><?php echo $row['new_test_required'];?><?php echo $row['new_laboratory_number'];?><?php echo $row['log_date'];?><?php echo $row['who'];?>

    解决方法:

    您已将$data [‘query’]设置为结果的第一行,但在视图中您正在使用它,因为它将拥有整个数据集.

    所以你需要改变

    $data['query']=$results[0];

    $data['query']=$results;

    要么

    $data['query']=$query->result_array();

    标签:php,codeigniter

    来源: https://codeday.me/bug/20190723/1508543.html

    展开全文
  • 蓝山帝景你试图访问一个string就好像它是一个数组,有一个键-string.string不会明白的。...//PHPWarning:Illegalstringoffset'hello'inphpshellcodeonline1"hello"[0];//Noerrors.array("hello"=&g...

    f379da4f4b7d4df217f854bad54c5438.png

    蓝山帝景

    你试图访问一个string就好像它是一个数组,有一个键-string. string不会明白的。在代码中,我们可以看到问题所在:"hello"["hello"];// PHP Warning:  Illegal string offset 'hello' in php shell code on line 1"hello"[0];

    // No errors.array("hello" => "val")["hello"];// No errors. This is *probably* what you wanted.纵深让我们看看这个错误:警告:非法字符串偏移“端口”在.。上面写着什么?上面说我们要用字符串'port'作为字符串的偏移量。就像这样:$a_string = "string";// This is ok:echo $a_string[0]; // secho $a_string[1]; // techo $a_string[2]; // r// ...

    // !! Not good:echo $a_string['port'];// !! Warning: Illegal string offset 'port' in ...这是什么原因?因为某种原因你期望array,但你有一个string..只是搞混了。也许你的变量被改变了,也许它从来不是array,这真的不重要。我们能做些什么?如果我们知我们应该有一个array,我们应该做一些基本的调试,以确定为什么我们没有array..如果我们不知道我们会不会array或string事情变得更棘手了。我们能,会,可以做的是各种各样的检查,以确保我们没有通知,警告或错误的事情is_array和isset或array_key_exists:$a_string = "string";$an_array = array('port' => 'the_port');if (is_array($a_string) && isset($a_string['port'])) {

        // No problem, we'll never get here.

        echo $a_string['port'];}if (is_array($an_array) && isset($an_array['port'])) {

        // Ok!

        echo $an_array['port']; // the_port}if (is_array($an_array) && isset($an_array['unset_key'])) {

        // No problem again, we won't enter.

        echo $an_array['unset_key'];}// Similar, but with array_key_existsif (is_array($an_array) && array_key_exists('port', $an_array)) {

        // Ok!

        echo $an_array['port']; // the_port}有一些微妙的区别isset和array_key_exists..例如,如果$array['key']是null, isset回报false. array_key_exists会检查一下,好吧,钥匙存在.

    展开全文
  • 我已经将一个csv文件转换为数组,并使用一些键将数组数据分组。 我定义了一个groupBy函数来处理数组数据。 但是,我遇到了这个错误,不确定哪一部分出错了。代码:groupby函数public function group($key, $item) {$...

    我已经将一个csv文件转换为数组,并使用一些键将数组数据分组。 我定义了一个groupBy函数来处理数组数据。 但是,我遇到了这个错误,不确定哪一部分出错了。

    代码:groupby函数

    public function group($key, $item) {

    $result = array();

    foreach($item as $val) {

    $result[$val[$key]][] = $val;

    }

    return $result;

    }

    数据转换功能。

    public function saveNewSale()

    {

    foreach (array_chunk($items, $chunk_size) as $chunk) {

    $cleaned_items = [];

    foreach ($chunk as $item) {

    //Data Transformation

    //call groupby function

    $byGroup = $this->group('ref_num', $item);

    array_push($cleaned_items, $item);

    }

    这是我的数组

    array:2 [

    0 => array:13 [

    "ref_num" => "INV699"

    "payment_term" => array:2 [

    "id" => 1

    "name" => "Cash"

    ]

    "items" => array:1 [

    0 => array:8 [

    "code" => "3MVR0003"

    "description" => "3M Vinyl

    "tax_value" => 0.06

    "qty" => 1

    "unit" => 1

    "price" => 10

    "total" => 212

    "total_tax" => 12

    ]

    ]

    "terms" => array:1 [

    0 => array:2 [

    "date" => "2019-02-20"

    "amount" => 200

    ]

    ]

    ]

    1 => array:13 [

    "ref_num" => "INV699"

    "payment_term" => array:2 [

    "id" => 1

    "name" => "Cash"

    ]

    "items" => array:1 [

    0 => array:8 [

    "code" => "sony"

    "description" => "3xperia"

    "tax_value" => 0.06

    "qty" => 1

    "unit" => 1

    "price" => 10

    "total" => 212

    "total_tax" => 12

    ]

    ]

    "terms" => array:1 [

    0 => array:2 [

    "date" => "2019-02-20"

    "amount" => 200

    ]

    ]

    ]

    ]

    我需要基于ref_num将这两个数组ref_num 。

    展开全文
  • <p>Previously I tried translating the php pdo code to my php version, but I got a problem like this. <strong>"Warning: Illegal string offset 'tagName' in..."</strong>. Can someone help me, what should...
  • 参见英文答案 >Illegal string offset Warning PHP11个我今天升级到PHP 5.4,我收到一些奇怪的警告:Warning: Illegal string offset 'quote1' in file.php on line 110Warning: Illegal string offse...
  • <p><strong>models/users_model.php</strong> <pre><code>class Users_model extends CI_Model{ public function getUsers(){ return array( 'first' => 'Farhan Khan', 'second' => 'Abdul Wali', '...
  • <a href="/questions/9869150/illegal-string-offset-warning-php" dir="ltr">Illegal string offset Warning PHP</a> 14 answers ...
  • 现在, PHP版本, wordpress版本和插件都是最新的, 但是Portifolio项目现在返回此错误:屏幕截图:警告:第679行上的/home/elite856/public_html/wp-content/themes/eliteled/functions.php中的非法字符串偏移量” alt...
  • # HTML代码 ``` <!DOCTYPE html> 教师管理 姓名 {foreach $row as $v} <td> {$v.name} <td><a style="margin-right: 10px" href="{:url('Index/urlid')}?...```
  • Warning: Illegal string offset 'error' /ibEconomy/sources/shop_items/award_item.php on line 196. <p>if ( ! $returnMe['error'] ) <p>Here is the code, I'm not sure exactly what is going on. </p>...
  • <p>I tried to add some data using PHP, and I always get the following: <p>Illegal string offset <p>I don't know if the reason is that a foreign key cannot be null, or I am trying to insert a ...
  • <p>I have this code I don't know why I get error from it. <pre><code>if( ! in_array($repeatType, ['monthly', 'weekly', 'daily'])){ // do somehting } $monthly = ['two_years' =>...
  • 我收到这个错误“警告:非法字符串偏移”类型在/home/mysite/public_html/wp-content/themes/evento/lib/php/extra.class.php第32行“而且我意识到文件中的这段代码是错误的,但是我并没有那么好的PHP,而且我想知道...
  • <p>Warning: Illegal string offset in PHP</p> <p>THE ARRAY BEFORE THE FOREACH <pre><code>array (size=6) 'user_id' => string '1' (length=1) 'name' => string 'Vandenbergh' (length=11) '...
  • 我不斷收到一個致命錯誤時,腳本是我的PHP的服務器上運行,PHP致命錯誤不能使用字符串偏移量爲ARRAY這個Web應用程序十年前建成並我目前清除錯誤,這樣我們就可以開始更新它。當前版本PHP 5.2.17Fatal error: Cannot ...
  • <p>i'm trying to fetch data from mysql database using this code : <pre><code>$con = mysqli_connect('localhost', 'root', '', 'nicu'); mysqli_query($con, "set NAMES utf8"); $query = mysqli_query...
  • <p>Warning: Illegal string offset 'slimg' in /opt/lampp/htdocs/linom/index.php on line 82 <pre><code><?php $slider = "SELECT * FROM post ORDER BY id ASC LIMIT 4"; $slider1 = mysqli_query($...
  • php echo $images[$i]['sizes']['thumbnail']; ?>" alt="<?php echo $images[$i]['alt']?>" /> <?php } ?> <?php } else if (!is_array($images)) { $image = acf_get_attachment($images)...
  • <p>What is wrong here: <pre><code>$items = ''; $st = $db->query("select code from map where pos = 'home01' limit 1");...query("select fname from banners where fname = " ....img class='imgr imgr2' ...
  • <p>I'm trying to pull the ... '.php'); } } </code></pre> <p>But for some reason it doesn't work. I keep getting this <p>Illegal string offset 'slug' <p>error. How do I resolve this? </div>
  • <p><code>Fatal error: Only variables can be passed by reference in C:\*\update_status_test.php on line 130</code></p> <p>Line 130 refers to below, <pre><code>$stmt->bindParam(':uid', $uid['uid'],...
  • <p>I have the main array called $quizzes</code> which contains the collection of $Quiz</code>. ... /demo.php on line 14 $ <p>when I try to <code>echo $listoftests[0]['correct'];</code></p> </div>
  • <p>foreach($post_array as $val){ //组装数据入库,例如: </p><p> $title = $val['d1']; </p><p> $content= $val['t1']; </p><p> $addtime = $val['t2']; //ignore 忽略主键与唯一ID...
  • 非法字符串偏移php

    2014-01-24 19:27:09
    C:\xampp\htdocs\artists\artist.php on line 52 <p>A <p>Warning: Illegal string offset 'title' in C:\xampp\htdocs\artists\artist.php on line 53 <p>A Anatoly Zverev "Portrait of Vladimir ...
  • PHP Warning: Illegal string offset 'video_url' in /var/www/html/wp-content/themes/wpeddit-theme-et-child/template-parts/single.php on line 144 <p>This is the line of code it is referring to: <pre>...
  • <p>I have the following array called $shops</code>: <pre><code>Array ( [0] => Array ...<p>When I loop through it similar to the following I get <code>Illegal string offset 'day'</code></p> ...
  • /home/ocnjsurf/public_html/wp-content/themes/sheeva/core/functions-core.php on line 19 <p>This occurred after I upgraded to php 5.445 <p>The code they are referencing is: <pre><code>function ...
  • php foreach ($halaman as $dt) : ?> <div class="item"> <a href="/tkd/index.php/page/<?php echo $dt['slug'] ?>"><?php echo $dt['judul'] ?></a> //line error </div&...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 1,292
精华内容 516
关键字:

php非法字符串偏移