Hi phphelp! sorry for very late reply, I got a time now to rewrite this code to pdo, but before that I want to mention that I think there are some errors in this tutorial
[php]
function browse_users() {
…
}
browse_users($start_list);
[/php]
browse_users function passes some kind of arguments when called, but in the function it does not have any arguments indicated, not even default value which gave me notice on my page.
[php]
$content .= ‘
’;
[/php]
also in this line inside “function make_users_table_end()”, it does not pass any kind of $line_count value? or should I set $line_count a default value?
and make_sid() function? I searched about it but php does not have any kind of function called make_sid() is this a custom function?
but anyway here is the code I rewrote in PDO, I only changed “browse_users()” function, the other parts of the code are the same
[php]
function browse_users() {
try{
$dbh = new PDO(‘mysql:host=localhost;dbname=mydb’, ‘username’, ‘password’);
$sql = “SELECT user_id, user_pass, personal_name, family_name, user_group, email_address, DATE_FORMAT(date_created, %Y%m%d) AS member_since FROM user ORDER BY user_id DESC”;
foreach($dbh->query($sql) as $row) {
$content .= '<tr bgcolor="'. get_alt_row_color($line_count). '">';
$content .= '<td class="normalprint"><font
face="Verdana,Arial,sans-serif" size="-1">' ."\n";
$content .= '<a href="user-detail.php'. make_sid()
.'&user_id='. $row[user_id] .'">'. $row[user_id]
.'</a></font></td>
<td class="normalprint"><font face="Verdana,Arial,sans-serif"
size="-1">'. $row[personal_name] .' '. $row[family_name];
$content .= '<td class="normalprint"><font
face="Verdana,Arial,sans-serif" size="-1">' ."\n";
$content .= $row[email_address];
$content .= "</font>\n\t</td>\n";
$content .= '<td class="normalprint"><font
face="Verdana,Arial,sans-serif" size="-1">' ."\n";
$content .= $user_group[$row[user_group]];
$content .= "</font>\n\t</td>\n";
$content .= '<td class="normalprint"><font
face="Verdana,Arial,sans-serif" size="-1">'.
$row[member_since] ."</td>\n";
$content .= "</font>\n\t</td>\n</tr>\n";
$line_count++;
}
$dbh = null;
} catch (PDOException $e) {
print "Error!: ".$e->getMEssage();
exit;
}
[/php]