FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Dynamic Links (MySQL/PHP)
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Dynamic Links (MySQL/PHP) [message #179224 is a reply to message #179222] Tue, 25 September 2012 18:17 Go to previous messageGo to previous message
tom.rankin51 is currently offline  tom.rankin51
Messages: 17
Registered: September 2012
Karma:
Junior Member
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(dot)rankin51(at)googlemail(dot)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
[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
Previous Topic: Updating Zend 5.0 to use PHP 5.3.9
Next Topic: Multiple <a> Tags, Filled With MySQL DB data with PHP
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 03:52:43 GMT 2024

Total time taken to generate the page: 0.06560 seconds