[Phpsig] Issue with web page display of MySQL values

bill phpsig@kalamazoolinux.org
Thu, 12 Sep 2002 15:21:31 -0400


forgot a trailing colon in the error check code (was changing it from something more
complex)  here it is as a function

function check_errors();

  if (mysql_errno() != 0) {
    echo "There was error # " . mysql_errno(). ": " . mysql_error();

    while (list($var,$value) = each ($GLOBALS)) {
        echo  "\n$var => $value";
    } // end while

    die;  // not necessary but no need to go further once an error occurs

    return false;  // we'll be dead before this but use this if you comment out the die
line.

  } // end if
  return true;

} // end function

Then do your query and check it

$show = mysql_query( $query );
check_errors();





bill wrote:

> Some questions:
>
> What is a "respective link?"  A URL? If so, which field(s) contain urls?
>
> Put some error checking in the program immediately after any query.
>
> //
>
>   if (mysql_errno() != 0) {
>     echo "There was error # " . mysql_errno(). ": " . mysql_error() .
>
>     while (list($var,$value) = each ($GLOBALS)) {
>         echo  "\n$var => $value";
>     }
>
>     die;  // not necessary but no need to go further once an error occurs
>
> //
>
> Simply the above by making it into a function and calling it after any query.
>
> Make a note of any query that fails.  If you can't find the error, try it from the
> command line and look at the result (if any).  If "Device Type and Site" are
> displaying the wrong thing then either the query is calling the wrong thing (which
> should be checked first) or the program is displaying the wrong results.
>
> If the query succeeds but displays unintended results, simply echo the query and look
> to see what you're asking for.
>
> It looks to me like you're calling and displaying siteid instead of site_name.
>
> hope this helps,
>
> bill hollett
>
> randall perry wrote:
>
> > I was helping a student with a project, and I am near the end of my
> > expertise on PHP and MySQL (the class was on neither).  I gave him some
> > code and helped him make the initial site, but now he is looking to improve
> > it, and I am not much help here.
> >
> > Take a look:
> > http://www.domain-logic.com/class/Davenport/cis241/view.php
> >
> > Device Type and Site should pull up their respective links in this view and
> > not their numbers.
> > Here is the database schema:
> >
> > mysql> show tables;
> > +---------------------+
> > | Tables_in_ipaddress |
> > +---------------------+
> > | device              |
> > | ipaddress           |
> > | site                |
> > +---------------------+
> >
> > mysql> describe device;
> > +----------+-------------+------+-----+---------+----------------+
> > | Field    | Type        | Null | Key | Default | Extra          |
> > +----------+-------------+------+-----+---------+----------------+
> > | devtype  | varchar(15) |      | UNI |         |                |
> > | typecode | smallint(6) |      | PRI | NULL    | auto_increment |
> > +----------+-------------+------+-----+---------+----------------+
> > 2 rows in set (0.00 sec)
> >
> > mysql> describe ipaddress;
> > +----------+-------------+------+-----+---------+-------+
> > | Field    | Type        | Null | Key | Default | Extra |
> > +----------+-------------+------+-----+---------+-------+
> > | ip_add   | varchar(15) |      | PRI | 0.0.0.0 |       |
> > | ufname   | varchar(30) | YES  |     | NULL    |       |
> > | ulname   | varchar(30) | YES  |     | NULL    |       |
> > | devname  | varchar(30) | YES  |     | NULL    |       |
> > | typecode | smallint(6) | YES  |     | NULL    |       |
> > | siteid   | smallint(6) | YES  |     | NULL    |       |
> > | appl     | varchar(35) | YES  |     | NULL    |       |
> > +----------+-------------+------+-----+---------+-------+
> > 7 rows in set (0.00 sec)
> >
> > mysql> describe site;
> > +-----------+-------------+------+-----+---------+----------------+
> > | Field     | Type        | Null | Key | Default | Extra          |
> > +-----------+-------------+------+-----+---------+----------------+
> > | site_name | varchar(40) |      | UNI |         |                |
> > | siteid    | smallint(6) |      | PRI | NULL    | auto_increment |
> > +-----------+-------------+------+-----+---------+----------------+
> > 2 rows in set (0.00 sec)
> >
> > I also made some links to the source code.  Hey Paul! Take a look and maybe
> > learn something (or maybe you are already past this?)
> > Randall Perry
> > www.fasnap.com
> > www.Davenport.edu
> >
> >   --------------------------------------------------------------------------------
> >
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.385 / Virus Database: 217 - Release Date: 9/4/2002
>
> _______________________________________________
> Phpsig mailing list
> Phpsig@kalamazoolinux.org
> http://www.kalamazoolinux.org/mailman/listinfo/phpsig