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 :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: isset not working with select [message #181345 is a reply to message #181342] Mon, 13 May 2013 12:49 Go to previous messageGo to previous message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma:
Senior Member
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.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
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: Sun Dec 01 03:35:27 GMT 2024

Total time taken to generate the page: 0.04333 seconds