Thank you alphaoide, that worked well with a couple touchups. Yes, I hardcoded the database name on creation of the DB...but I will correct that in the real release.
The really weird thing is it still doesn't work. I tried both the old way and the new (with $wpdb) way without enclosing them in functions (making them print to the top of the page), and both outputted EXACTLY the same text.
Here is the old function:
function getData($lastID) {
$sql = "SELECT * FROM wp_liveshoutbox WHERE id > ".$lastID." ORDER BY id ASC LIMIT 60";
$conn = getDBConnection();
$results = mysql_query($sql, $conn);
while ($row = mysql_fetch_array($results)) {
$chat_user_name = $row[2];
$chat_user_text = $row[3];
$chat_user_id = $row[0];
echo $chat_user_id." ---".$chat_user_name." ---".$chat_user_text." ---"; // --- is being used to separate the fields in the output
}
}
And here is the new one.
function getData($lastID) {
global $wpdb;
$sql = "SELECT * FROM wp_liveshoutbox ORDER BY id ASC LIMIT 60";
$results = $wpdb->get_results( $sql);
foreach( $results as $r ) {
$chat_user_name = $r->name;
$chat_user_text = $r->text;
$chat_user_id = $r->id;
echo $chat_user_id." ---".$chat_user_name." ---".$chat_user_text." ---"; // --- is being used to separate the fields in the output
}
}
So it shouldn't be a problem with that part of it.
Here's the other part of the script that deals with this function:
if ($javascript == "yes") { getData($lastID); }
and part of the javascript file:
var GetChaturl = "/wp-content/plugins/live-shoutbox/live-shoutbox.php?javascript=yes";
function receiveChatText() {
if (httpReceiveChat.readyState == 4 || httpReceiveChat.readyState == 0) {
httpReceiveChat.open("GET",GetChaturl + '&lastID=' + lastID + '&rand='+Math.floor(Math.random() * 1000000), true);
httpReceiveChat.onreadystatechange = handlehHttpReceiveChat;
httpReceiveChat.send(null);
}
}
It's very strange considering both functions print the same thing, but when you switch the old for the new, it doesn't work. Any ideas?