Topic: PHP Core Block Accessing Mysql
bsnoblen
avatar
Freshman
Freshman
Posts: 2

Posted:
13.May 2006 - 01:04

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?
Simon
online
avatar
Steering Committee
Steering Committee
Posts: 13427

Posted:
13.May 2006 - 01:34

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
bsnoblen
avatar
Freshman
Freshman
Posts: 2

Posted:
15.May 2006 - 18:22

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