Solved

Creating an RSS Feed using PHP/Oracle

Posted on 2011-02-16
2
487 Views
Last Modified: 2012-05-11
I am trying to create an rrs feed using PHP/Oracle. The code/example works perfect with Mysql but it crashes when I try the same code with Oracle. Database connection with Oracle is working fine. I tried so many combinations and codes but nothing works when I try to create RSS.
I have attached the code, 'll greatly appreciate any feedback.

Thanks.

Here's the part that's working fine and shows data. Please help me generate RSS feed. Thanks.
<?php

$conn = oci_connect('UserName', 'Password', 'ServerName/DatabaseName');

// Parse the statement. Note there is no final semi-colon in the SQL statement
$stid = oci_parse($conn, "SELECT * FROM FECapp.Cal_Event where location = 'Michigan' and url is NOT NULL");
$result = oci_execute($stid);

while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
  echo "<br>";
  echo $row['EVENT_NAME'];
  echo "<br>";
  echo $row['LOCATION'];
  echo "<br>";
  echo $row['URL'];
}
?>

Open in new window

0
Comment
Question by:awarraic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
rationalboss earned 500 total points
ID: 34912253
<?php

$conn = oci_connect('UserName', 'Password', 'ServerName/DatabaseName');
if (!$conn) {
	$e = oci_error();   // For oci_connect errors do not pass a handle
    trigger_error(htmlentities($e['message']), E_USER_ERROR);
}
// Parse the statement. Note there is no final semi-colon in the SQL statement
$stid = oci_parse($conn, "SELECT * FROM FECapp.Cal_Event where location = 'Michigan' and url is NOT NULL");
if (!$stid) {
	$e = oci_error();   // For oci_connect errors do not pass a handle
    trigger_error(htmlentities($e['message']), E_USER_ERROR);
}
$result = oci_execute($stid);
if (!$result) {
    $e = oci_error($stid);  // For oci_execute errors pass the statement handle
    print htmlentities($e['message']);
    print "\n<pre>\n";
    print htmlentities($e['sqltext']);
    printf("\n%".($e['offset']+1)."s", "^");
    print  "\n</pre>\n";
} 


while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
  echo "<br>";
  echo $row['EVENT_NAME'];
  echo "<br>";
  echo $row['LOCATION'];
  echo "<br>";
  echo $row['URL'];
}
?>

Open in new window


If you are using < PHP 5.0, use ocierror() instead of oci_error()
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 34920992
Your only problems so far may be in using Oracle, but eventually you will need to know about RSS.  The string your script creates here is not an RSS feed.  RSS is a specialized subset of XML.  You can learn more about the specific tags and formats here:
http://cyber.law.harvard.edu/rss/rss.html
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP: Filling Out/Creating a PDF 29 109
pass foreach data in php into jquery ajax 10 52
Delete image(s) associated with record(s) 16 29
How do I Check for duplicate entries in mysql 15 27
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question