dialup admin coding - help required
Ok I have tried and tried to get this to work how I want but obviously need more sleep, not being a code genius and trying to learn this mix and mash is confusing enough. Anyway this is my code for my failed login page, my sql query does parse all information into the array ok but I just cannot seem to get it to output on screen. Any way here is what I have so far anyone able to assist in showing me where I'm going wrong. <?php require('../conf/config.php3'); ?> <html> <?php if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3")) include_once("../lib/sql/drivers/$config[sql_type]/functions.php3"); else{ echo <<<EOM <title>Failed logins</title> <link rel="stylesheet" href="style.css"> </head> <body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black"> <center> <b>Could not include SQL library functions. Aborting</b> </body> </html> EOM; exit(); } $now = time(); $start = $now - ($last*60); $now_str = date($config[sql_full_date_format],$now); $prev_str = date($config[sql_full_date_format],$start); ?> <head> <title>Failed Logins</title> <link rel="stylesheet" href="style.css"> </head> <body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black"> <center> <table border=0 width=550 cellpadding=0 cellspacing=0> <tr valign=top> <td align=center><img src="images/title2.gif"></td> </tr> </table> <table border=0 width=400 cellpadding=0 cellspacing=2> </table> <br> <table border=0 width=840 cellpadding=1 cellspacing=1> <tr valign=top> <td width=65%></td> <td bgcolor="black" width=35%> <table border=0 width=100% cellpadding=2 cellspacing=0> <tr bgcolor="#907030" align=right valign=top><th> <font color="white">Failed Logins</font> </th></tr> </table> </td></tr> <tr bgcolor="black" valign=top><td colspan=2> <table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top> <tr><td> <?php echo <<<EOM EOM; ?> <p> <table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top> <tr bgcolor="#d0ddb0"> <th>#</th><th>login</th><th>Password</th><th>Time</th><th>Terminate cause</th><th>Caller ID</th> </tr> <?php $link = @da_sql_pconnect($config); $search = @da_sql_query($link,$config, "SELECT id, user,pass,reply,date,callingid FROM radpostauth ORDER BY date;"); $num = 0; *// Here is where my array collects the records - This is working *// while( $row = @da_sql_fetch_array($search,$config) ){ $num++; $acct_login = $row[user]; $acct_password = $row[pass]; $acct_terminate_cause = $row[reply]; $acct_time = $row[date]; $acct_callingid = $row[callingid]; } ?> *// Here is my screen output, obviously I need to loop through the array and output the lines but just can't figure it out. *// <tr align=center bgcolor="white"> <td>$num</td> <td>$acct_login</td> <td>$acct_password</td> <td>$acct_time</td> <td>$acct_terminate_cause</td> <td>$acct_callingid</td> </tr> </table> </td></tr><tr><td> </td></tr> </table></td></tr></form> </table> </tr> </table> </body> </html>
I don't have an environment to test this, and, I'm no PHP expert, but, I've got some similar stuff working, and, I suspect that the changes below might work for you... You can't include PHP variables in HTML text outside of the <? ?> tags and expect them to be interpolated. Generally, it's just easier to use PHP echo statements for things that require variables to be interpolated. Below is an example of your code with this resolved. No guarantees, but, hopefully it points you in the right direction. In case you don't know, pretty good documentation with examples for PHP can be found at www.php.net. Owen
<?php require('../conf/config.php3'); ?> <html> <?php
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3")) include_once("../lib/sql/drivers/$config[sql_type]/functions.php3"); else{ echo <<<EOM <title>Failed logins</title> <link rel="stylesheet" href="style.css"> </head> <body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black"> <center> <b>Could not include SQL library functions. Aborting</b> </body> </html> EOM; exit(); }
$now = time(); $start = $now - ($last*60); $now_str = date($config[sql_full_date_format],$now); $prev_str = date($config[sql_full_date_format],$start);
?>
<head> <title>Failed Logins</title> <link rel="stylesheet" href="style.css"> </head> <body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black"> <center> <table border=0 width=550 cellpadding=0 cellspacing=0> <tr valign=top> <td align=center><img src="images/title2.gif"></td> </tr> </table> <table border=0 width=400 cellpadding=0 cellspacing=2> </table> <br> <table border=0 width=840 cellpadding=1 cellspacing=1> <tr valign=top> <td width=65%></td> <td bgcolor="black" width=35%> <table border=0 width=100% cellpadding=2 cellspacing=0> <tr bgcolor="#907030" align=right valign=top><th> <font color="white">Failed Logins</font> </th></tr> </table> </td></tr> <tr bgcolor="black" valign=top><td colspan=2> <table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top> <tr><td> <?php echo <<<EOM
EOM; ?>
<p> <table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top> <tr bgcolor="#d0ddb0"> <th>#</th><th>login</th><th>Password</th><th>Time</th><th>Terminate cause</th><th>Caller ID</th> </tr>
<?php
$link = @da_sql_pconnect($config);
$search = @da_sql_query($link,$config, "SELECT id, user,pass,reply,date,callingid FROM radpostauth ORDER BY date;"); $num = 0;
*// Here is where my array collects the records - This is working *//
while( $row = @da_sql_fetch_array($search,$config) ){
$num++; $acct_login = $row[user]; $acct_password = $row[pass]; $acct_terminate_cause = $row[reply]; $acct_time = $row[date]; $acct_callingid = $row[callingid];
<!-- Delete the next few lines
}
?>
(to here) -->
*// Here is my screen output, obviously I need to loop through the array and output the lines but just can't figure it out. *//
<!-- Change these lines as follows -->
echo "<tr align=center bgcolor="white">\n"
echo " <td>$num</td>\n" echo " <td>$acct_login</td> echo " <td>$acct_password</td> echo " <td>$acct_time</td> echo " <td>$acct_terminate_cause</td> echo " <td>$acct_callingid</td> echo " </tr>
<!-- Add these lines --> } ?>
</table>
</td></tr><tr><td>
</td></tr> </table></td></tr></form> </table> </tr> </table> </body> </html>
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/ users.html
On 12/21/06, Cory Robson <cory@cmi.net.au> wrote:
Anyway this is my code for my failed login page, my sql query does parse all information into the array ok but I just cannot seem to get it to output on screen. Any way here is what I have so far anyone able to assist in showing me where I'm going wrong.
First, see Owen's reply (which I haven't quoted). I believe he's nailed the issue and his code would most likely work, though I would do it like this: [snip code]
*// Here is my screen output, obviously I need to loop through the array and output the lines but just can't figure it out. *//
<tr align=center bgcolor="white">
<td><?php print $num; ?></td> <td><?php print $acct_login; ?></td> <td><?php print $acct_password; ?></td> <td><?php print $acct_time; ?></td> <td><?php print $acct_terminate_cause; ?></td> <td><?php print $acct_calling; ?></td>
</tr> </table>
[snip code] Both Owen's code and mine should have the same effect, however I've found that the above is sometimes easier to read and "keep track of". And I like to keep my HTML and PHP "blocks" separate as much as possible. -j -- Jeremy L. Gaddis, MCP, GCWN http://www.linuxwiz.net/
participants (3)
-
Cory Robson -
Gaddis, Jeremy L. -
Owen DeLong