Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
PHP Core Block Accessing Mysql
  • Posted: 13.05.2006, 01:04
     
    bsnoblen
    rank:
    Freshman Freshman
    registered:
     May 2006
    Status:
    offline
    last visit:
    15.05.06
    Posts:
    2
    I am tring to create a PHP block that accesses a mysql database, the code the I am using work fine when I run it out side of PostNuke, but when I put it in a block nothing is displayed. Am I not able to do this with a PHP block?
  • Posted: 13.05.2006, 01:34
     
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    online
    Posts:
    13413
    What is the code you are pasting into the block? (minus passwords etc of course)

    --
    Regards,
    Simon

    itbegins.co.uk - Zikula Consulting

    Please read the Support Guide
  • Posted: 15.05.2006, 18:22
     
    bsnoblen
    rank:
    Freshman Freshman
    registered:
     May 2006
    Status:
    offline
    last visit:
    15.05.06
    Posts:
    2
    The code I am using is:

    Code

    $link_id = mysql_connect('localhost', '','');
     if(!$link_id) die(sql_error());
     mysql_select_db(CrosLex);

     $result = mysql_query('SELECT year, name, email FROM webpage_alumni ORDER BY year ASC');
     print <<<END
     
          <table border="0" cellpadding="0" cellspacing="1">
          <tr class="header">
          <td width="40">Year</td>
          <td width="200">Name</td>
          <td width="150">Email</td> </tr>
     end;
     while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
     print <<<END
         <tr>
             <td>$row[year]</td>
             <td>$row[name]</td>
             <td>$row[email]</td></tr>
     end;
     }

     echo   '</table>';

     mysql_free_result($result);
     mysql_close($link_id);




    edited by: bsnoblen, May 15, 2006 - 01:40 PM

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula