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


Groups > comp.lang.php > #7161

Re: Multiple <a> Tags, Filled With MySQL DB data with PHP

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.php
Subject Re: Multiple <a> Tags, Filled With MySQL DB data with PHP
Date 2012-09-25 18:41 +0000
Organization A noiseless patient Spider
Message-ID <k3stt1$5ba$1@dont-email.me> (permalink)
References <e9cd6d56-2c2a-422b-af7c-f6abb198d441@googlegroups.com>

Show all headers | View raw


On Tue, 25 Sep 2012 10:43:45 -0700, tom.rankin51 wrote:

> I am trying to create two image galleries using fancybox.  There is no
> issue doing this by manually typing out a bunch of <a> tags with the
> info inside, but when I attempt to code a piece of PHP to pull this data
> from my database, it doesn't like it and displays the images strangely.

Basic troubleshooting for php / mysql / html stuff:

1) Turn all the warnings on in php
2) Make sure that every database call tests for errors, and that they get 
reported
2a) In extreme cases, output the actual sql query and var_dump the result:

I do something like this at the top of my code in such situations:

<?php

$debugtxt = "";
$debugging = false;
if ( $_SERVER['REMOTE_ADDR'] == $my_ip && $_GET['debug'] == "37" ) 
$debugging = true;

?>

and wrap something like this round every sql call:

<?php

$sql = ".......";

$result = mysqli->query( $sql );

$debugtxt .= "sql call to get date of last login from users table\n";
$debugtxt .= "sql: {$sql}\n";
$debugtxt .= "Result:" . var_dump( $result );

if ( $result === false ) {
..... do onething
}
else {
..... do otherthing
}

?>

When you generate the html, before the closing </body> tag:

<?php if ( $debugging ) echo "<hr><h1>Debugging</h1><pre>$debugtxt</pre>
\n"; ?>

3) check the server error logs after each request
4) view the html source of the pages you get so you can see the actual 
html that your page is generating
5) When posting to the group, pare your code down to the minimum that 
demonstrates the problem.

You will hopefully then be able to determine where your code is going 
wrong and why.

In this particular case, I would suggest (4) is particularly important, 
you have told us what you expect, and what code you use to generate it, 
but have not shown us what the generated html looks like when examined 
with the source viewer in your browser.

If no html is generated, go back to the server logs looking for a php 
reported error. If your sql query is failing, your sql result set is 
actually the value false, and you're failing to detect this. There may be 
an sql error message in your server logs.

Rgds

Denis McMahon

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


Thread

Multiple <a> Tags, Filled With MySQL DB data with PHP tom.rankin51@googlemail.com - 2012-09-25 10:43 -0700
  Re: Multiple <a> Tags, Filled With MySQL DB data with PHP Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-25 14:21 -0400
    Re: Multiple <a> Tags, Filled With MySQL DB data with PHP tom.rankin51@googlemail.com - 2012-09-25 11:26 -0700
      Re: Multiple <a> Tags, Filled With MySQL DB data with PHP Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-25 16:02 -0400
  Re: Multiple <a> Tags, Filled With MySQL DB data with PHP Denis McMahon <denismfmcmahon@gmail.com> - 2012-09-25 18:41 +0000
    Re: Multiple <a> Tags, Filled With MySQL DB data with PHP tom.rankin51@googlemail.com - 2012-09-25 12:16 -0700
    Re: Multiple <a> Tags, Filled With MySQL DB data with PHP tom.rankin51@googlemail.com - 2012-09-25 12:58 -0700
      Re: Multiple <a> Tags, Filled With MySQL DB data with PHP Luuk <luuk@invalid.lan> - 2012-09-25 22:12 +0200
        Re: Multiple <a> Tags, Filled With MySQL DB data with PHP tom.rankin51@googlemail.com - 2012-09-25 13:38 -0700
          Re: Multiple <a> Tags, Filled With MySQL DB data with PHP tom.rankin51@googlemail.com - 2012-09-25 13:53 -0700
        Re: Multiple <a> Tags, Filled With MySQL DB data with PHP Denis McMahon <denismfmcmahon@gmail.com> - 2012-09-25 23:19 +0000
          Re: Multiple <a> Tags, Filled With MySQL DB data with PHP Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-25 19:48 -0400
            Re: Multiple <a> Tags, Filled With MySQL DB data with PHP Denis McMahon <denismfmcmahon@gmail.com> - 2012-09-26 14:25 +0000
  Re: Multiple <a> Tags, Filled With MySQL DB data with PHP tom.rankin51@googlemail.com - 2012-09-25 12:10 -0700
  Re: Multiple <a> Tags, Filled With MySQL DB data with PHP Christoph Becker <cmbecker69@gmx.de> - 2012-09-26 00:27 +0200
    Re: Multiple <a> Tags, Filled With MySQL DB data with PHP Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-25 19:18 -0400
      Re: Multiple <a> Tags, Filled With MySQL DB data with PHP Christoph Becker <cmbecker69@gmx.de> - 2012-09-26 02:04 +0200
        Re: Multiple <a> Tags, Filled With MySQL DB data with PHP Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-25 21:45 -0400
          Re: Multiple <a> Tags, Filled With MySQL DB data with PHP tom.rankin51@googlemail.com - 2012-09-25 23:16 -0700
            Re: Multiple <a> Tags, Filled With MySQL DB data with PHP tom.rankin51@googlemail.com - 2012-09-26 01:39 -0700
              Re: Multiple <a> Tags, Filled With MySQL DB data with PHP Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-26 07:48 -0400
              Re: Multiple <a> Tags, Filled With MySQL DB data with PHP Christoph Becker <cmbecker69@gmx.de> - 2012-09-26 14:12 +0200
            Re: Multiple <a> Tags, Filled With MySQL DB data with PHP Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-26 06:53 -0400
          Re: Multiple <a> Tags, Filled With MySQL DB data with PHP Captain Paralytic <paul_lautman@yahoo.com> - 2012-09-26 05:16 -0700
  Re: Multiple <a> Tags, Filled With MySQL DB data with PHP tom.rankin51@googlemail.com - 2012-09-26 13:35 -0700

csiph-web