Jump to content

Browser RSS Newsfeed Inconsistencies Using MySQL Database and PHP files


light87

Recommended Posts

Hello:

 

I have a test website that creates an RSS feed from PHP coding and a MySQL database.

 

I have noticed some inconsistencies across 3 major browsers and would like to know if

 

anybody can help me out.  I don't know if the problems are due to bad Browser Design(s)

 

and/or possible coding errors in my files.

 

 

 

I used these six files:

 

Aliensaway675_Database_TableSetup_aliens_abduction_Chapter12_Page675.sql

 

index.php

 

X_Database_Chapter12_Page675_connectvars_final.php

 

 

X_Database_Chapter12_Page675_newsfeed_final.php

 

 

X_Database_Chapter12_Page675_report_final.php

 

 

X_Database_Chapter12_Page675_style_final.css

 

I noticed different Browser behaviors for the newsfeed. More specifically, I pasted the following

 

URL into the Internet Explorer 9, Mozilla version 11.0, and Opera version 11.61 browsers:

 

 

http://www.cheapcostdiamonds.com/X_Database_Chapter12_Page675_newsfeed_final.php

 

 

Again, this is a test site (I am not trying to sell anything). I then went directly into my GoDaddy's MySQL database

 

after adding a few reports and deleted a few reports until there were 5 sightings left for the feed (i.e. 5 records in the MySQL database).

 

I refreshed the database in GoDaddy, then refreshed all three browsers and noticed some differences.

 

These are shown in the 3 screenshots that I attached. More specifically:

 

1) IE9 showed more results in the feed that should have been (there are 6, there should only be 5). The "Aliens Abducted Me - Newsfeed" is a

 

 

clickable link (which is what we want it to be).

 

2) Mozilla showed "Aliens Abducted Me - Newsfeed", but it is not clickable. It does show the correct number of sightings.

 

3) Opera showed "Aliens Abducted Me - Newsfeed", but it is not clickable. It does show the correct number of sightings.

 

My question to the community is:

 

Are these differences due to the lack of consistencies in the Browser designs or did I make errors in the files?

 

 

 

 

The sql file is:

 

CREATE TABLE `aliens_abduction` ( 
  `abduction_id` INT AUTO_INCREMENT,
  `first_name` VARCHAR(30), 
  `last_name` VARCHAR(30), 
  `when_it_happened` DATE, 
  `how_long` VARCHAR(30), 
  `how_many` VARCHAR(30), 
  `alien_description` VARCHAR(100), 
  `what_they_did` VARCHAR(100), 
  `fang_spotted` VARCHAR(10), 
  `other` VARCHAR(100), 
  `email` VARCHAR(50), 
  PRIMARY KEY (`abduction_id`) 
);

INSERT INTO `aliens_abduction` VALUES (1, 'Alf', 'Nader', '2000-07-12', 'one week', 'at least 12', 'It was a big non-recyclable shiny disc full of what appeared to be mutated labor union officials.', 'Swooped down from the sky and snatched me up with no warning.', 'no', 'That\'s it.', 'ralph@nader.com'); 
INSERT INTO `aliens_abduction` VALUES (2, 'Don', 'Quayle', '1991-09-14', '37 seconds', 'dunno', 'They looked like donkeys made out of metal with some kind of jet packs attached to them.', 'I was sitting there eating a baked potatoe when "Zwoosh!", this beam of light took me away.', 'yes', 'I really do love potatos.', 'dq@iwasvicepresident.com'); 
INSERT INTO `aliens_abduction` VALUES (3, 'Rick', 'Nixon', '1969-01-21', 'nearly 4 years', 'just one', 'They were pasty and pandering, and not very forgiving.', 'Impeached me, of course, then they probed me.', 'no', 'I\'m lonely.', 'rnixon@not'); 
INSERT INTO `aliens_abduction` VALUES (4, 'Belita', 'Chevy', '2008-06-21', 'almost a week', '27', 'Clumsy little buggers, had no rhythm.', 'Tried to get me to play bad music.', 'no', 'Looking forward to playing some Guitar Wars now that I\'m back.', 'belitac@rockin.net'); 
INSERT INTO `aliens_abduction` VALUES (5, 'Sally', 'Jones', '2008-05-11', '1 day', 'four', 'green with six tentacles', 'We just talked and played with a dog', 'yes', 'I may have seen your dog. Contact me.', 'sally@gregs-list.net'); 
INSERT INTO `aliens_abduction` VALUES (6, 'Meinhold', 'Ressner', '2008-08-10', '3 hours', 'couldn\'t tell', 'They were in a ship the size of a full moon.', 'Carried me to the top of a mountain and dropped me off.', 'no', 'Just want to thank those fellas for helping me out.', 'meinhold@icanclimbit.com'); 
INSERT INTO `aliens_abduction` VALUES (7, 'Mickey', 'Mikens', '2008-07-11', '45 minutes', 'hundreds', 'Huge heads, skinny arms and legs', 'Read my mind,', 'yes', 'I\'m thinking about designing a helmet to thwart future abductions.', 'mickey@stopreadingmymind.net'); 
INSERT INTO `aliens_abduction` VALUES (8, 'Shill', 'Watner', '2008-07-05', '2 hours', 'don\'t know', 'There was a bright light in the sky, followed by a bark or two.', 'They beamed me toward a gas station in the desert.', 'yes', 'I was out of gas, so it was a pretty good abduction.', 'shillwatner@imightbecaptkirk.com');

 

The code for X_Database_Chapter12_Page675_connectvars_final.php is:

 

<?php

  //3,08,12
  //Filename:C:,HeadFirst_PHP_MYSQL,Chapter12,
  //X_Database_Chapter12_Page675_connectvars_final.php

  // Define database connection constants 
  define('DB_HOST', 'KEPTPRIVATE');


  define('DB_USER', 'KEPTPRIVATE');


  define('DB_PASSWORD', 'KEPTPRIVATE');


  define('DB_NAME', 'KEPTPRIVATE'); 
?>





 

The code for X_Database_Chapter12_Page675_newsfeed_final.php is:

 

<?php header('Content-Type: text/xml'); ?><?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?><rss version="2.0"> 
  <channel> 
    <title>Aliens Abducted Me - Newsfeed</title>

    <link>http://www.cheapcostdiamonds.com/</link> 
    <description>Alien abduction reports from around the world courtesy of Owen and his abducted dog Fang.</description> 
    <language>en-us</language>




<?php 
  require_once('X_Database_Chapter12_Page675_connectvars_final.php'); 


  //2,4,10
  //Filename:C:,HeadFirst_PHP_MYSQL,Chapter12,
  //X_Database_Chapter12_Page675_newsfeed_final.php
  // Connect to the database 
  $dbc = mysqli_connect('DB_HOST', 'DB_USER', 'DB_PASSWORD', 'DB_NAME'); 


  // Retrieve the alien sighting data from MySQL 
  $query = "SELECT abduction_id, first_name, last_name, DATE_FORMAT(when_it_happened,'%a, %d %b %Y %T') AS when_it_happened_rfc, " . "alien_description, what_they_did FROM aliens_abduction ORDER BY when_it_happened DESC"; 

  $data = mysqli_query($dbc, $query); 
  // Loop through the array of alien sighting data, formatting it as RSS 
  while ($row = mysqli_fetch_array($data)) { 
    // Display each row as an RSS item 
    echo '<item>'; 

    echo '  <title>' . $row['first_name'] . ' ' . $row['last_name'] . ' - ' . substr($row['alien_description'], 0, 32) . '...</title>'; 

    echo '  <link>http://www.cheapcostdiamonds.com/index.php?abduction_id=' . $row['abduction_id'] . '</link>'; 

    echo '  <pubDate>' . $row['when_it_happened_rfc'] . ' ' . date('T') . '</pubDate>'; 

    echo '  <description>' . $row['what_they_did'] . '</description>'; 

    echo '</item>'; 
  } 


?></channel></rss>

 

 

The code for X_Database_Chapter12_Page675_report_final.php is:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<head> 
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  <title>Aliens Abducted Me - Report an Abduction</title> 
  <link rel="stylesheet" type="text/css" href="X_Database_Chapter12_Page675_style_final.css" /> 
</head> 

<body> 
  <h2>Aliens Abducted Me - Report an Abduction</h2> 

<?php 
  require_once('X_Database_Chapter12_Page675_connectvars_final.php'); 

  if (isset($_POST['submit'])) { 
    // Connect to the database 
    $dbc = mysqli_connect('DB_HOST', 'DB_USER', 'DB_PASSWORD', 'DB_NAME'); 

    // Grab the report data from the POST 
    $first_name = mysqli_real_escape_string($dbc, trim($_POST['firstname'])); 

    $last_name = mysqli_real_escape_string($dbc, trim($_POST['lastname'])); 

    $email = mysqli_real_escape_string($dbc, trim($_POST['email'])); 

    $when_it_happened = mysqli_real_escape_string($dbc, trim($_POST['whenithappened'])); 

    $how_long = mysqli_real_escape_string($dbc, trim($_POST['howlong'])); 

    $how_many = mysqli_real_escape_string($dbc, trim($_POST['howmany'])); 

    $alien_description = mysqli_real_escape_string($dbc, trim($_POST['aliendescription'])); 

    $what_they_did = mysqli_real_escape_string($dbc, trim($_POST['whattheydid'])); 

    $fang_spotted = mysqli_real_escape_string($dbc, trim($_POST['fangspotted'])); 

    $other = mysqli_real_escape_string($dbc, trim($_POST['other'])); 

    if (!empty($first_name) && !empty($last_name) && !empty($when_it_happened) && !empty($how_long) && !empty($what_they_did)) { 
      // Write the data to the database 
      $query = "INSERT INTO aliens_abduction (first_name, last_name, email, when_it_happened, how_long, how_many, alien_description, what_they_did, fang_spotted, other) " . "VALUES ('$first_name', '$last_name', '$email', '$when_it_happened', '$how_long', '$how_many', '$alien_description', '$what_they_did', '$fang_spotted', '$other')"; 

      mysqli_query($dbc, $query); 

      // Confirm success with the user 
      echo '<p>Thanks for adding your abduction.</p>';

      echo '<p><a href="index.php"><< Back to the home page</a></p>'; 

      mysqli_close($dbc); 

      exit(); 
    } 
    else { 
      echo '<p class="error">Please enter your full name, date of abduction, how long you were abducted, and a brief description of the aliens.</p>'; 
    } 
  } 

?> 

<p>Share your story of alien abduction:</p>



<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

  <label for="firstname">First name:</label>

  <input type="text" id="firstname" name="firstname" value="<?php if (!empty($first_name)) echo $first_name; ?>" /><br />

  <label for="lastname">Last name:</label>

  <input type="text" id="lastname" name="lastname" value="<?php if (!empty($first_name)) echo $last_name; ?>" /><br />


  <label for="email">What is your email address?</label>


  <input type="text" id="email" name="email" value="<?php if (!empty($email)) echo $email; ?>" /><br /> 

  <label for="whenithappened">When did it happen?</label> 

  <input type="text" id="whenithappened" name="whenithappened" value="<?php if (!empty($when_it_happened)) echo $when_it_happened; else echo 'YYYY-MM-DD'; ?>" /><br /> 

  <label for="howlong">How long were you gone?</label>


  <input type="text" id="howlong" name="howlong" value="<?php if (!empty($how_long)) echo $how_long; ?>" /><br /> 

  <label for="howmany">How many did you see?</label> 

  <input type="text" id="howmany" name="howmany" value="<?php if (!empty($how_many)) echo $how_many; ?>" /><br /> 

  <label for="aliendescription">Describe them:</label> 

  <input type="text" id="aliendescription" name="aliendescription" size="32" value="<?php if (!empty($alien_description)) echo $alien_description; ?>" /><br /> 

  <label for="whattheydid">What did they do to you?</label> 

  <input type="text" id="whattheydid" name="whattheydid" size="32" value="<?php if (!empty($what_they_did)) echo $what_they_did; ?>" /><br />


  <label for="fangspotted">Have you seen my dog Fang?</label> 

  Yes <input id="fangspotted" name="fangspotted" type="radio" value="yes" <?php echo ($fang_spotted == 'yes' ? 'checked="checked"' : ''); ?> /> 

  No <input id="fangspotted" name="fangspotted" type="radio" value="no"  <?php echo ($fang_spotted == 'no' ? 'checked="checked"' : ''); ?> /><br />

    <img src="fang.jpg" width="100" height="175" alt="My abducted dog Fang." /><br /> 

    <label for="other">Anything else you want to add?</label> 


    <textarea id="other" name="other"> 

<?php 

  if (!empty($other)) echo $other; 

?>

    </textarea><br /> 

  <input type="submit" value="Report Abduction" name="submit" />


</form>


</body>


</html>

 

The code for X_Database_Chapter12_Page675_style_final.css is:

 

/* Filename:C:,HeadFirst_PHP_MYSQL,Chapter12, X_Database_Chapter12_Page675_style_final.css */
.error { 
  font-weight:bold; 
  color:#FF0000; 
} 

table { 
  border:1px solid #DDDDDD; 
  border-collapse:collapse; 
} 

tr.heading { 
  font-size:large; 
  color:#006600; 
} 

td { 
  border:1px solid #DDDDDD; 
} 

form label { 
  display:inline-block; 
  width:225px; 
  font-weight:bold; 
} 

a { 
  text-decoration:none; 
  font-weight:bold; 
} 

a:link { 
  color:#006600; 
} 

a:hover { 
  background-color:#EEEEEE; 
} 

a:visited { 
  color:#002200; 
} 

a:active { 
  color:#009900; 
}

 

 

 

I have 4 attachments.

post-90989-13482403318928_thumb.png

post-90989-13482403319723_thumb.png

post-90989-13482403320523_thumb.png

17822_.php

Link to comment
Share on other sites

First, you have to understand that how the feeds are displayed is outside of your control. You can provide as much information as you want but the ultimate display of the feed will vary. If one includes links and one doesn't then that's how it is.

 

But I did notice your items don't have s. Throw those in.

url here

And everything that can be text needs to be htmlspecialchar()ed if it isn't already.

 

As for IE showing six, could it be remembering one of the items it saw earlier?

Link to comment
Share on other sites

Thanks for the reply!

 

There is probably a design problem with IE9.  I changed the setting for how frequently IE9 updates feeds to 15 minutes and loaded the following URL into the IE9, Mozilla, and Opera browsers and refreshed all of them several times during the last day or so.  IE9 still shows 6 items instead of the 5 that are shown in Mozilla and Opera.  The URL is:

 

http://www.cheapcostdiamonds.com/X_Database_Chapter12_Page675_newsfeed_final.php

 

Maybe I should write a letter to Microsoft?

Link to comment
Share on other sites

The problems with this feed are mostly solved.  I fixed the problems with Google Chrome, Mozilla and Opera by getting the RSS feed subscription extension for each one.  I still can't get IE9 to work properly, and decided that it is a problem with their browser design (the problem with IE9 is that it shows 1 too many listings).  If anybody knows how to fix the problem with IE9 please let me know.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.