Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #7149 > unrolled thread
| Started by | tom.rankin51@googlemail.com |
|---|---|
| First post | 2012-09-25 10:43 -0700 |
| Last post | 2012-09-26 13:35 -0700 |
| Articles | 20 on this page of 25 — 6 participants |
Back to article view | Back to comp.lang.php
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
Page 1 of 2 [1] 2 Next page →
| From | tom.rankin51@googlemail.com |
|---|---|
| Date | 2012-09-25 10:43 -0700 |
| Subject | Multiple <a> Tags, Filled With MySQL DB data with PHP |
| Message-ID | <e9cd6d56-2c2a-422b-af7c-f6abb198d441@googlegroups.com> |
Hello
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.
The "working" code is:
<a class="fancybox" rel="1" href="/image4.jpg" title="Title 1"><img src="thumbnail.jpg"></a>
<a class="fancybox" rel="1" href="/image3.jpg" title="Title 2"></a>
<a class="fancybox" rel="2" href="/image2.jpg" title="Title 3"><img src="thumbnail.jpg"></a>
<a class="fancybox" rel="2" href="/image1.jpg" title="Title 4"></a>
This essentially groups the images by the 'rel' tag automatically, showing two thumbnails which when clicked shows the corresponding images in descending order (ie last added).
In my database I have created a 'rel' field and populated it with either "1" or "2", and tried the following:
<!-- START OF PHP SCRIPT (DB OPEN)-->
<?
include("php/dbinfo.inc.php");
mysql_connect($hostname,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$visuals_query=mysql_query("SELECT id, imagelink, comment, picdate, rel FROM PictureMedia ORDER BY picdate DESC");
mysql_close();
?>
<!-- END OF PP SCRIPT (DB OPEN) -->
<?
while($r=mysql_fetch_assoc($visuals_query)) {
echo '<a class="fancybox" rel="'.$r["rel"].'" href="'.$r["imagelink"].'" title="'.$r["comment"].'"><img src="thumbnail.jpg"></a>';
}
?>
Now, I think that this should do exactly the same thing, other than showing four thumbnails obviously. What actually happens is that the first thumbnail loads the last added image in a new page, then the other three as expected but with the focus on the picture displayed by the query. It also did not show a Facebook share button when using PHP.
I understand that this issue isn't all down to PHP, but may be down to the fancybox script. However, I can't post in two groups simultaneously so if my code looks correct then I can go along another route.
Thanks in advance
Tom
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-09-25 14:21 -0400 |
| Message-ID | <k3ssnt$59g$2@dont-email.me> |
| In reply to | #7149 |
On 9/25/2012 1:43 PM, tom.rankin51@googlemail.com wrote:
> Hello
>
> 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.
>
> The "working" code is:
>
> <a class="fancybox" rel="1" href="/image4.jpg" title="Title 1"><img src="thumbnail.jpg"></a>
> <a class="fancybox" rel="1" href="/image3.jpg" title="Title 2"></a>
> <a class="fancybox" rel="2" href="/image2.jpg" title="Title 3"><img src="thumbnail.jpg"></a>
> <a class="fancybox" rel="2" href="/image1.jpg" title="Title 4"></a>
>
> This essentially groups the images by the 'rel' tag automatically, showing two thumbnails which when clicked shows the corresponding images in descending order (ie last added).
>
> In my database I have created a 'rel' field and populated it with either "1" or "2", and tried the following:
>
> <!-- START OF PHP SCRIPT (DB OPEN)-->
> <?
> include("php/dbinfo.inc.php");
>
> mysql_connect($hostname,$username,$password);
> @mysql_select_db($database) or die( "Unable to select database");
>
> $visuals_query=mysql_query("SELECT id, imagelink, comment, picdate, rel FROM PictureMedia ORDER BY picdate DESC");
>
> mysql_close();
> ?>
> <!-- END OF PP SCRIPT (DB OPEN) -->
>
> <?
> while($r=mysql_fetch_assoc($visuals_query)) {
> echo '<a class="fancybox" rel="'.$r["rel"].'" href="'.$r["imagelink"].'" title="'.$r["comment"].'"><img src="thumbnail.jpg"></a>';
> }
> ?>
>
> Now, I think that this should do exactly the same thing, other than showing four thumbnails obviously. What actually happens is that the first thumbnail loads the last added image in a new page, then the other three as expected but with the focus on the picture displayed by the query. It also did not show a Facebook share button when using PHP.
>
> I understand that this issue isn't all down to PHP, but may be down to the fancybox script. However, I can't post in two groups simultaneously so if my code looks correct then I can go along another route.
>
> Thanks in advance
> Tom
>
Look at the source code in your page - does it look correct?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[toc] | [prev] | [next] | [standalone]
| From | tom.rankin51@googlemail.com |
|---|---|
| Date | 2012-09-25 11:26 -0700 |
| Message-ID | <6e6e05bf-9922-48ce-a50e-f64b8939356a@googlegroups.com> |
| In reply to | #7154 |
I'm not sure what you mean. I think my source is correct yes, hence why I can't figure out the problem. As far as my knowledge extends, the php code I provided does exactly the same as the collection of <a> tags - but it produces completely different results.
I have already noted that my php code will produce four thumbnails which I have accounted for, however it i this code which will load the first image in a new page and not display facebook share links.
Tom
On Tuesday, September 25, 2012 7:21:50 PM UTC+1, Jerry Stuckle wrote:
> On 9/25/2012 1:43 PM, tom.rankin51@googlemail.com wrote:
>
> > Hello
>
> >
>
> > 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.
>
> >
>
> > The "working" code is:
>
> >
>
> > <a class="fancybox" rel="1" href="/image4.jpg" title="Title 1"><img src="thumbnail.jpg"></a>
>
> > <a class="fancybox" rel="1" href="/image3.jpg" title="Title 2"></a>
>
> > <a class="fancybox" rel="2" href="/image2.jpg" title="Title 3"><img src="thumbnail.jpg"></a>
>
> > <a class="fancybox" rel="2" href="/image1.jpg" title="Title 4"></a>
>
> >
>
> > This essentially groups the images by the 'rel' tag automatically, showing two thumbnails which when clicked shows the corresponding images in descending order (ie last added).
>
> >
>
> > In my database I have created a 'rel' field and populated it with either "1" or "2", and tried the following:
>
> >
>
> > <!-- START OF PHP SCRIPT (DB OPEN)-->
>
> > <?
>
> > include("php/dbinfo.inc.php");
>
> >
>
> > mysql_connect($hostname,$username,$password);
>
> > @mysql_select_db($database) or die( "Unable to select database");
>
> >
>
> > $visuals_query=mysql_query("SELECT id, imagelink, comment, picdate, rel FROM PictureMedia ORDER BY picdate DESC");
>
> >
>
> > mysql_close();
>
> > ?>
>
> > <!-- END OF PP SCRIPT (DB OPEN) -->
>
> >
>
> > <?
>
> > while($r=mysql_fetch_assoc($visuals_query)) {
>
> > echo '<a class="fancybox" rel="'.$r["rel"].'" href="'.$r["imagelink"].'" title="'.$r["comment"].'"><img src="thumbnail.jpg"></a>';
>
> > }
>
> > ?>
>
> >
>
> > Now, I think that this should do exactly the same thing, other than showing four thumbnails obviously. What actually happens is that the first thumbnail loads the last added image in a new page, then the other three as expected but with the focus on the picture displayed by the query. It also did not show a Facebook share button when using PHP.
>
> >
>
> > I understand that this issue isn't all down to PHP, but may be down to the fancybox script. However, I can't post in two groups simultaneously so if my code looks correct then I can go along another route.
>
> >
>
> > Thanks in advance
>
> > Tom
>
> >
>
>
>
> Look at the source code in your page - does it look correct?
>
>
>
> --
>
> ==================
>
> Remove the "x" from my email address
>
> Jerry Stuckle
>
> JDS Computer Training Corp.
>
> jstucklex@attglobal.net
>
> ==================
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-09-25 16:02 -0400 |
| Message-ID | <k3t2kr$fdn$1@dont-email.me> |
| In reply to | #7157 |
On 9/25/2012 2:26 PM, tom.rankin51@googlemail.com wrote: > On Tuesday, September 25, 2012 7:21:50 PM UTC+1, Jerry Stuckle wrote: >> On 9/25/2012 1:43 PM, tom.rankin51@googlemail.com wrote: >> >>> Hello >> >>> >> >>> 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. >> >>> >> <snip code> >>> Now, I think that this should do exactly the same thing, other than showing four thumbnails obviously. What actually happens is that the first thumbnail loads the last added image in a new page, then the other three as expected but with the focus on the picture displayed by the query. It also did not show a Facebook share button when using PHP. >> >>> >> >>> I understand that this issue isn't all down to PHP, but may be down to the fancybox script. However, I can't post in two groups simultaneously so if my code looks correct then I can go along another route. >> >>> >> >>> Thanks in advance >> >>> Tom >> >>> >> >> >> >> Look at the source code in your page - does it look correct? >> >> > I'm not sure what you mean. I think my source is correct yes, hence why I can't figure out the problem. As far as my knowledge extends, the php code I provided does exactly the same as the collection of <a> tags - but it produces completely different results. > > I have already noted that my php code will produce four thumbnails which I have accounted for, however it i this code which will load the first image in a new page and not display facebook share links. > > Tom > (top posting fixed) I mean look at the generated HTML - in your browser, "View Source". Compare it to what works. It obviously is NOT correct, or it would generate the desired results. Also, you should NOT use the '@' character on your MySQL (or any other) calls. It will hide any possible warning or error messages you get. P.S. Please don't top post. Thanks. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2012-09-25 18:41 +0000 |
| Message-ID | <k3stt1$5ba$1@dont-email.me> |
| In reply to | #7149 |
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
[toc] | [prev] | [next] | [standalone]
| From | tom.rankin51@googlemail.com |
|---|---|
| Date | 2012-09-25 12:16 -0700 |
| Message-ID | <397efd7d-bf0e-4a14-80e3-03849e6c1360@googlegroups.com> |
| In reply to | #7161 |
I'm way ahead of you. My code is exactly the same regardless of whether I use the PHP or the HTML. My error logs contain absolutely nothing so it doesn't appear to be posting any errors at all.
I honestly thought the above was the bare minimum :-)
I'm pretty exasperated now though with it because it appears I've done everything right?
Tom
On Tuesday, September 25, 2012 7:41:38 PM UTC+1, Denis McMahon wrote:
> 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
[toc] | [prev] | [next] | [standalone]
| From | tom.rankin51@googlemail.com |
|---|---|
| Date | 2012-09-25 12:58 -0700 |
| Message-ID | <dc2ece11-7acb-4d9b-9d97-15744eb5df28@googlegroups.com> |
| In reply to | #7161 |
I'm not too sure how to debug correctly following these instructions. I can place the code at the beginning and end of my page, but I am getting a syntax error when typing $result = mysqli->query($sql);
Also, I'm unsure which bits I place around which other other bits :-D This is something which is taking me completely out of my depth to be honest so even though the description was in depth, it's maybe not as in depth enough for me.
Tom
On Tuesday, September 25, 2012 7:41:38 PM UTC+1, Denis McMahon wrote:
> 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
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2012-09-25 22:12 +0200 |
| Message-ID | <qqf9j9-fbj.ln1@luuk.invalid.lan> |
| In reply to | #7167 |
On 25-09-2012 21:58, tom.rankin51@googlemail.com wrote:
> I'm not too sure how to debug correctly following these instructions. I can place the code at the beginning and end of my page, but I am getting a syntax error when typing $result = mysqli->query($sql);
>
>> <?php
>> $sql = ".......";
>> $result = mysqli->query( $sql );
>> $debugtxt .= "sql: {$sql}\n";
or, that last one could be:
echo "SQL: {$sql}\n";
it should echo the query to the output......
[toc] | [prev] | [next] | [standalone]
| From | tom.rankin51@googlemail.com |
|---|---|
| Date | 2012-09-25 13:38 -0700 |
| Message-ID | <fdf8c5d9-16f3-4630-8cfc-dc07e741b414@googlegroups.com> |
| In reply to | #7170 |
My HTML regardless of whether I use my PHP code or the <a> tags is exactly the same. I've checked this many times. I can't explain it any other way. It's definitely the same.
Also I'm not a PHP guru or anything - I have literally learnt what I thought I needed last weekend so I'm really new to all of this. I had a friend helping me oversee what I was doing, but like a good IT Support Tech he decided to not want to help me any more just as it was getting to the stuff that would need support.
So all of this above is going a bit over the top of my head.
On Tuesday, September 25, 2012 9:20:02 PM UTC+1, Luuk wrote:
> On 25-09-2012 21:58, tom.rankin51@googlemail.com wrote:
>
> > I'm not too sure how to debug correctly following these instructions. I can place the code at the beginning and end of my page, but I am getting a syntax error when typing $result = mysqli->query($sql);
>
> >
>
> >> <?php
>
> >> $sql = ".......";
>
> >> $result = mysqli->query( $sql );
>
>
>
> >> $debugtxt .= "sql: {$sql}\n";
>
>
>
> or, that last one could be:
>
> echo "SQL: {$sql}\n";
>
>
>
> it should echo the query to the output......
[toc] | [prev] | [next] | [standalone]
| From | tom.rankin51@googlemail.com |
|---|---|
| Date | 2012-09-25 13:53 -0700 |
| Message-ID | <dc8c3cd2-f930-4ca7-90ff-3b213926388c@googlegroups.com> |
| In reply to | #7171 |
Sorry I realised I top posted in that too after you said. I'm such an idiot sometimes lol.
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2012-09-25 23:19 +0000 |
| Message-ID | <k3te6p$inm$1@dont-email.me> |
| In reply to | #7170 |
On Tue, 25 Sep 2012 22:12:43 +0200, Luuk wrote:
> On 25-09-2012 21:58, tom.rankin51@googlemail.com wrote:
>> I'm not too sure how to debug correctly following these instructions.
>> I can place the code at the beginning and end of my page, but I am
>> getting a syntax error when typing $result = mysqli->query($sql);
>>
>>> <?php $sql = ".......";
>>> $result = mysqli->query( $sql );
>
>>> $debugtxt .= "sql: {$sql}\n";
>
> or, that last one could be:
> echo "SQL: {$sql}\n";
>
> it should echo the query to the output......
Yeah, but when I'm trying to debug code generating a web page, I stick
all the debugging output in a <pre> element at the end of the page, if I
don't get the pre element output the problem is invariably identified in
the server error log.
To the OP - sorry, you're not using mysqli .... replace "$result = mysqli-
>exec( $sql );" with whatever code you're using to make your database
call, maybe the "mysql_query" call.
Change this php:
$visuals_query=mysql_query("SELECT id, imagelink, comment, picdate, rel
FROM PictureMedia ORDER BY picdate DESC");
To:
<?php
$sql = "SELECT id, imagelink, comment, picdate, rel FROM PictureMedia
ORDER BY picdate DESC";
$visuals_query=mysql_query( $sql );
$debug = "sql: " $sql . "\nresult: " . var_dump( $visuals_query ) . "\n";
if ( $visuals_query == false )
$debug .= "sql error: " . mysql_error() . "\n";
?>
and then use the
<?php echo "<php>{$debug}</pre>"; ?>
to show the actual query, the query result set (warning, can be large)
and any sql error messages.
Rgds
Denis McMahon
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-09-25 19:48 -0400 |
| Message-ID | <k3tfsk$4lu$1@dont-email.me> |
| In reply to | #7175 |
On 9/25/2012 7:19 PM, Denis McMahon wrote:
> On Tue, 25 Sep 2012 22:12:43 +0200, Luuk wrote:
>
>> On 25-09-2012 21:58, tom.rankin51@googlemail.com wrote:
>>> I'm not too sure how to debug correctly following these instructions.
>>> I can place the code at the beginning and end of my page, but I am
>>> getting a syntax error when typing $result = mysqli->query($sql);
>>>
>>>> <?php $sql = ".......";
>>>> $result = mysqli->query( $sql );
>>
>>>> $debugtxt .= "sql: {$sql}\n";
>>
>> or, that last one could be:
>> echo "SQL: {$sql}\n";
>>
>> it should echo the query to the output......
>
> Yeah, but when I'm trying to debug code generating a web page, I stick
> all the debugging output in a <pre> element at the end of the page, if I
> don't get the pre element output the problem is invariably identified in
> the server error log.
>
> To the OP - sorry, you're not using mysqli .... replace "$result = mysqli-
>> exec( $sql );" with whatever code you're using to make your database
> call, maybe the "mysql_query" call.
>
> Change this php:
>
> $visuals_query=mysql_query("SELECT id, imagelink, comment, picdate, rel
> FROM PictureMedia ORDER BY picdate DESC");
>
> To:
>
> <?php
> $sql = "SELECT id, imagelink, comment, picdate, rel FROM PictureMedia
> ORDER BY picdate DESC";
> $visuals_query=mysql_query( $sql );
> $debug = "sql: " $sql . "\nresult: " . var_dump( $visuals_query ) . "\n";
> if ( $visuals_query == false )
> $debug .= "sql error: " . mysql_error() . "\n";
> ?>
>
> and then use the
>
> <?php echo "<php>{$debug}</pre>"; ?>
>
> to show the actual query, the query result set (warning, can be large)
> and any sql error messages.
>
> Rgds
>
> Denis McMahon
>
Won't show much. The result of a mysql_query call is a result, not an
array. All it will say is "false" or "resource id 2" (or similar). And
your following "if" statement will handle the first result.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2012-09-26 14:25 +0000 |
| Message-ID | <k3v38a$jbm$2@dont-email.me> |
| In reply to | #7176 |
On Tue, 25 Sep 2012 19:48:35 -0400, Jerry Stuckle wrote:
>> <?php $sql = "SELECT id, imagelink, comment, picdate, rel FROM
>> PictureMedia ORDER BY picdate DESC";
>> $visuals_query=mysql_query( $sql );
>> $debug = "sql: " $sql . "\nresult: " . var_dump( $visuals_query ) .
>> "\n"; if ( $visuals_query == false )
>> $debug .= "sql error: " . mysql_error() . "\n";
>> ?>
> Won't show much. The result of a mysql_query call is a result, not an
> array. All it will say is "false" or "resource id 2" (or similar). And
> your following "if" statement will handle the first result.
Point taken, it probably needs to be more like:
<?php
$sql = "SELECT id, imagelink, comment, picdate, rel FROM PictureMedia
ORDER BY picdate DESC";
$visuals_query = mysql_query( $sql );
$debug = "sql: " $sql . "\n";
if ( $visuals_query == false ) {
$debug .= "sql error: " . mysql_error() . "\n";
}
else {
$debug .= "Result set contained " . mysql_num_rows( $visuals_query
) ." rows\n";
if ( mysql_num_rows( $visuals_query ) > 0 ) {
$debug .= "Rows:\n"
while ( $tmp = mysql_fetch_assoc( $visuals_query ) )
$debug .= var_dump( $tmp );
mysql_data_seek( $visuals_query, 0 );
}
}
?>
Rgds
Denis McMahon
[toc] | [prev] | [next] | [standalone]
| From | tom.rankin51@googlemail.com |
|---|---|
| Date | 2012-09-25 12:10 -0700 |
| Message-ID | <5967262c-1b79-4b01-a9f3-14265f2707b5@googlegroups.com> |
| In reply to | #7149 |
I'm way ahead of you. The code above is the minimum as far as I'm concerned - however, it's all for nothing when you consider that my error logs have absolutely nothing in them and the HTML code is exactly the same between my PHP and HTML.
This is why I'm reaching the end of my knowledge!
On Tuesday, September 25, 2012 6:43:45 PM UTC+1, (unknown) wrote:
> Hello
>
>
>
> 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.
>
>
>
> The "working" code is:
>
>
>
> <a class="fancybox" rel="1" href="/image4.jpg" title="Title 1"><img src="thumbnail.jpg"></a>
>
> <a class="fancybox" rel="1" href="/image3.jpg" title="Title 2"></a>
>
> <a class="fancybox" rel="2" href="/image2.jpg" title="Title 3"><img src="thumbnail.jpg"></a>
>
> <a class="fancybox" rel="2" href="/image1.jpg" title="Title 4"></a>
>
>
>
> This essentially groups the images by the 'rel' tag automatically, showing two thumbnails which when clicked shows the corresponding images in descending order (ie last added).
>
>
>
> In my database I have created a 'rel' field and populated it with either "1" or "2", and tried the following:
>
>
>
> <!-- START OF PHP SCRIPT (DB OPEN)-->
>
> <?
>
> include("php/dbinfo.inc.php");
>
>
>
> mysql_connect($hostname,$username,$password);
>
> @mysql_select_db($database) or die( "Unable to select database");
>
>
>
> $visuals_query=mysql_query("SELECT id, imagelink, comment, picdate, rel FROM PictureMedia ORDER BY picdate DESC");
>
>
>
> mysql_close();
>
> ?>
>
> <!-- END OF PP SCRIPT (DB OPEN) -->
>
>
>
> <?
>
> while($r=mysql_fetch_assoc($visuals_query)) {
>
> echo '<a class="fancybox" rel="'.$r["rel"].'" href="'.$r["imagelink"].'" title="'.$r["comment"].'"><img src="thumbnail.jpg"></a>';
>
> }
>
> ?>
>
>
>
> Now, I think that this should do exactly the same thing, other than showing four thumbnails obviously. What actually happens is that the first thumbnail loads the last added image in a new page, then the other three as expected but with the focus on the picture displayed by the query. It also did not show a Facebook share button when using PHP.
>
>
>
> I understand that this issue isn't all down to PHP, but may be down to the fancybox script. However, I can't post in two groups simultaneously so if my code looks correct then I can go along another route.
>
>
>
> Thanks in advance
>
> Tom
[toc] | [prev] | [next] | [standalone]
| From | Christoph Becker <cmbecker69@gmx.de> |
|---|---|
| Date | 2012-09-26 00:27 +0200 |
| Message-ID | <k3tb4v$2cv$2@speranza.aioe.org> |
| In reply to | #7149 |
tom.rankin51 wrote: > Now, I think that this should do exactly the same thing, other than > showing four thumbnails obviously. What actually happens is that the > first thumbnail loads the last added image in a new page, then the > other three as expected but with the focus on the picture displayed > by the query. It also did not show a Facebook share button when > using PHP. Have you checked the JS (error) console of your browser? I would not be surprised, if an error will be reported there. -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-09-25 19:18 -0400 |
| Message-ID | <k3te4c$sjk$1@dont-email.me> |
| In reply to | #7173 |
On 9/25/2012 6:27 PM, Christoph Becker wrote: > tom.rankin51 wrote: >> Now, I think that this should do exactly the same thing, other than >> showing four thumbnails obviously. What actually happens is that the >> first thumbnail loads the last added image in a new page, then the >> other three as expected but with the focus on the picture displayed >> by the query. It also did not show a Facebook share button when >> using PHP. > > Have you checked the JS (error) console of your browser? I would not be > surprised, if an error will be reported there. > What javascript is being used here? -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | Christoph Becker <cmbecker69@gmx.de> |
|---|---|
| Date | 2012-09-26 02:04 +0200 |
| Message-ID | <k3tgpq$e1e$1@speranza.aioe.org> |
| In reply to | #7174 |
Jerry Stuckle wrote: > What javascript is being used here? Tom wants to present the images with Fancybox <http://fancybox.net/> (see the OP). Since the generated (X)HTML is /reportedly/ the same as the hand-written one, there /might/ be a problem on the javascript side -- even if that's quite unlikely, if the generated code is /exactly/ the same. -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-09-25 21:45 -0400 |
| Message-ID | <k3tmnc$3p6$1@dont-email.me> |
| In reply to | #7177 |
On 9/25/2012 8:04 PM, Christoph Becker wrote: > Jerry Stuckle wrote: >> What javascript is being used here? > > Tom wants to present the images with Fancybox <http://fancybox.net/> > (see the OP). Since the generated (X)HTML is /reportedly/ the same as > the hand-written one, there /might/ be a problem on the javascript side > -- even if that's quite unlikely, if the generated code is /exactly/ the > same. > The HTML he's trying to emulate does not use javascript. And even if it did - it would be the same javascript in both cases, and would either work or fail in both cases. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | tom.rankin51@googlemail.com |
|---|---|
| Date | 2012-09-25 23:16 -0700 |
| Message-ID | <34ad523d-c5a0-4d8a-bb4e-b5a63a424402@googlegroups.com> |
| In reply to | #7178 |
So should I attempt debugging this? People seem tonhbe mixed opinions over whether it would be a wise thing to do? There also seems to be debate over whether my HTML is the same in both cases. I can post this too ifnit helps? I can post my JS but it is anything standard at fancyapps.com/fancybox
[toc] | [prev] | [next] | [standalone]
| From | tom.rankin51@googlemail.com |
|---|---|
| Date | 2012-09-26 01:39 -0700 |
| Message-ID | <de8c5f68-66ba-40c7-a3d7-618ef9495a87@googlegroups.com> |
| In reply to | #7179 |
To help things along, please find a test page at www.tomrankinmusic.com/vistest.php
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.php
csiph-web