Hey coders and codettes,
I am wondering if you could help me, I am getting the warning below when trying to execute code
WARNING: Warning: Illegal string offset 'callsign' in C:\xampp\htdocs\fms\blog.php on line 106 S
This is the Code it refers to:
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>
Any advice would be great
Try this:
if(isset($rows1['callsign'])){
echo 'working';
else {
echo 'Not working';
}
My guess would be the value of $rows1['callsign']
is not a string.
This ($rows1['callsign']=='C1'OR'C2')
does not do what you think it does. It evaluates that statement sort of like:
IF ($rows1['callsign'] EQUALS 'C1') OR ('C2' == TRUE) ...
You probably want:
if($rows1['callsign'] == 'C1' OR $rows1['callsign'] == 'C2') {
Also, more than likely that $rows1['callsign'] is not defined, do print_r($rows1);
and you can see what it actually contains.
Multiple problems here:
1.
$rows1['callsign']=='SK20'OR'SK30'
this will not work as you expect, you need to do
$rows1['callsign'] == 'SK20' || $rows1['callsign'] == 'SK30'
example:
<?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"
On one of the lines in the first block you have $row1['callsign'] instead of $rows1['callsign']
the error message generally means that $rows1 is not an array. Use var_dump() to see what is actually in it and how it got there