Solved

Creating an RSS Feed using PHP/Oracle

Posted on 2011-02-16
2
486 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
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 109

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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…
The viewer will learn how to dynamically set the form action using jQuery.

860 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