FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » isset not working with select
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
isset not working with select [message #181342] Mon, 13 May 2013 07:01 Go to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
http://mroldies.net/showtable.php?year=1960



$result = mysql_query("SELECT acover,bcover FROM A$year WHERE id =
$number");
if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }
$cov = mysql_fetch_row($result);


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

On item #1 in the table, the panel appears with the desired images as
wanted.
On item #2 image place holders appear because I do not have them online
yet.
I do not want to see the place holders if there is not an image.
What to use to do that?

Also, if you click on 1961, or any other year, and then any item in the
table, you will get a message below the videos stating the column does not
exist so it can't continue processing.
How can I bypass this when that database does not have that column?
Re: isset not working with select [message #181345 is a reply to message #181342] Mon, 13 May 2013 08:49 Go to previous messageGo to next message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
On 5/13/2013 4:01 AM, richard wrote:
> http://mroldies.net/showtable.php?year=1960
>
>
>
> $result = mysql_query("SELECT acover,bcover FROM A$year WHERE id =
> $number");
> if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }
> $cov = mysql_fetch_row($result);
>
>
> if (isset($cov[0]))
> {echo "<img src='http://mroldies.net/covers/$year/".$cov[0]."'>";}
> echo "<img src='http://mroldies.net/covers/$year/".$cov[1]."'>";
>
> On item #1 in the table, the panel appears with the desired images as
> wanted.
> On item #2 image place holders appear because I do not have them online
> yet.
> I do not want to see the place holders if there is not an image.
> What to use to do that?
>
> Also, if you click on 1961, or any other year, and then any item in the
> table, you will get a message below the videos stating the column does not
> exist so it can't continue processing.
> How can I bypass this when that database does not have that column?
>

First off you should stop using the mysql extensions and start using a
PDO or MySQLi. (read up on the extensions to find out why, specifically
mysql_fetch_row)

2. Is your query indeed returning cov[1]. Have you done any debugging
techniques to determine the variables contents.

C. Your display logic is not very sound. The second row will ALWAYS try
to display regardless of cov[0] and whether or not cov[1] is set.

In fact you must have error 'notices' suppressed or you would of gotten
an undefined index for the second row cov[1] and may have given you an
idea why it is not working. When developing have all your errors tuned
on. I won't repeat how since it has been explained many times prior.

Here is some homework.

* Begin updating your code to use mysqli or your pdo.
* Learn some debugging techniques such as var_export, print_f, echo....
* Turn ALL your errors on

The first one will prevent your scripts from shutting down once the
mysql extensions are turned off on future PHP releases.

The last 2 will go a long way in you finding many issues that you will
have in the future on your own.

Good luck.
Re: isset not working with select [message #181346 is a reply to message #181342] Mon, 13 May 2013 08:43 Go to previous messageGo to next message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
On Mon, 13 May 2013 07:01:46 -0400, richard wrote:
> http://mroldies.net/showtable.php?year=1960
>
>
>
> $result = mysql_query("SELECT acover,bcover FROM A$year WHERE id =
> $number");
> if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }
> $cov = mysql_fetch_row($result);
>
>
> if (isset($cov[0]))
> {echo "<img src='http://mroldies.net/covers/$year/".$cov[0]."'>";}
> echo "<img src='http://mroldies.net/covers/$year/".$cov[1]."'>";
>
> On item #1 in the table, the panel appears with the desired images as
> wanted.
> On item #2 image place holders appear because I do not have them online
> yet.
> I do not want to see the place holders if there is not an image.
> What to use to do that?

If the first one works and the second one doesn't, maybe you should just
do them both like the first one?

> Also, if you click on 1961, or any other year, and then any item in the
> table, you will get a message below the videos stating the column does not
> exist so it can't continue processing.
> How can I bypass this when that database does not have that column?

Again, check for zero rows being returned in your program and build code
to handle that circumstance. die() is NOT your friend.

--
I wish there was a knob on the TV to turn up the intelligence. There's a
knob called "brightness", but it doesn't work.
-- Gallagher
Re: isset not working with select [message #181361 is a reply to message #181342] Mon, 13 May 2013 14:10 Go to previous messageGo to next message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
On 13/05/13 13:01, richard wrote:
> http://mroldies.net/showtable.php?year=1960
>
>
>
> $result = mysql_query("SELECT acover,bcover FROM A$year WHERE id =
> $number");
> if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }
> $cov = mysql_fetch_row($result);
>
>
> if (isset($cov[0]))
> {echo "<img src='http://mroldies.net/covers/$year/".$cov[0]."'>";}
> echo "<img src='http://mroldies.net/covers/$year/".$cov[1]."'>";
>
> On item #1 in the table, the panel appears with the desired images as
> wanted.
> On item #2 image place holders appear because I do not have them online
> yet.
> I do not want to see the place holders if there is not an image.
> What to use to do that?

isset() will not work in this case, as both cells will always be set.
I recommend you try empty() which will give you indication if the cell
is empty or not.

$value_to_use = empty($cov[0])?$cov[1]:$cov[0];
echo "<img src='http://mroldies.net/covers/$year/".$value_to_use."'>";


IMHO it's not good to echo things, build up what you want to do and echo
out everything when you are finished, this way you get out only what you
want to show to the user, as you can remove parts completely if they fail.


> Also, if you click on 1961, or any other year, and then any item in the
> table, you will get a message below the videos stating the column does not
> exist so it can't continue processing.
> How can I bypass this when that database does not have that column?

Don't know what you mean, didn't see any such message, but I guess that
is a question to a javascript newsgroup.


--

//Aho
Re: isset not working with select [message #181363 is a reply to message #181342] Mon, 13 May 2013 15:54 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
On Mon, 13 May 2013 07:01:46 -0400, richard wrote:

> What to use to do that?

Programming skills and logic.

Perhaps you could check that the returned elements contain some viable
data after checking if they're set, and if they don't contain such
expected viable data, then you could output something else?

Given:

$cov = mysql_fetch_row($result);

Then:

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

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

} else {

// here you have an alternative output

}

Now please note carefully:

The order of multiple tests in an if statement as shown above can be
critical to prevent errors. Don't change it around!

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
Re: isset not working with select [message #181373 is a reply to message #181346] Mon, 13 May 2013 18:31 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
On 13/05/13 13:43, Peter H. Coffin wrote:
> On Mon, 13 May 2013 07:01:46 -0400, richard wrote:
>> http://mroldies.net/showtable.php?year=1960
>>
>>
>>
>> $result = mysql_query("SELECT acover,bcover FROM A$year WHERE id =
>> $number");
>> if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }
>> $cov = mysql_fetch_row($result);
>>
>>
>> if (isset($cov[0]))
>> {echo "<img src='http://mroldies.net/covers/$year/".$cov[0]."'>";}
>> echo "<img src='http://mroldies.net/covers/$year/".$cov[1]."'>";
>>
>> On item #1 in the table, the panel appears with the desired images as
>> wanted.
>> On item #2 image place holders appear because I do not have them online
>> yet.
>> I do not want to see the place holders if there is not an image.
>> What to use to do that?
> If the first one works and the second one doesn't, maybe you should just
> do them both like the first one?
>
>> Also, if you click on 1961, or any other year, and then any item in the
>> table, you will get a message below the videos stating the column does not
>> exist so it can't continue processing.
>> How can I bypass this when that database does not have that column?
> Again, check for zero rows being returned in your program and build code
> to handle that circumstance. die() is NOT your friend.
>
if (mysql_numrows($result)) // there is some date to process

....

else

// there isn't.
....

--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Re: isset not working with select [message #181374 is a reply to message #181361] Mon, 13 May 2013 18:43 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
On 13/05/13 19:10, J.O. Aho wrote:
> On 13/05/13 13:01, richard wrote:
>> http://mroldies.net/showtable.php?year=1960
>>
>>
>>
>> $result = mysql_query("SELECT acover,bcover FROM A$year WHERE id =
>> $number");
>> if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }
>> $cov = mysql_fetch_row($result);
>>
>>
>> if (isset($cov[0]))
>> {echo "<img src='http://mroldies.net/covers/$year/".$cov[0]."'>";}
>> echo "<img src='http://mroldies.net/covers/$year/".$cov[1]."'>";
>>
>> On item #1 in the table, the panel appears with the desired images as
>> wanted.
>> On item #2 image place holders appear because I do not have them online
>> yet.
>> I do not want to see the place holders if there is not an image.
>> What to use to do that?
>
> isset() will not work in this case, as both cells will always be set.
> I recommend you try empty() which will give you indication if the cell
> is empty or not.
>
another trick I have used is to assign another variable at the mysql
level so you can have a query that sets a flag..
select...if(isnull(bcover) 0,1) as bcoverflag...

I use that so see whether the database actually contains an image at
all. So if bcoverflag is false, then I don't even attempt to display a
non existent image

i.e. (cut from code that works)

$query=sprintf("select name, details, type, hour(time) as hour,
minute(time) as minute, year(date) as year, monthname(date) as month,
day(date) as day, if(isnull(picture1),0,1) as pic1flag,
if(isnull(picture2),0,1) as pic2flag,if(isnull(picture3),0,1) as
pic3flag from %s where id='%d'",$table,$id);
$result=mysql_query($query);
if(!$result || (mysql_numrows($result)==0)) // bad query or
nonexistent data
{
echo("</div>\n");
return; //nothing to see here. Move along now please.
}
....

if(mysql_result($result,0,'pic1flag')) // have a picture 1
{
$url=sprintf('<IMG
src=" ../send_eventpik.php?id=%d&picture=picture1&height=200&width=10 0&ie6fool=%d "
alt="picture1" style="float:left; margin-right: 30px; margin-bottom:
30px;">',$id,rand(5,25));
}
(send_eventpik.php is a php script that sends a picture when called as a
URL.

> $value_to_use = empty($cov[0])?$cov[1]:$cov[0];
> echo "<img src='http://mroldies.net/covers/$year/".$value_to_use."'>";
>
>
> IMHO it's not good to echo things, build up what you want to do and
> echo out everything when you are finished, this way you get out only
> what you want to show to the user, as you can remove parts completely
> if they fail.
>
+1
>
>> Also, if you click on 1961, or any other year, and then any item in the
>> table, you will get a message below the videos stating the column
>> does not
>> exist so it can't continue processing.
>> How can I bypass this when that database does not have that column?
>
> Don't know what you mean, didn't see any such message, but I guess
> that is a question to a javascript newsgroup.
>
>
see the use of mysql_numrows() to not process nonexistent data.



--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Re: isset not working with select [message #181384 is a reply to message #181363] Tue, 14 May 2013 17:38 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
On Mon, 13 May 2013 19:54:53 +0000 (UTC), Denis McMahon wrote:

> On Mon, 13 May 2013 07:01:46 -0400, richard wrote:
>
>> What to use to do that?
>
> Programming skills and logic.
>
> Perhaps you could check that the returned elements contain some viable
> data after checking if they're set, and if they don't contain such
> expected viable data, then you could output something else?
>
> Given:
>
> $cov = mysql_fetch_row($result);
>
> Then:
>
> if ( isset( $cov[0], $cov[1] ) && is_string( $cov[0] ) && is_string( $cov
> [1] ) && strlen( $cov[0] ) > 4 && strlen( $cov[1] ) > 4 ) {
>
> // here you use $cov[0] and $cov[1] in the output
>
> } else {
>
> // here you have an alternative output
>
> }
>
> Now please note carefully:
>
> The order of multiple tests in an if statement as shown above can be
> critical to prevent errors. Don't change it around!

Thanks I'll give that one a try.
Re: isset not working with select [message #181418 is a reply to message #181363] Wed, 15 May 2013 16:23 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
On Mon, 13 May 2013 19:54:53 +0000 (UTC), Denis McMahon wrote:

> On Mon, 13 May 2013 07:01:46 -0400, richard wrote:
>
>> What to use to do that?
>
> Programming skills and logic.
>
> Perhaps you could check that the returned elements contain some viable
> data after checking if they're set, and if they don't contain such
> expected viable data, then you could output something else?
>
> Given:
>
> $cov = mysql_fetch_row($result);
>
> Then:
>
> if ( isset( $cov[0], $cov[1] ) && is_string( $cov[0] ) && is_string( $cov
> [1] ) && strlen( $cov[0] ) > 4 && strlen( $cov[1] ) > 4 ) {
>
> // here you use $cov[0] and $cov[1] in the output
>
> } else {
>
> // here you have an alternative output
>
> }
>
> Now please note carefully:
>
> The order of multiple tests in an if statement as shown above can be
> critical to prevent errors. Don't change it around!

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 want to check both images seperately as I may have one set, but not both.
Re: isset not working with select [message #181419 is a reply to message #181418] Wed, 15 May 2013 16:34 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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 seperately as I may have one set, but not
> both.

Not unreasonable

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
Re: isset not working with select [message #181421 is a reply to message #181419] Wed, 15 May 2013 17:07 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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 seperately as I may have one set, but not
>> both.
>
> Not unreasonable

Thanks. I just couldn't see it for nuthin.
Re: isset not working with select [message #181422 is a reply to message #181418] Wed, 15 May 2013 17:15 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
In article <195lftw1ts4is(dot)1wz8p6f1a44my$(dot)dlg(at)40tude(dot)net>,
richard <noreply(at)example(dot)com> wrote:

> On Mon, 13 May 2013 19:54:53 +0000 (UTC), Denis McMahon wrote:
>
>> On Mon, 13 May 2013 07:01:46 -0400, richard wrote:
>>
>>> What to use to do that?
>>
>> Programming skills and logic.
>>
>> Perhaps you could check that the returned elements contain some viable
>> data after checking if they're set, and if they don't contain such
>> expected viable data, then you could output something else?
>>
>> Given:
>>
>> $cov = mysql_fetch_row($result);
>>
>> Then:
>>
>> if ( isset( $cov[0], $cov[1] ) && is_string( $cov[0] ) && is_string( $cov
>> [1] ) && strlen( $cov[0] ) > 4 && strlen( $cov[1] ) > 4 ) {
>>
>> // here you use $cov[0] and $cov[1] in the output
>>
>> } else {
>>
>> // here you have an alternative output
>>
>> }
>>
>> Now please note carefully:
>>
>> The order of multiple tests in an if statement as shown above can be
>> critical to prevent errors. Don't change it around!
>
> if (isset($cov[0]) && is_string($cov[0]) && strlen(cov[0])>4)
~~~~~~~~
Missing $ sign.

> { echo "<img src='http://mroldies.net/covers/$year/".$cov[0]."'>"; }
>
> Returns a parse error of unexpected '['.
> where did I screw up at?
>
> I want to check both images seperately as I may have one set, but not both.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: isset not working with select [message #181423 is a reply to message #181419] Wed, 15 May 2013 17:12 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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 seperately as I may have one set, but not
>> both.
>
> Not unreasonable

Ok so the code still shows the place holders for both.
Re: isset not working with select [message #181424 is a reply to message #181421] Wed, 15 May 2013 17:18 Go to previous messageGo to next message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma: 0
Member
add to buddy list
ignore all messages by this user
richard wrote:
> Thanks. I just couldn't see it for nuthin.

You may consider using an editor with (better) syntax highlighting; that
should help spotting such typos more easily.

--
Christoph M. Becker
Re: isset not working with select [message #181428 is a reply to message #181424] Wed, 15 May 2013 19:07 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
On Wed, 15 May 2013 23:18:04 +0200, Christoph Becker wrote:

> richard wrote:
>> Thanks. I just couldn't see it for nuthin.
>
> You may consider using an editor with (better) syntax highlighting; that
> should help spotting such typos more easily.

I use notepad++ for that reason.
What editor would know that YOU wanted $cov and not just cov?
Syntax Highlighting (was: isset not working with select) [message #181430 is a reply to message #181428] Wed, 15 May 2013 19:33 Go to previous messageGo to next message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma: 0
Member
add to buddy list
ignore all messages by this user
richard wrote:
> On Wed, 15 May 2013 23:18:04 +0200, Christoph Becker wrote:
>
>> richard wrote:
>>> Thanks. I just couldn't see it for nuthin.
>>
>> You may consider using an editor with (better) syntax highlighting; that
>> should help spotting such typos more easily.
>
> I use notepad++ for that reason.
> What editor would know that YOU wanted $cov and not just cov?

I am using Active State's Komodo Edit, and there "$cov" is highlighted
differently than "cov" (black vs. cyan in the default configuration). I
assume there are other editors/IDEs around that offer this also (it
shouldn't be hard for the lexer to distinguish between the two cases);
maybe Notepad++ can be configured this way too.

--
Christoph M. Becker
Re: isset not working with select [message #181431 is a reply to message #181423] Wed, 15 May 2013 19:54 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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(at)gmail(dot)com
Re: isset not working with select [message #181437 is a reply to message #181428] Thu, 16 May 2013 03:27 Go to previous message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
In article <v4hd79nxpfj8$(dot)70pezduov2p(dot)dlg(at)40tude(dot)net>,
richard <noreply(at)example(dot)com> wrote:

> On Wed, 15 May 2013 23:18:04 +0200, Christoph Becker wrote:
>
>> richard wrote:
>>> Thanks. I just couldn't see it for nuthin.
>>
>> You may consider using an editor with (better) syntax highlighting; that
>> should help spotting such typos more easily.
>
> I use notepad++ for that reason.
> What editor would know that YOU wanted $cov and not just cov?

Obviously the editor isn't gonna *know* that, just it will be more
obvious when you do an eyeball scan, that you have $cov in purple (say),
then again in purple, but over here where the third $cov should be it's
in black, so that stands out.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: mkdir no such file or directory
Next Topic: makes searching and booking applications airfares
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Dec 13 10:11:27 EST 2017

Total time taken to generate the page: 0.00922 seconds