php-general Digest 10 Nov 2007 12:40:45 -0000 Issue 5120

Topics (messages 264292 through 264296):

My first xml try
        264292 by: Ronald Wiplinger
        264295 by: Andrew Ballard

Re: debugging imap_open
        264293 by: John Gunther

Re: Local vs Master Configure values
        264294 by: Nathan Nobbe

explorer
        264296 by: kNish

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
I must use php 4 and mysql 4.x !

I tried an example I found on the net and modified it so that it should
work with php4 and mysql 4. The code is below.
I need to access a database and get an xml feed output.
I tried to use echo statements for debugging and found that it seems I
do not get the information of require().

What do I need to change?

bye

Ronald

|<?
    header("Content-Type: application/xml; charset=ISO-8859-1");

class RSS
{
    function RSS()
    {
        require("../mysyql-config");
    }
    
    function GetFeed()
    {
        return $this->getDetails() . $this->getItems();
    }
    
    
    function getDetails()
    {
        $detailsTable = "webref_rss_details";
        $query = "SELECT * FROM ". $detailsTable;
        $db = mysql_connect($dbhost, $dbuname, $dbpass);
        mysql_select_db($dbname,$db);
        $result = mysql_query($query, $db);
//    echo "dbhost=$dbhost<br>dbuname=$dbuname";
        while($myrow = mysql_fetch_array($result))
        {
            $details = '<?xml version="1.0" encoding="utf-8" ?>
                    <rss version="2.0">
                        <channel>
                            <title>'. $myrow['title'] .'</title>
                            <link>'. $myrow['link'] .'</link>
                            <description>'. $myrow['description']
.'</description>
                            <language>'. $myrow['language'] .'</language>
                            <image>
                                <title>'. $myrow['image_title'] .'</title>
                                <url>'. $myrow['image_url'] .'</url>
                                <link>'. $myrow['image_link'] .'</link>
                                <width>'. $myrow['image_width'] .'</width>
                                <height>'. $myrow['image_height']
.'</height>
                            </image>';
        }
        return $details;
    }
    
    function getItems()
    {
        $itemsTable = "webref_rss_items";
        $query = "SELECT * FROM ". $itemsTable;
        $db = mysql_connect($dbhost, $dbuname, $dbpass);
        mysql_select_db($dbname,$db);
        $result = mysql_query ($query, $db);
        $items = '';
        while($myrow = mysql_fetch_array($result))
        {
            $items .= '<item>
                         <title>'. $myrow["title"] .'</title>
                         <link>'. $myrow["link"] .'</link>
                         <description><![CDATA['. $myrow["description"]
.']]></description>
                     </item>';
        }
        $items .= '</channel>
                 </rss>';
        return $items;
    }

}

    $rss = new RSS();
    echo $rss->GetFeed();
?>
|

--- End Message ---
--- Begin Message ---
Ronald,

On Nov 9, 2007 9:05 PM, Ronald Wiplinger <[EMAIL PROTECTED]> wrote:
> I tried to use echo statements for debugging and found that it seems I
> do not get the information of require().
>
> What do I need to change?

I'm not sure what error you're getting, but I would guess it can't
find the required file because mysql-config is spelled wrong in the
constructor for the class that you posted. It also looks like you are
using variables $dbname, $dbhost, $dbuname in your functions, but I
don't see how those variables could be defined. Even if you declare
them global in the constructor function, I'm pretty sure they would be
out of scope in any of your other functions.

I am guessing that your table webref_rss_details must only have one
row in it, because the block of XML you are outputing in getDetails()
is definitely something you only want to send once. Also, if you
aren't using any of the XML writers or DOM libraries to build your
document, you should account for the possibility of invalid XML
characters like ", <, >, and & in the content that you are writing and
make sure they are converted to the appropriate entities.

Andrew

--- End Message ---
--- Begin Message --- Since no one seems to know about the debug feature, let me ask about the imap argument directly. None of the following work, always "Couldn't open stream":
mail.usservas.org:143
mail.usservas.org:110
mail.usservas.org:143/imap
mail.usservas.org:110/pop3
mail.usservas.org:143/imap/notls
mail.usservas.org:110/pop3/notls
mail.usservas.org:143/imap/ssl/novalidate-cert
mail.usservas.org:110/pop3/ssl/novalidate-cert

The only mention of imap in phpinfo() is in the "imap" section:
IMAP c-Client Version   2001
SSL Support     enabled
Kerberos Support        enabled

I can manually log in to pop3 and imap through telnet, so I'm at a loss. Am I leaving something important out? I'm running PHP 5.2.1 on Apache 2.0

John

John Gunther wrote:
I'm trying to use imap functions for the first time and always get "Couldn't open stream" errors so I turned on both kinds of debugging. Unfortunately I can't find debugging output anywhere. What am I doing wrong? Here's my code:

ini_set('error_log','/tmp/imap.txt');
$po='{mail.usservas.org:143/debug}';
$mbox = imap_open($po, $user, $password ,OP_DEBUG);


Thanks for the help.

John Gunther

--- End Message ---
--- Begin Message ---
On 11/9/07, tedd <[EMAIL PROTECTED]> wrote:
>
> The only question that remains for me is what's the difference
> between Local and Master Configure values in php_info? Why two?


as i mentioned the local column is for overrides that can be specified in
one of several locations:
httpd.conf
.htaccess file
code; ini_set()

this is for customization of the global settings in php.ini
typically it is used in shared hosting environments; but i think its a great
solution for multi-developer environments as well.
developers can have custom configurations; say debuggers / profilers
include paths etc.

check out my small article about setting up .htaccess if you want.
http://gentoo-wiki.com/HOWTO_php.ini_overrides_w/_.htaccess

-nathan

--- End Message ---
--- Begin Message ---
Hi,

           How if, it is possible to open a windows explorer with a
path specified in it, thru a php script.

 BRgds,

kNish

--- End Message ---

Reply via email to