Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #18776

Re: Help With Warning Message

From Lew Pitcher <lew.pitcher@digitalfreehold.ca>
Newsgroups comp.lang.php
Subject Re: Help With Warning Message
Date 2021-08-23 18:19 +0000
Organization A noiseless patient Spider
Message-ID <sg0oqs$g6i$1@dont-email.me> (permalink)
References <7no5igtt055jqdalqa2u2vlkfeu6bvhnag@4ax.com> <sfuut5$lb8$1@dont-email.me> <8ia6ig94heh1gjujblafvn17or10ufdlik@4ax.com> <ioh040Fpg0kU1@mid.individual.net>

Show all headers | View raw


On Mon, 23 Aug 2021 09:13:04 +0200, J.O. Aho wrote:

> On 23/08/2021 07.03, Call Me Tom wrote:
>> 
>>    $da_name = $da['airport_name']; is line 104.  When I Access $da_name
>> in my table, it prints the airport name.  Can you tell what it thinks
>> is a boolean?
> 
> The $da is boolean for the row  before failed:
> 
> $da = $result4->FETCH(PDO::FETCH_ASSOC);
> 
> So you should check the $da value before using it
> 
> if($da) {
> 	$da = $result4->FETCH(PDO::FETCH_ASSOC);
> 	$da_name = $da['airport_name'];
> } else {
> 	// do what you need to tell it didn't find any thing
> }
 
ITYM
  $da = $result4->FETCH(PDO::FETCH_ASSOC);
  if ($da === FALSE)
  {
    /* fetch() failed for some reason. abort this activity */
  }
  else $da_name = $da['airport_name'];

And, to be complete, the OP should check the value in $result4
before invoking the fetch() method. So the logic fragment should
look more like
  $result4 = $dbh->query($query4);
  if ($result4 === FALSE)
  {
    /* query() failed for some reason - abort this activity */
  }
  else
  {
    $da = $result4->FETCH(PDO::FETCH_ASSOC);
    if ($da === FALSE)
    {
      /* fetch() failed for some reason - abort this activity */
    }
    else $da_name = $da['airport_name'];
  }


> also worth mentioning, the variable $origin needs to be sanitized, as 
> it's a prone for SQL-injection. I do suggest you use withe list method, 
> where you check that the string has only allowed characters.




-- 
Lew Pitcher
"In Skills, We Trust"

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Help With Warning Message Call Me Tom <noemail@noemail.com> - 2021-08-22 20:00 -0400
  Re: Help With Warning Message Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2021-08-23 01:50 +0000
    Re: Help With Warning Message Call Me Tom <noemail@noemail.com> - 2021-08-23 01:03 -0400
      Re: Help With Warning Message "J.O. Aho" <user@example.net> - 2021-08-23 09:13 +0200
        Re: Help With Warning Message Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2021-08-23 18:19 +0000
          Re: Help With Warning Message Call Me Tom <noemail@noemail.com> - 2021-08-23 15:26 -0400
          Re: Help With Warning Message "J.O. Aho" <user@example.net> - 2021-08-24 00:33 +0200
      Re: Help With Warning Message Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2021-08-23 11:47 +0000
  Re: Help With Warning Message Arno Welzel <usenet@arnowelzel.de> - 2021-08-30 10:21 +0200

csiph-web