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


Groups > comp.lang.php > #9377

Re: isset not working with select

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.php
Subject Re: isset not working with select
Date 2013-05-15 23:54 +0000
Organization A noiseless patient Spider
Message-ID <kn178g$8so$7@dont-email.me> (permalink)
References <zjgov1oukrit$.nu30chb74ox5.dlg@40tude.net> <kmrged$mqd$3@dont-email.me> <195lftw1ts4is.1wz8p6f1a44my$.dlg@40tude.net> <kn0rgl$8so$6@dont-email.me> <1j6pljoakm4p9$.rlhgdvtgdltb$.dlg@40tude.net>

Show all headers | View raw


On Wed, 15 May 2013 17:12:36 -0400, richard wrote:

> On Wed, 15 May 2013 20:34:30 +0000 (UTC), Denis McMahon wrote:
> 
>> On Wed, 15 May 2013 16:23:35 -0400, richard wrote:
>> 
>>> if (isset($cov[0]) && is_string($cov[0]) && strlen(cov[0])>4)
>>>   { echo "<img src='http://mroldies.net/covers/$year/".$cov[0]."'>"; }
>>> 
>>> Returns a parse error of unexpected '['.
>>> where did I screw up at?
>> 
>> I wrote: strlen( $cov[0] ) > 4 You wrote: strlen(cov[0])>4
>> 
>> You missed a $ in the "strlen( $cov[0] ) > 4" test. That missing "$"
>> character is significant!
>> 
>>> I want to check both images separately as I may have one set, but not
>>> both.
>> 
>> Not unreasonable
> 
> Ok so the code still shows the place holders for both.

I'm not 100% sure on how you have implemented the code.

Let me expand on the previous example - this generates separate images 
for the two covers:

Given:

$cov = mysql_fetch_row($result);

Then:

if ( isset( $cov[0] ) && is_string( $cov[0] ) && strlen( $cov[0] ) > 4 ) {

// here you use $cov[0] in the output

echo "<img src='http://mroldies.net/covers/{$year}/{$cov[0]}'>";

/* --- in here --- */

} else {

// here you have an alternative output for $cov[0]

echo "Image 1 Not Available"

}

/* --- from here --- */
if ( isset( $cov[1] ) && is_string( $cov[1] ) && strlen( $cov[1] ) > 4 ) {

// here you use $cov[1] in the output

echo "<img src='http://mroldies.net/covers/{$year}/{$cov[1]}'>";

} else {

// here you have an alternative output $cov[1]

echo "Image 2 Not Available"

}
/* --- to here --- */

If however you only want the second image to display if the first image 
is also present, then all the lines from the comment "/* --- from here 
--- */" to the comment "/* --- to here --- */" should be moved up to the 
place held by the comment "/* --- in here --- */"

You might in that case want to change the text output "Image 1 Not 
Available" to "Images Not Available"

-- 
Denis McMahon, denismfmcmahon@gmail.com

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


Thread

isset not working with select richard <noreply@example.com> - 2013-05-13 07:01 -0400
  Re: isset not working with select Scott Johnson <noonehome@chalupasworld.com> - 2013-05-13 05:49 -0700
  Re: isset not working with select "Peter H. Coffin" <hellsop@ninehells.com> - 2013-05-13 07:43 -0500
    Re: isset not working with select The Natural Philosopher <tnp@invalid.invalid> - 2013-05-13 23:31 +0100
  Re: isset not working with select "J.O. Aho" <user@example.net> - 2013-05-13 20:10 +0200
    Re: isset not working with select The Natural Philosopher <tnp@invalid.invalid> - 2013-05-13 23:43 +0100
  Re: isset not working with select Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-13 19:54 +0000
    Re: isset not working with select richard <noreply@example.com> - 2013-05-14 17:38 -0400
    Re: isset not working with select richard <noreply@example.com> - 2013-05-15 16:23 -0400
      Re: isset not working with select Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-15 20:34 +0000
        Re: isset not working with select richard <noreply@example.com> - 2013-05-15 17:07 -0400
          Re: isset not working with select Christoph Becker <cmbecker69@gmx.de> - 2013-05-15 23:18 +0200
            Re: isset not working with select richard <noreply@example.com> - 2013-05-15 19:07 -0400
              Syntax Highlighting (was: isset not working with select) Christoph Becker <cmbecker69@gmx.de> - 2013-05-16 01:33 +0200
              Re: isset not working with select Tim Streater <timstreater@greenbee.net> - 2013-05-16 08:27 +0100
        Re: isset not working with select richard <noreply@example.com> - 2013-05-15 17:12 -0400
          Re: isset not working with select Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-15 23:54 +0000
      Re: isset not working with select Tim Streater <timstreater@greenbee.net> - 2013-05-15 22:15 +0100

csiph-web