<legend id='ilNZk'><style id='ilNZk'><dir id='ilNZk'><q id='ilNZk'></q></dir></style></legend>
  • <tfoot id='ilNZk'></tfoot>
      <bdo id='ilNZk'></bdo><ul id='ilNZk'></ul>

      <small id='ilNZk'></small><noframes id='ilNZk'>

      <i id='ilNZk'><tr id='ilNZk'><dt id='ilNZk'><q id='ilNZk'><span id='ilNZk'><b id='ilNZk'><form id='ilNZk'><ins id='ilNZk'></ins><ul id='ilNZk'></ul><sub id='ilNZk'></sub></form><legend id='ilNZk'></legend><bdo id='ilNZk'><pre id='ilNZk'><center id='ilNZk'></center></pre></bdo></b><th id='ilNZk'></th></span></q></dt></tr></i><div id='ilNZk'><tfoot id='ilNZk'></tfoot><dl id='ilNZk'><fieldset id='ilNZk'></fieldset></dl></div>

        “非法抵销"循环内

        时间:2023-09-20

        <i id='UqSmJ'><tr id='UqSmJ'><dt id='UqSmJ'><q id='UqSmJ'><span id='UqSmJ'><b id='UqSmJ'><form id='UqSmJ'><ins id='UqSmJ'></ins><ul id='UqSmJ'></ul><sub id='UqSmJ'></sub></form><legend id='UqSmJ'></legend><bdo id='UqSmJ'><pre id='UqSmJ'><center id='UqSmJ'></center></pre></bdo></b><th id='UqSmJ'></th></span></q></dt></tr></i><div id='UqSmJ'><tfoot id='UqSmJ'></tfoot><dl id='UqSmJ'><fieldset id='UqSmJ'></fieldset></dl></div>
          <legend id='UqSmJ'><style id='UqSmJ'><dir id='UqSmJ'><q id='UqSmJ'></q></dir></style></legend>

              <bdo id='UqSmJ'></bdo><ul id='UqSmJ'></ul>
            • <tfoot id='UqSmJ'></tfoot>
                  <tbody id='UqSmJ'></tbody>

                  <small id='UqSmJ'></small><noframes id='UqSmJ'>

                  本文介绍了“非法抵销"循环内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  以下代码在每次 while() 循环时都会产生非法偏移错误:

                  The following code produces an illegal offset error every time the while() loops:

                  警告:第 48 行/Applications/MAMP/htdocs/admin/scripts/email_owners_send.php 中的非法字符串偏移用户名"

                  Warning: Illegal string offset 'username' in /Applications/MAMP/htdocs/admin/scripts/email_owners_send.php on line 48

                  我正在尝试将 $name 设置为 $email['username'] 如果 $email['username'] 不为空,如果为空,$name应该设置为$email.$emailwhile() 语句设置,来自 mysql_fetch_assoc().这是我目前的代码:

                  I'm trying to set $name to be $email['username'] if $email['username'] isn't empty, and if is empty, $name should be set to $email. $email is set by the while() statement, from a mysql_fetch_assoc(). This is my code at the moment:

                  // print out all the email address recipients
                  $query = mysql_query("SELECT * FROM ownersemails WHERE deleted=0 LIMIT 5");
                  $recipients = '';
                  $total = mysql_num_rows($query);
                  $num = 0;
                  while($email = mysql_fetch_assoc($query)) {
                      // add to count
                      $num++;
                  
                      // set email
                      $email = $email['email'];
                  
                      // set name as username if apparant
                      if(!empty($email['username'])) {
                          $name = $email;
                      }
                      else {
                          $name = $email['username'];
                      }
                  
                      // add to recipients string (=. append)
                      $recipients .= '{ "email": "'.$email.'", "name": "'.$name.'" }';
                      // only add a comma if it isn't the last one
                      if($num!=$total) {
                          $recipients .=',';
                      }
                  }
                  

                  推荐答案

                  您正在覆盖由 while 循环设置的 $email 变量

                  You are overwriting the $email variable set by the while loop

                   while($email = mysql_fetch_assoc($query)) {
                  

                  然后你就覆盖了它:

                  $email = $email['email'];
                  

                  so $email 将成为字符串而不是数组.你可以把它改成

                  so $email will become a string and not an array. You could change this to

                  $email_address = $email['email']
                  

                  这篇关于“非法抵销"循环内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 while 循环中填充数组并在每次迭代中获得 下一篇:PHP数组转换成Javascript数组

                  相关文章

                  最新文章

                • <small id='Iog1b'></small><noframes id='Iog1b'>

                • <i id='Iog1b'><tr id='Iog1b'><dt id='Iog1b'><q id='Iog1b'><span id='Iog1b'><b id='Iog1b'><form id='Iog1b'><ins id='Iog1b'></ins><ul id='Iog1b'></ul><sub id='Iog1b'></sub></form><legend id='Iog1b'></legend><bdo id='Iog1b'><pre id='Iog1b'><center id='Iog1b'></center></pre></bdo></b><th id='Iog1b'></th></span></q></dt></tr></i><div id='Iog1b'><tfoot id='Iog1b'></tfoot><dl id='Iog1b'><fieldset id='Iog1b'></fieldset></dl></div>
                  <legend id='Iog1b'><style id='Iog1b'><dir id='Iog1b'><q id='Iog1b'></q></dir></style></legend>
                    <bdo id='Iog1b'></bdo><ul id='Iog1b'></ul>
                      <tfoot id='Iog1b'></tfoot>