Solved

Creating an RSS Feed using PHP/Oracle

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

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now