Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #7147 > unrolled thread
| Started by | tom.rankin51@googlemail.com |
|---|---|
| First post | 2012-09-25 10:27 -0700 |
| Last post | 2012-09-26 11:16 -0400 |
| Articles | 12 — 6 participants |
Back to article view | Back to comp.lang.php
Dynamic Links (MySQL/PHP) tom.rankin51@googlemail.com - 2012-09-25 10:27 -0700
Re: Dynamic Links (MySQL/PHP) The Natural Philosopher <tnp@invalid.invalid> - 2012-09-25 18:41 +0100
Re: Dynamic Links (MySQL/PHP) tom.rankin51@googlemail.com - 2012-09-25 10:58 -0700
Re: Dynamic Links (MySQL/PHP) tom.rankin51@googlemail.com - 2012-09-25 11:34 -0700
Re: Dynamic Links (MySQL/PHP) Luuk <luuk@invalid.lan> - 2012-09-25 21:07 +0200
Re: Dynamic Links (MySQL/PHP) Luuk <luuk@invalid.lan> - 2012-09-25 20:02 +0200
Re: Dynamic Links (MySQL/PHP) tom.rankin51@googlemail.com - 2012-09-25 11:17 -0700
Re: Dynamic Links (MySQL/PHP) Luuk <luuk@invalid.lan> - 2012-09-25 21:04 +0200
Re: Dynamic Links (MySQL/PHP) tom.rankin51@googlemail.com - 2012-09-25 23:24 -0700
Re: Dynamic Links (MySQL/PHP) Denis McMahon <denismfmcmahon@gmail.com> - 2012-09-26 14:03 +0000
Re: Dynamic Links (MySQL/PHP) Captain Paralytic <paul_lautman@yahoo.com> - 2012-09-26 05:05 -0700
Re: Dynamic Links (MySQL/PHP) Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-26 11:16 -0400
| From | tom.rankin51@googlemail.com |
|---|---|
| Date | 2012-09-25 10:27 -0700 |
| Subject | Dynamic Links (MySQL/PHP) |
| Message-ID | <ebad13b2-cbfd-412c-a199-4350f1168efb@googlegroups.com> |
Hello
I have a very basic knowledge of PHP and MySQL and sought help from a friend who initially was someone I can turn to but now can't provide me with any help (!) ...and so to Google Groups!
I am trying to display preview text on a webpage and then after clicking a link it will take you to the full item. It must be quite a simple thing to do, however, I am getting a completely blank page. I get no errors, and I have no syntax errors that I can see so I'm struggling to see what I have done wrongly.
My code on the main page is :
<?
include("php/dbinfo.inc.php");
mysql_connect($hostname,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$mydate=date("Y-m-d",strtotime("-2 weeks"));
$news_query=mysql_query("SELECT id, postdate, title, SUBSTRING_INDEX(body,' ',20) as preview_text, body FROM NewsContent WHERE postdate > '$mydate' ORDER BY postdate DESC");
mysql_close();
?>
<div>
<ol>
<!-- START OF PHP SCRIPT (NEWS) -->
<?
while($r=mysql_fetch_assoc($news_query)) {
echo '<li id="'.$r["id"].'">';
echo '<h2 class="body-headline">';
echo $r["title"];
echo '</h2>';
echo '<h3 class="date-heading">';
echo date("d-M-Y",strtotime($r["postdate"]));
echo '</h3>';
echo nl2br ($r["preview_text"]);
echo '...<a class="fancybox fancybox.ajax" href="news.php?id='.$r["id"].'">show more</a>';
echo '</li><hr />';
} ?>
<!-- END OF PHP SCRIPT (NEWS) -->
</ol>
</div>
Note that I'm using a fancybox script, but this happens without using that script also.
In my news item page I have done the following:
<?
include("php/dbinfo.inc.php");
mysql_connect($hostname,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$id = $_GET['id'];
$sql = "SELECT id, postdate, title, body FROM NewsContent WHERE id = '$id'";
$news_query=mysql_query($sql);
IF ($news_query){
$r = mysql_fetch_row($news_query);
$title = $r["title"];
$body = $r["body"];
}
mysql_close();
?>
<div>
<h2>
<?
echo $r["title"];
?>
</h2>
<div class="modal-nav-links">
<p><?php echo $r["body"] ?></p>
<!-- <div style="clear: both;"></div> -->
</div>
</div>
I was under the impression that this would work, but no dice. Can someone with a bit of experience give me an idea of what I'm doing incorrectly?
Thanks in advance
Tom
[toc] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2012-09-25 18:41 +0100 |
| Message-ID | <k3sqbk$ntp$1@news.albasani.net> |
| In reply to | #7147 |
tom.rankin51@googlemail.com wrote:
> Hello
>
> I have a very basic knowledge of PHP and MySQL and sought help from a friend who initially was someone I can turn to but now can't provide me with any help (!) ...and so to Google Groups!
>
> I am trying to display preview text on a webpage and then after clicking a link it will take you to the full item. It must be quite a simple thing to do, however, I am getting a completely blank page. I get no errors, and I have no syntax errors that I can see so I'm struggling to see what I have done wrongly.
>
> My code on the main page is :
>
> <?
> include("php/dbinfo.inc.php");
>
> mysql_connect($hostname,$username,$password);
> @mysql_select_db($database) or die( "Unable to select database");
>
> $mydate=date("Y-m-d",strtotime("-2 weeks"));
>
> $news_query=mysql_query("SELECT id, postdate, title, SUBSTRING_INDEX(body,' ',20) as preview_text, body FROM NewsContent WHERE postdate > '$mydate' ORDER BY postdate DESC");
>
> mysql_close();
> ?>
>
> <div>
> <ol>
> <!-- START OF PHP SCRIPT (NEWS) -->
> <?
> while($r=mysql_fetch_assoc($news_query)) {
> echo '<li id="'.$r["id"].'">';
> echo '<h2 class="body-headline">';
> echo $r["title"];
> echo '</h2>';
> echo '<h3 class="date-heading">';
> echo date("d-M-Y",strtotime($r["postdate"]));
> echo '</h3>';
> echo nl2br ($r["preview_text"]);
> echo '...<a class="fancybox fancybox.ajax" href="news.php?id='.$r["id"].'">show more</a>';
> echo '</li><hr />';
> } ?>
> <!-- END OF PHP SCRIPT (NEWS) -->
> </ol>
> </div>
>
> Note that I'm using a fancybox script, but this happens without using that script also.
>
> In my news item page I have done the following:
>
> <?
> include("php/dbinfo.inc.php");
>
> mysql_connect($hostname,$username,$password);
> @mysql_select_db($database) or die( "Unable to select database");
>
> $id = $_GET['id'];
> $sql = "SELECT id, postdate, title, body FROM NewsContent WHERE id = '$id'";
> $news_query=mysql_query($sql);
> IF ($news_query){
> $r = mysql_fetch_row($news_query);
>
> $title = $r["title"];
> $body = $r["body"];
> }
>
> mysql_close();
> ?>
>
> <div>
> <h2>
> <?
> echo $r["title"];
> ?>
> </h2>
> <div class="modal-nav-links">
> <p><?php echo $r["body"] ?></p>
> <!-- <div style="clear: both;"></div> -->
> </div>
> </div>
>
>
> I was under the impression that this would work, but no dice. Can someone with a bit of experience give me an idea of what I'm doing incorrectly?
>
> Thanks in advance
> Tom
Haven't time to explore your source, but if its on a server that you
administer, look in apache* error logs: that's where PHP errors can end up.
*or whatever web server it is
--
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.
[toc] | [prev] | [next] | [standalone]
| From | tom.rankin51@googlemail.com |
|---|---|
| Date | 2012-09-25 10:58 -0700 |
| Message-ID | <4a2d4f8b-96c5-41ca-90b3-6eeebd767b04@googlegroups.com> |
| In reply to | #7148 |
I'm looking into my error logs but can't find an error anywhere. For the record, I found a .log file in my Apache Logs folder, and a .htaccess file that contains nothing in my Error Logs folder.
I apologise, this is not something I've ever had to do before.
Tom
On Tuesday, September 25, 2012 6:41:09 PM UTC+1, The Natural Philosopher wrote:
> tom wrote:
>
> > Hello
>
> >
>
> > I have a very basic knowledge of PHP and MySQL and sought help from a friend who initially was someone I can turn to but now can't provide me with any help (!) ...and so to Google Groups!
>
> >
>
> > I am trying to display preview text on a webpage and then after clicking a link it will take you to the full item. It must be quite a simple thing to do, however, I am getting a completely blank page. I get no errors, and I have no syntax errors that I can see so I'm struggling to see what I have done wrongly.
>
> >
>
> > My code on the main page is :
>
> >
>
> > <?
>
> > include("php/dbinfo.inc.php");
>
> >
>
> > mysql_connect($hostname,$username,$password);
>
> > @mysql_select_db($database) or die( "Unable to select database");
>
> >
>
> > $mydate=date("Y-m-d",strtotime("-2 weeks"));
>
> >
>
> > $news_query=mysql_query("SELECT id, postdate, title, SUBSTRING_INDEX(body,' ',20) as preview_text, body FROM NewsContent WHERE postdate > '$mydate' ORDER BY postdate DESC");
>
> >
>
> > mysql_close();
>
> > ?>
>
> >
>
> > <div>
>
> > <ol>
>
> > <!-- START OF PHP SCRIPT (NEWS) -->
>
> > <?
>
> > while($r=mysql_fetch_assoc($news_query)) {
>
> > echo '<li id="'.$r["id"].'">';
>
> > echo '<h2 class="body-headline">';
>
> > echo $r["title"];
>
> > echo '</h2>';
>
> > echo '<h3 class="date-heading">';
>
> > echo date("d-M-Y",strtotime($r["postdate"]));
>
> > echo '</h3>';
>
> > echo nl2br ($r["preview_text"]);
>
> > echo '...<a class="fancybox fancybox.ajax" href="news.php?id='.$r["id"].'">show more</a>';
>
> > echo '</li><hr />';
>
> > } ?>
>
> > <!-- END OF PHP SCRIPT (NEWS) -->
>
> > </ol>
>
> > </div>
>
> >
>
> > Note that I'm using a fancybox script, but this happens without using that script also.
>
> >
>
> > In my news item page I have done the following:
>
> >
>
> > <?
>
> > include("php/dbinfo.inc.php");
>
> >
>
> > mysql_connect($hostname,$username,$password);
>
> > @mysql_select_db($database) or die( "Unable to select database");
>
> >
>
> > $id = $_GET['id'];
>
> > $sql = "SELECT id, postdate, title, body FROM NewsContent WHERE id = '$id'";
>
> > $news_query=mysql_query($sql);
>
> > IF ($news_query){
>
> > $r = mysql_fetch_row($news_query);
>
> >
>
> > $title = $r["title"];
>
> > $body = $r["body"];
>
> > }
>
> >
>
> > mysql_close();
>
> > ?>
>
> >
>
> > <div>
>
> > <h2>
>
> > <?
>
> > echo $r["title"];
>
> > ?>
>
> > </h2>
>
> > <div class="modal-nav-links">
>
> > <p><?php echo $r["body"] ?></p>
>
> > <!-- <div style="clear: both;"></div> -->
>
> > </div>
>
> > </div>
>
> >
>
> >
>
> > I was under the impression that this would work, but no dice. Can someone with a bit of experience give me an idea of what I'm doing incorrectly?
>
> >
>
> > Thanks in advance
>
> > Tom
>
>
>
>
>
> Haven't time to explore your source, but if its on a server that you
>
> administer, look in apache* error logs: that's where PHP errors can end up.
>
>
>
> *or whatever web server it is
>
>
>
> --
>
> 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.
[toc] | [prev] | [next] | [standalone]
| From | tom.rankin51@googlemail.com |
|---|---|
| Date | 2012-09-25 11:34 -0700 |
| Message-ID | <df8bee0a-cd48-4e44-92a8-7b66cb9486b4@googlegroups.com> |
| In reply to | #7148 |
Just to update, my error logs are completely empty
On Tuesday, September 25, 2012 6:41:09 PM UTC+1, The Natural Philosopher wrote:
> tom.rankin51@googlemail.com wrote:
>
> > Hello
>
> >
>
> > I have a very basic knowledge of PHP and MySQL and sought help from a friend who initially was someone I can turn to but now can't provide me with any help (!) ...and so to Google Groups!
>
> >
>
> > I am trying to display preview text on a webpage and then after clicking a link it will take you to the full item. It must be quite a simple thing to do, however, I am getting a completely blank page. I get no errors, and I have no syntax errors that I can see so I'm struggling to see what I have done wrongly.
>
> >
>
> > My code on the main page is :
>
> >
>
> > <?
>
> > include("php/dbinfo.inc.php");
>
> >
>
> > mysql_connect($hostname,$username,$password);
>
> > @mysql_select_db($database) or die( "Unable to select database");
>
> >
>
> > $mydate=date("Y-m-d",strtotime("-2 weeks"));
>
> >
>
> > $news_query=mysql_query("SELECT id, postdate, title, SUBSTRING_INDEX(body,' ',20) as preview_text, body FROM NewsContent WHERE postdate > '$mydate' ORDER BY postdate DESC");
>
> >
>
> > mysql_close();
>
> > ?>
>
> >
>
> > <div>
>
> > <ol>
>
> > <!-- START OF PHP SCRIPT (NEWS) -->
>
> > <?
>
> > while($r=mysql_fetch_assoc($news_query)) {
>
> > echo '<li id="'.$r["id"].'">';
>
> > echo '<h2 class="body-headline">';
>
> > echo $r["title"];
>
> > echo '</h2>';
>
> > echo '<h3 class="date-heading">';
>
> > echo date("d-M-Y",strtotime($r["postdate"]));
>
> > echo '</h3>';
>
> > echo nl2br ($r["preview_text"]);
>
> > echo '...<a class="fancybox fancybox.ajax" href="news.php?id='.$r["id"].'">show more</a>';
>
> > echo '</li><hr />';
>
> > } ?>
>
> > <!-- END OF PHP SCRIPT (NEWS) -->
>
> > </ol>
>
> > </div>
>
> >
>
> > Note that I'm using a fancybox script, but this happens without using that script also.
>
> >
>
> > In my news item page I have done the following:
>
> >
>
> > <?
>
> > include("php/dbinfo.inc.php");
>
> >
>
> > mysql_connect($hostname,$username,$password);
>
> > @mysql_select_db($database) or die( "Unable to select database");
>
> >
>
> > $id = $_GET['id'];
>
> > $sql = "SELECT id, postdate, title, body FROM NewsContent WHERE id = '$id'";
>
> > $news_query=mysql_query($sql);
>
> > IF ($news_query){
>
> > $r = mysql_fetch_row($news_query);
>
> >
>
> > $title = $r["title"];
>
> > $body = $r["body"];
>
> > }
>
> >
>
> > mysql_close();
>
> > ?>
>
> >
>
> > <div>
>
> > <h2>
>
> > <?
>
> > echo $r["title"];
>
> > ?>
>
> > </h2>
>
> > <div class="modal-nav-links">
>
> > <p><?php echo $r["body"] ?></p>
>
> > <!-- <div style="clear: both;"></div> -->
>
> > </div>
>
> > </div>
>
> >
>
> >
>
> > I was under the impression that this would work, but no dice. Can someone with a bit of experience give me an idea of what I'm doing incorrectly?
>
> >
>
> > Thanks in advance
>
> > Tom
>
>
>
>
>
> Haven't time to explore your source, but if its on a server that you
>
> administer, look in apache* error logs: that's where PHP errors can end up.
>
>
>
> *or whatever web server it is
>
>
>
> --
>
> 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.
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2012-09-25 21:07 +0200 |
| Message-ID | <61c9j9-hoi.ln1@luuk.invalid.lan> |
| In reply to | #7159 |
On 25-09-2012 20:34, tom.rankin51@googlemail.com wrote: > Just to update, my error logs are completely empty > > On Tuesday, September 25, 2012 6:41:09 PM UTC+1, The Natural Philosopher wrote: >> tom.rankin51@googlemail.com wrote: >> >>> Hello >> >>> >> >>> I have a very basic knowledge of PHP and MySQL and sought help from a friend who initially was someone I can turn to but now can't provide me with any help (!) ...and so to Google Groups! >> >>> try to add some 'debugging' code and change '@mysql_select_db' to 'mysql_select_db' add some echo statements after assignements and see where the output stops, or is wrong/unexpected.......
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2012-09-25 20:02 +0200 |
| Message-ID | <5689j9-i3i.ln1@luuk.invalid.lan> |
| In reply to | #7147 |
On 25-09-2012 19:27, tom.rankin51@googlemail.com wrote:
> Hello
>
> I have a very basic knowledge of PHP and MySQL and sought help from a friend who initially was someone I can turn to but now can't provide me with any help (!) ...and so to Google Groups!
>
> I am trying to display preview text on a webpage and then after clicking a link it will take you to the full item. It must be quite a simple thing to do, however, I am getting a completely blank page. I get no errors, and I have no syntax errors that I can see so I'm struggling to see what I have done wrongly.
>
> My code on the main page is :
>
> <?
> include("php/dbinfo.inc.php");
>
> mysql_connect($hostname,$username,$password);
> @mysql_select_db($database) or die( "Unable to select database");
>
> $mydate=date("Y-m-d",strtotime("-2 weeks"));
>
> $news_query=mysql_query("SELECT id, postdate, title, SUBSTRING_INDEX(body,' ',20) as preview_text, body FROM NewsContent WHERE postdate > '$mydate' ORDER BY postdate DESC");
>
> mysql_close();
> ?>
>
> <div>
> <ol>
> <!-- START OF PHP SCRIPT (NEWS) -->
> <?
> while($r=mysql_fetch_assoc($news_query)) {
> echo '<li id="'.$r["id"].'">';
> echo '<h2 class="body-headline">';
> echo $r["title"];
> echo '</h2>';
> echo '<h3 class="date-heading">';
> echo date("d-M-Y",strtotime($r["postdate"]));
> echo '</h3>';
> echo nl2br ($r["preview_text"]);
> echo '...<a class="fancybox fancybox.ajax" href="news.php?id='.$r["id"].'">show more</a>';
> echo '</li><hr />';
> } ?>
> <!-- END OF PHP SCRIPT (NEWS) -->
> </ol>
> </div>
>
> Note that I'm using a fancybox script, but this happens without using that script also.
>
> In my news item page I have done the following:
>
> <?
> include("php/dbinfo.inc.php");
>
> mysql_connect($hostname,$username,$password);
> @mysql_select_db($database) or die( "Unable to select database");
>
> $id = $_GET['id'];
> $sql = "SELECT id, postdate, title, body FROM NewsContent WHERE id = '$id'";
> $news_query=mysql_query($sql);
> IF ($news_query){
> $r = mysql_fetch_row($news_query);
>
> $title = $r["title"];
> $body = $r["body"];
> }
>
> mysql_close();
> ?>
>
> <div>
> <h2>
> <?
> echo $r["title"];
> ?>
> </h2>
> <div class="modal-nav-links">
> <p><?php echo $r["body"] ?></p>
> <!-- <div style="clear: both;"></div> -->
> </div>
> </div>
>
>
> I was under the impression that this would work, but no dice. Can someone with a bit of experience give me an idea of what I'm doing incorrectly?
>
> Thanks in advance
> Tom
>
There is a missing 'mysql_select_db()'
http://php.net/manual/en/function.mysql-select-db.php
[toc] | [prev] | [next] | [standalone]
| From | tom.rankin51@googlemail.com |
|---|---|
| Date | 2012-09-25 11:17 -0700 |
| Message-ID | <f457009e-cf40-45dc-9b67-74ac021a652f@googlegroups.com> |
| In reply to | #7151 |
Both sections of code contain 'mysql_select_db() - should it be included a third time?
On Tuesday, September 25, 2012 7:10:02 PM UTC+1, Luuk wrote:
> On 25-09-2012 19:27, tom.rankin51@googlemail.com wrote:
>
> > Hello
>
> >
>
> > I have a very basic knowledge of PHP and MySQL and sought help from a friend who initially was someone I can turn to but now can't provide me with any help (!) ...and so to Google Groups!
>
> >
>
> > I am trying to display preview text on a webpage and then after clicking a link it will take you to the full item. It must be quite a simple thing to do, however, I am getting a completely blank page. I get no errors, and I have no syntax errors that I can see so I'm struggling to see what I have done wrongly.
>
> >
>
> > My code on the main page is :
>
> >
>
> > <?
>
> > include("php/dbinfo.inc.php");
>
> >
>
> > mysql_connect($hostname,$username,$password);
>
> > @mysql_select_db($database) or die( "Unable to select database");
>
> >
>
> > $mydate=date("Y-m-d",strtotime("-2 weeks"));
>
> >
>
> > $news_query=mysql_query("SELECT id, postdate, title, SUBSTRING_INDEX(body,' ',20) as preview_text, body FROM NewsContent WHERE postdate > '$mydate' ORDER BY postdate DESC");
>
> >
>
> > mysql_close();
>
> > ?>
>
> >
>
> > <div>
>
> > <ol>
>
> > <!-- START OF PHP SCRIPT (NEWS) -->
>
> > <?
>
> > while($r=mysql_fetch_assoc($news_query)) {
>
> > echo '<li id="'.$r["id"].'">';
>
> > echo '<h2 class="body-headline">';
>
> > echo $r["title"];
>
> > echo '</h2>';
>
> > echo '<h3 class="date-heading">';
>
> > echo date("d-M-Y",strtotime($r["postdate"]));
>
> > echo '</h3>';
>
> > echo nl2br ($r["preview_text"]);
>
> > echo '...<a class="fancybox fancybox.ajax" href="news.php?id='.$r["id"].'">show more</a>';
>
> > echo '</li><hr />';
>
> > } ?>
>
> > <!-- END OF PHP SCRIPT (NEWS) -->
>
> > </ol>
>
> > </div>
>
> >
>
> > Note that I'm using a fancybox script, but this happens without using that script also.
>
> >
>
> > In my news item page I have done the following:
>
> >
>
> > <?
>
> > include("php/dbinfo.inc.php");
>
> >
>
> > mysql_connect($hostname,$username,$password);
>
> > @mysql_select_db($database) or die( "Unable to select database");
>
> >
>
> > $id = $_GET['id'];
>
> > $sql = "SELECT id, postdate, title, body FROM NewsContent WHERE id = '$id'";
>
> > $news_query=mysql_query($sql);
>
> > IF ($news_query){
>
> > $r = mysql_fetch_row($news_query);
>
> >
>
> > $title = $r["title"];
>
> > $body = $r["body"];
>
> > }
>
> >
>
> > mysql_close();
>
> > ?>
>
> >
>
> > <div>
>
> > <h2>
>
> > <?
>
> > echo $r["title"];
>
> > ?>
>
> > </h2>
>
> > <div class="modal-nav-links">
>
> > <p><?php echo $r["body"] ?></p>
>
> > <!-- <div style="clear: both;"></div> -->
>
> > </div>
>
> > </div>
>
> >
>
> >
>
> > I was under the impression that this would work, but no dice. Can someone with a bit of experience give me an idea of what I'm doing incorrectly?
>
> >
>
> > Thanks in advance
>
> > Tom
>
> >
>
>
>
> There is a missing 'mysql_select_db()'
>
> http://php.net/manual/en/function.mysql-select-db.php
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2012-09-25 21:04 +0200 |
| Message-ID | <jqb9j9-kni.ln1@luuk.invalid.lan> |
| In reply to | #7153 |
On 25-09-2012 20:17, tom.rankin51@googlemail.com wrote:
> Both sections of code contain 'mysql_select_db() - should it be included a third time?
>
> On Tuesday, September 25, 2012 7:10:02 PM UTC+1, Luuk wrote:
>> On 25-09-2012 19:27, tom.rankin51@googlemail.com wrote:
>>
>>> Hello
>>
>>>
>>
>>> I have a very basic knowledge of PHP and MySQL and sought help from a friend who initially was someone I can turn to but now can't provide me with any help (!) ...and so to Google Groups!
>>
>>>
>>
>>> I am trying to display preview text on a webpage and then after clicking a link it will take you to the full item. It must be quite a simple thing to do, however, I am getting a completely blank page. I get no errors, and I have no syntax errors that I can see so I'm struggling to see what I have done wrongly.
>>
>>>
>>
>>> My code on the main page is :
>>
>>>
>>
>>> <?
>>
>>> include("php/dbinfo.inc.php");
>>
>>>
>>
>>> mysql_connect($hostname,$username,$password);
>>
>>> @mysql_select_db($database) or die( "Unable to select database");
>>
>>>
>>
>>> $mydate=date("Y-m-d",strtotime("-2 weeks"));
>>
>>>
>>
>>> $news_query=mysql_query("SELECT id, postdate, title, SUBSTRING_INDEX(body,' ',20) as preview_text, body FROM NewsContent WHERE postdate > '$mydate' ORDER BY postdate DESC");
>>
>>>
>>
>>> mysql_close();
>>
>>> ?>
>>
>>>
>>
>>> <div>
>>
>>> <ol>
>>
>>> <!-- START OF PHP SCRIPT (NEWS) -->
>>
>>> <?
>>
>>> while($r=mysql_fetch_assoc($news_query)) {
>>
>>> echo '<li id="'.$r["id"].'">';
>>
>>> echo '<h2 class="body-headline">';
>>
>>> echo $r["title"];
>>
>>> echo '</h2>';
>>
>>> echo '<h3 class="date-heading">';
>>
>>> echo date("d-M-Y",strtotime($r["postdate"]));
>>
>>> echo '</h3>';
>>
>>> echo nl2br ($r["preview_text"]);
>>
>>> echo '...<a class="fancybox fancybox.ajax" href="news.php?id='.$r["id"].'">show more</a>';
>>
>>> echo '</li><hr />';
>>
>>> } ?>
>>
>>> <!-- END OF PHP SCRIPT (NEWS) -->
>>
>>> </ol>
>>
>>> </div>
>>
>>>
>>
>>> Note that I'm using a fancybox script, but this happens without using that script also.
>>
>>>
>>
>>> In my news item page I have done the following:
>>
>>>
>>
>>> <?
>>
>>> include("php/dbinfo.inc.php");
>>
>>>
>>
>>> mysql_connect($hostname,$username,$password);
>>
>>> @mysql_select_db($database) or die( "Unable to select database");
>>
>>>
>>
>>> $id = $_GET['id'];
>>
>>> $sql = "SELECT id, postdate, title, body FROM NewsContent WHERE id = '$id'";
>>
>>> $news_query=mysql_query($sql);
>>
>>> IF ($news_query){
>>
>>> $r = mysql_fetch_row($news_query);
>>
>>>
>>
>>> $title = $r["title"];
>>
>>> $body = $r["body"];
>>
>>> }
>>
>>>
>>
>>> mysql_close();
>>
>>> ?>
>>
>>>
>>
>>> <div>
>>
>>> <h2>
>>
>>> <?
>>
>>> echo $r["title"];
>>
>>> ?>
>>
>>> </h2>
>>
>>> <div class="modal-nav-links">
>>
>>> <p><?php echo $r["body"] ?></p>
>>
>>> <!-- <div style="clear: both;"></div> -->
>>
>>> </div>
>>
>>> </div>
>>
>>>
>>
>>>
>>
>>> I was under the impression that this would work, but no dice. Can someone with a bit of experience give me an idea of what I'm doing incorrectly?
>>
>>>
>>
>>> Thanks in advance
>>
>>> Tom
>>
>>>
>>
>>
>>
>> There is a missing 'mysql_select_db()'
>>
>> http://php.net/manual/en/function.mysql-select-db.php
>
aaargh ;)
you did not pos the content of "php/dbinfo.inc.php"
and i missed $database.....
so i got a 'No database selected'... message
sorry...
[toc] | [prev] | [next] | [standalone]
| From | tom.rankin51@googlemail.com |
|---|---|
| Date | 2012-09-25 23:24 -0700 |
| Message-ID | <31ffe251-7a90-4efe-80b8-8f37cc47910e@googlegroups.com> |
| In reply to | #7164 |
So is this worth debugging even though my error logs show nothing?
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2012-09-26 14:03 +0000 |
| Message-ID | <k3v20c$jbm$1@dont-email.me> |
| In reply to | #7180 |
On Tue, 25 Sep 2012 23:24:33 -0700, tom.rankin51 wrote: > So is this worth debugging even though my error logs show nothing? You're error logs might be showing nothing if you use "@" before function calls, as this prevents errors from being logged. Remove any "@" symbols that precede function calls and see if the logs are still empty? It may be that you're looking at the wrong logs - what web server are you using? On my ubuntu server with apache2, the errors turn up in /var/log/apache2/error.log, which seems to be the default as I have nothing specific in /etc/php5/apache2/php.ini to send them anywhere else If you (a) can identify the relevant php config file and (b) have the access needed to edit it, check the settings in the "error handling and logging" section and adjust if appropriate. If you need guidance, don't post the whole section, just post the current settings. Also post details of OS and server (eg linux/suse + apache2 or windows XP server + IIS etc) Rgds Denis McMahon
[toc] | [prev] | [next] | [standalone]
| From | Captain Paralytic <paul_lautman@yahoo.com> |
|---|---|
| Date | 2012-09-26 05:05 -0700 |
| Message-ID | <ea6b267c-bfca-4253-91c2-a72ccf1817b3@hj1g2000vbb.googlegroups.com> |
| In reply to | #7147 |
On Sep 25, 6:27 pm, tom.ranki...@googlemail.com wrote:
> Hello
>
> I have a very basic knowledge of PHP and MySQL and sought help from a friend who initially was someone I can turn to but now can't provide me with any help (!) ...and so to Google Groups!
>
> I am trying to display preview text on a webpage and then after clicking a link it will take you to the full item. It must be quite a simple thing to do, however, I am getting a completely blank page. I get no errors, and I have no syntax errors that I can see so I'm struggling to see what I have done wrongly.
>
> My code on the main page is :
>
> <?
> include("php/dbinfo.inc.php");
>
> mysql_connect($hostname,$username,$password);
> @mysql_select_db($database) or die( "Unable to select database");
>
> $mydate=date("Y-m-d",strtotime("-2 weeks"));
>
> $news_query=mysql_query("SELECT id, postdate, title, SUBSTRING_INDEX(body,' ',20) as preview_text, body FROM NewsContent WHERE postdate > '$mydate' ORDER BY postdate DESC");
>
> mysql_close();
> ?>
>
> <div>
> <ol>
> <!-- START OF PHP SCRIPT (NEWS) -->
> <?
> while($r=mysql_fetch_assoc($news_query)) {
> echo '<li id="'.$r["id"].'">';
> echo '<h2 class="body-headline">';
> echo $r["title"];
> echo '</h2>';
> echo '<h3 class="date-heading">';
> echo date("d-M-Y",strtotime($r["postdate"]));
> echo '</h3>';
> echo nl2br ($r["preview_text"]);
> echo '...<a class="fancybox fancybox.ajax" href="news.php?id='.$r["id"].'">show more</a>';
> echo '</li><hr />';
> } ?>
> <!-- END OF PHP SCRIPT (NEWS) -->
> </ol>
> </div>
>
> Note that I'm using a fancybox script, but this happens without using that script also.
>
> In my news item page I have done the following:
>
> <?
> include("php/dbinfo.inc.php");
>
> mysql_connect($hostname,$username,$password);
> @mysql_select_db($database) or die( "Unable to select database");
>
> $id = $_GET['id'];
> $sql = "SELECT id, postdate, title, body FROM NewsContent WHERE id = '$id'";
> $news_query=mysql_query($sql);
> IF ($news_query){
> $r = mysql_fetch_row($news_query);
>
> $title = $r["title"];
> $body = $r["body"];
> }
>
> mysql_close();
> ?>
>
> <div>
> <h2>
> <?
> echo $r["title"];
> ?>
> </h2>
> <div class="modal-nav-links">
> <p><?php echo $r["body"] ?></p>
> <!-- <div style="clear: both;"></div> -->
> </div>
> </div>
>
> I was under the impression that this would work, but no dice. Can someone with a bit of experience give me an idea of what I'm doing incorrectly?
>
> Thanks in advance
> Tom
You haven't got any php in your files. In order for the contents of a
file to be parsed as php, it must be within a pair of php open/close
tags. The php open tag is <?php and the closing one is ?>
Since you have no <?php tag, you have no php to be parsed.
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-09-26 11:16 -0400 |
| Message-ID | <k3v68r$rbu$1@dont-email.me> |
| In reply to | #7184 |
On 9/26/2012 8:05 AM, Captain Paralytic wrote:
> On Sep 25, 6:27 pm, tom.ranki...@googlemail.com wrote:
>> Hello
>>
>> I have a very basic knowledge of PHP and MySQL and sought help from a friend who initially was someone I can turn to but now can't provide me with any help (!) ...and so to Google Groups!
>>
>> I am trying to display preview text on a webpage and then after clicking a link it will take you to the full item. It must be quite a simple thing to do, however, I am getting a completely blank page. I get no errors, and I have no syntax errors that I can see so I'm struggling to see what I have done wrongly.
>>
>> My code on the main page is :
>>
>> <?
>> include("php/dbinfo.inc.php");
>>
>> mysql_connect($hostname,$username,$password);
>> @mysql_select_db($database) or die( "Unable to select database");
>>
>> $mydate=date("Y-m-d",strtotime("-2 weeks"));
>>
>> $news_query=mysql_query("SELECT id, postdate, title, SUBSTRING_INDEX(body,' ',20) as preview_text, body FROM NewsContent WHERE postdate > '$mydate' ORDER BY postdate DESC");
>>
>> mysql_close();
>> ?>
>>
>> <div>
>> <ol>
>> <!-- START OF PHP SCRIPT (NEWS) -->
>> <?
>> while($r=mysql_fetch_assoc($news_query)) {
>> echo '<li id="'.$r["id"].'">';
>> echo '<h2 class="body-headline">';
>> echo $r["title"];
>> echo '</h2>';
>> echo '<h3 class="date-heading">';
>> echo date("d-M-Y",strtotime($r["postdate"]));
>> echo '</h3>';
>> echo nl2br ($r["preview_text"]);
>> echo '...<a class="fancybox fancybox.ajax" href="news.php?id='.$r["id"].'">show more</a>';
>> echo '</li><hr />';
>> } ?>
>> <!-- END OF PHP SCRIPT (NEWS) -->
>> </ol>
>> </div>
>>
>> Note that I'm using a fancybox script, but this happens without using that script also.
>>
>> In my news item page I have done the following:
>>
>> <?
>> include("php/dbinfo.inc.php");
>>
>> mysql_connect($hostname,$username,$password);
>> @mysql_select_db($database) or die( "Unable to select database");
>>
>> $id = $_GET['id'];
>> $sql = "SELECT id, postdate, title, body FROM NewsContent WHERE id = '$id'";
>> $news_query=mysql_query($sql);
>> IF ($news_query){
>> $r = mysql_fetch_row($news_query);
>>
>> $title = $r["title"];
>> $body = $r["body"];
>> }
>>
>> mysql_close();
>> ?>
>>
>> <div>
>> <h2>
>> <?
>> echo $r["title"];
>> ?>
>> </h2>
>> <div class="modal-nav-links">
>> <p><?php echo $r["body"] ?></p>
>> <!-- <div style="clear: both;"></div> -->
>> </div>
>> </div>
>>
>> I was under the impression that this would work, but no dice. Can someone with a bit of experience give me an idea of what I'm doing incorrectly?
>>
>> Thanks in advance
>> Tom
>
> You haven't got any php in your files. In order for the contents of a
> file to be parsed as php, it must be within a pair of php open/close
> tags. The php open tag is <?php and the closing one is ?>
>
> Since you have no <?php tag, you have no php to be parsed.
>
He's probably using short_open_tags, Paul. Another bad habit he needs
to break.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web