Parašė Daslee· 2011 Rugs. 12 21:09:10
#1
Gal kas žinote kaip būtų galima padaryti automatini šaukyklos atnaujinima kas kelias sekundes su java? Pas manes šaukykla veikia su
mysql databaze, ten visos žinutės yra. Ir nežinau kaip padaryti, kad java prisijungtu prie
mysql ir atsiustu viska kaip
php. Mano
PHP šaukyklos kodas, kai užsikrauna tinklapis:
<?php
session_start();
$con = mysql_connect("IP","root", "pass") or die (mysql_error());
$db = mysql_select_db("gameserver_betax", $con);
?>
<?php
if(isset ($_SESSION['uid'])) {
if(isset($_POST['submit'])){
$mesg = $_POST['message'];
if($mesg){
if(strlen($mesg) < 256){
$sql = "INSERT INTO shoutbox VALUES ('".mysql_insert_id()."', '".$_SESSION['uid']."', '".$mesg."', '".date("Y-m-d")."')";
$res = mysql_query($sql) or die(mysql_error());
echo "Message sent!";
}else{
echo "Message length must be more than 1 character and no more than 255 characters!<br>";
}
}else{
echo "Cannot send empty message!";
}
echo "<form action='shoutbox.php' method='post'>";
echo "<input type='text' name='message' style='width: 134px;'> <input type='submit' name='submit' value='Send'>";
echo "</form>";
$sql = "SELECT * FROM shoutbox ORDER BY msgid DESC LIMIT 10";
$res = mysql_query($sql) or die(mysql_error());
echo "<div class='shoutbox'>";
while($row = mysql_fetch_assoc($res)){
echo "<b>".$row['sender']."</b><br>".$row['message']."<br><br>";
}
echo "</div>";
}else{
echo "<form action='shoutbox.php' method='post'>";
echo "<input type='text' name='message' style='width: 134px;'> <input type='submit' name='submit' value='Send'>";
echo "</form>";
$sql = "SELECT * FROM shoutbox ORDER BY msgid DESC LIMIT 10";
$res = mysql_query($sql) or die(mysql_error());
echo "<div class='shoutbox'>";
while($row = mysql_fetch_assoc($res)){
echo "<b>".$row['sender']."</b><br>".$row['message']."<br><br>";
}
echo "</div>";
}
}else{
echo "You are not logged in. Please <a href='accmgr.php'>login</a>!";
}
?>
Ir kaip šitokius kodus padaryti java scripte? Arba gal kaip nors java gali valdyti
php funkcijas? Tada padaryčiau, kad visas tas atnaujinimas butu: function Loadchat()
Redagavo Daslee· 2011 Rugs. 12 21:09:07