嘿编码器和代码,
我想知道您是否可以帮助我,我在尝试执行代码时收到以下警告
警告: 警告:非法字符串偏移'呼号'在第106行的C:\ xampp \ htdocs \ fms \ _blog.php中 S
这是它所指的代码:
if($rows1['callsign']=='SN23'OR'SN24'OR'SN25'){
echo 'IRV';}
elseif ($rows1['callsign']=='SK20'OR'SK30'){
echo 'VAN';}
elseif ($rows1['callsign']=='SN21'OR'SN22'){
echo 'TASER';}
elseif ($rows1['callsign']=='C1'OR'C2'){
echo 'AREA';}
elseif ($row1['callsign']=='NPAS'){
echo 'NPAS';} ?>
<br></font>
</a>
</div>
<center>
<font color="white">
<a data-toggle="modal" href="#"
onclick="popup_viewunit('105')">
<font color="white">
<h4><b><i class="fa fa-<?php
if($rows1['callsign']=='SN23'OR'SN24'OR'SN25'){
echo 'circle';}
elseif ($rows1['callsign']=='SK20'OR'SK30'){
echo 'truck';}
elseif ($rows1['callsign']=='SN21'OR'SN22'){
echo 'bolt';}
elseif ($rows1['callsign']=='C1'OR'C2'){
echo 'map';}
elseif ($rows1['callsign']=='NPAS'){
ROW 106-- echo 'times fa-pulse';} ?>"></i><?php echo
$rows1['callsign']; ?></b></h4> -- END OF ROW 106
</font>
任何建议都会很棒
答案 0 :(得分:0)
试试这个:
if(isset($rows1['callsign'])){
echo 'working';
else {
echo 'Not working';
}
我的猜测是$rows1['callsign']
的值不是字符串。
答案 1 :(得分:0)
此($rows1['callsign']=='C1'OR'C2')
不符合您的想法。它评估该语句类似:
IF ($rows1['callsign'] EQUALS 'C1') OR ('C2' == TRUE) ...
你可能想要:
if($rows1['callsign'] == 'C1' OR $rows1['callsign'] == 'C2') {
此外,很可能没有定义$ rows1 ['callign'],执行print_r($rows1);
并且您可以看到它实际包含的内容。
答案 2 :(得分:0)
这里有多个问题:
1
$rows1['callsign']=='SK20'OR'SK30'
这不会像你期望的那样工作,你需要做
$rows1['callsign'] == 'SK20' || $rows1['callsign'] == 'SK30'
示例:
<?php
$a = 3;
echo (($a == 1 or 2) ? "yes" : "no"); // will output "yes" because "2" will be evaluated to true
echo (($a == 1 or $a == 2) ? "yes" : "no"); // correctly outputs "no"
在第一个区块中的一条线上,您有$ row1 ['callsign']而不是$ rows1 ['callsign']
错误消息通常表示$ rows1不是数组。使用var_dump()来查看实际内容以及它是如何实现的