Solved

Creating an RSS Feed using PHP/Oracle

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
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…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

772 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