@saro78 said:
qui gli apici devono essere singoli non doppi '2008-04-12'
GRAZIE MILLE!!! Per una cavolata del genere sono quasi diventato scemo!!Grazie Ancora!!!!!
@saro78 said:
qui gli apici devono essere singoli non doppi '2008-04-12'
GRAZIE MILLE!!! Per una cavolata del genere sono quasi diventato scemo!!Grazie Ancora!!!!!
Salve a tutti!
Ho un grande problema con il mysql_fetch_array(), mi fa capricci e non capisco dove sto sbagliando.
Di seguito posto il codice:
 $lastmonth =date("m")-1;
 if($lastmonth < 10){
 $date="0$lastmonth";}
 else {
 $date="$lastmonth";
 }
$Y=date("Y");
$d=date("d");
$last_m="$Y-$date-$d";
echo $last_m; ?><br><?
$sql = 'SELECT * FROM games WHERE SUBSTRING(time,1,10) < "'.$last_m.'" LIMIT 1';
echo $sql; ?><br><?
$old_game = single_qry($sql);
echo $old_game; ?><br><?
if(mysql_num_rows($old_game)==0)
{
echo mysql_num_rows($old_game);     ?><br><?
echo "nulla da eliminare";    ?><br><?
}
else
{
$game = mysql_fetch_array($old_game);
echo $game  ?><br><?
$id= $game['id'];
$r= "DROP TABLE game_".$id."";
$rd= single_qry($r);
$s= "DROP TABLE gamechat_".$id."";
$sd= single_qry($s);
$sdl = "DELETE FROM games WHERE id= ".$id." LIMIT 1";
$dosdl = single_qry($sdl);
echo "ho eliminato la partita di id= ".$id.""; ?><br><?
}
In pratica seleziona una partita che è ferma da un mese dal database, e fino qui funziona...ma quando voglio prendere l'id della partita tramite mysql_fetch_array() mi restituisce errore.
Ecco cosa mi restituisce:
2008-04-12
SELECT * FROM games WHERE SUBSTRING(time,1,10) < "2008-04-12" LIMIT 1
Resource id #7
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ...line 38
Ciao a tutti,
Sto cercando di integrare netrisk (board game opensource) a smf. Iniziava a funzionare ma ora mi sono bloccato.
Se clicco su una partita mi dice:
Fatal error: Call to undefined function: get_assoc() in C:\WM\www\smfrisk\login.php on line **33
la linea interessata è la seguente (la seconda):
[php]
$sql = "SELECT id,player,host,state,password,color,email FROM {$db_prefix}game_$id WHERE player = '{$name}'";
$playerinfo = get_assoc($sql);[/php]
questo è il codice per intero del login.php:
**[php]<?php
// Load the settings...
require_once(dirname(FILE) . '/Settings.php');
require_once('includes/functions.php');
include("includes/langconfig.php");
// And important includes.
//require_once($sourcedir . '/QueryString.php');
//require_once($sourcedir . '/Subs.php');
//require_once($sourcedir . '/Errors.php');
//require_once($sourcedir . '/Load.php');
//require_once($sourcedir . '/Security.php');
// Get GET and POST variables
$id = $_GET['id'];
$name = $user_settings['memberName'];
$password = $_REQUEST['hash_passwrd'];
$player_rank = $_SESSION['player_rank'];
// Check for name and pass or else go back to join screen
/if (isset($user_settings['memberName'])){
index_error_header($trad['MUST_LOGIN']);
exit;
}
if(!isset($id)){ // make sure i get an id or else go to index
index_error_header($trad['MUST_LOGGED']);
exit;
}/
// Get all the player info
$sql = "SELECT id,player,host,state,password,color,email FROM {$db_prefix}game_$id WHERE player = '{$name}'";
$playerinfo = get_assoc($sql);
// Get last most recent timestamp
$sql = "SELECT timestamp FROM {$db_prefix}game_$id ORDER BY 'timestamp' DESC LIMIT 1";
$timestamp = get_one($sql);
//Check username (redundancy)
if($playerinfo['player'] != $name){
joingame_error_header($trad['LOGIN_FAILED']);
exit;
}
//WM: end my code
// Get game name
$sql = "SELECT name,timelimit FROM {$db_prefix}games WHERE id = $id";
$result = mysql_query($sql) or die('Could not get game name(login) :'.mysql_error());
$game_name = get_assoc($sql);
// Remove any previous Session data
session_name("netrisk_$gamename");
session_start();
// Unset session data
$_SESSION=array();
// Clear cookie
unset($_COOKIE[session_name()]);
// Destroy session data
session_destroy();
// Initialize the Session
session_name("netrisk_$gamename");
session_start();
// ONLY GET THE STATIC DATA... DYNAMIC DATA SHOULD BE LOADED BY GAME.PHP
// You cant name anything $_SESSION['host'] apparently.
$_SESSION['game_name'] = $game_name['name'];
$_SESSION['game_timelimit'] = $game_name['timelimit'];
$_SESSION['game_id'] = $id;
$_SESSION['player_pass'] = $password;
$_SESSION['player_id'] = $playerinfo['id'];
$_SESSION['player_rank'] = $player_rank;
$_SESSION['player_color'] = $playerinfo;
$_SESSION['game_host'] = $playerinfo['host'];
$_SESSION['state'] = $playerinfo['state'];
$_SESSION['email'] = $playerinfo['email'];
$_SESSION['player_name'] = $playerinfo['player'];
$_SESSION['game_timestamp'] = $timestamp;
// Send to game screen now that the session has been initialized
header("Location: game.php");
?>[/php]E qesto è il codice della pagina da dove arriva il giocatore:
[php]<?php
// Load the settings...
require_once(dirname(FILE) . '/Settings.php');
require_once($sourcedir . '/QueryString.php');
require_once($sourcedir . '/Subs.php');
require_once($sourcedir . '/Errors.php');
require_once($sourcedir . '/Load.php');
require_once($sourcedir . '/Security.php');
include('includes/langconfig.php');
//if (isset($_SESSION['player_name'])){
if (isset($user_settings['memberName'])){
?>
<a class="button" href="index.php?page=creategame"><? echo $trad['CREATE_GAME']; ?></a>
<?php
}
if (isset($_GET['sort']))  { $sort = $_GET['sort']; } else { $sort = 'time'; }
if (isset($_GET['order']))  { $order = $_GET['order']; } else { $order = 'DESC'; }
if(isset($_GET['num'])){
$startnum = $_GET['num'];
$endnum = $startnum + 20;
$sql = "SELECT * FROM {$db_prefix}games ORDER BY $sort $order LIMIT $startnum , $endnum ";
} else { // set Limit to +1 to see if there is another pages worth of games
$startnum = 0;
$sql = "SELECT * FROM {$db_prefix}games ORDER BY $sort $order LIMIT 0 , 20";
}
$some_games = db_query($sql);
$query_rows = mysql_num_rows($some_games);
?>
<? if(isset($_GET['error'])){ ?>
<div class="error" id="error" style="top: 15px;">
<? echo $trad['WARNING:']; ?> <?= $_GET['error'] ?>
<div class="close"><a href="javascript:OffError()">X</a></div>
</div>
<? } ?>
<table id="game_browser">
<!--MW:classes in case we want styles on columns (width)-->
<colgroup class="kibitz" />
<colgroup class="locked" />
<colgroup class="game_name" />
<colgroup class="game_players" />
<colgroup class="game_status" />
<colgroup class="current_player" />
<colgroup class="game_time" />
<tr>
<th><!--kibitz--></th>
<th><!--locked--></th>
<?php
switch($order) {
case 'DESC': $order = 'ASC';
break;
case 'ASC': $order = 'DESC';
break;
}
?>
<th><a href="index.php?page=gamebrowser&sort=name&order=<?= $order ?>"><? echo $trad['GAME_NAME']; ?></a></th>
<!--MW:again, comment out for now.<th>Type</th>-->
<th>#</th>
<th><a href="index.php?page=gamebrowser&sort=state&order=<?= $order ?>"><? echo $trad['STATUS']; ?></a></th>
<th><? echo $trad['CURRENT_PLAYER']; ?></th>
<th><a href="index.php?page=gamebrowser&sort=time&order=<?= $order ?>"><? echo $trad['LAST_MOVE']; ?></a></th>
</tr>
<?
$rownum = 0;
while (($game = mysql_fetch_array($some_games))&& ($rownum < 20)){
?>
    <tr class="<?
    switch ($game['state']) {
        case "Waiting":
            echo 'browsewait';
            break;
        case "Playing":
            echo 'browseplay';
            break;
        case "Finished":
            echo 'browsefin';
            break;
    }  // check row%2 to color rows
    ?>" style="background-color:#<?php  if ($rownum%2) { echo "000"; } else { echo "1e1e1e";} ?>;">
    <td><?
    if($game['kibitz']) 
        echo '<a href="index.php?page=kibitz&id='.$game['id'].'"><img src="images/kibitz.gif" height="12" width="16" alt="Kibitz" /></a>'; 
    else ;
        /*echo ' ';*/
        
    ?></td>
    <td><?
    if($game['password']){ echo '<img src="images/lock.gif" alt="Password" />'; $pass = 1; 
        } else { /*echo ' ';*/ $pass = 0; }
    ?></td>
    <td><?
    ($game['players'] == $game['capacity']) ? $full = 1 : $full = 0;
    ($game['state'] != 'Waiting') ? $playing = 1 : $playing = 0;
            echo '<input type="hidden" name="'.$game['id'].'" value="'.$game['id'].'" /> <a href="login.php?id='.$game['id'].'&gamename='.rawurlencode($game['name']).'">'.@stripslashes($game['name']);
    ?></a></td>        
    
    <td><?     echo $game['players'].'/'.$game['capacity']; ?></td>
    <td><?     echo $game['state']; ?></td>
    
    <td><?
    /* Find out who's the current player.*/
        $sql = "SELECT player FROM {$db_prefix}game_".$game['id']." WHERE state != 'inactive' AND state != 'initial' AND state != 'dead' AND state != 'waiting' AND id != 1";
        $current_player = db_query($sql);
        // find out if the user needs to place troops
        if ($_SESSION['player_id']) {
            $sql = "SELECT state FROM {$db_prefix}game_".$game['id']." WHERE id = ".$_SESSION['player_id'];
            $user_state = get_one($sql);
        }
    switch ($game['state']) {
        case "Waiting":
            echo $trad['FOR_PLAYERS'];
            break;
        case "Finished":
            echo '';
            break;
        case "Initial":
        if ($user_state == 'initial') {
            echo "<span style='color:red;'>".$trad['PLACEMENT']."</span>";
        } else {
            echo $trad['PLACEMENT'];
        }
            break;
        case "Playing":
            if ($current_player[0] == $_SESSION['player_name']) {
                echo "<span style='color:red;'>".$current_player[0]."</span>";
            } else {
                echo $current_player[0];
            break;
       }
    }        
    ?></td>
    
    
    <td><?     echo substr($game['time'], 0, 10);    ?></td>
    </tr><?
        echo "\n";
        $rownum++;
} ?>
</table>
<span class="rightalign">
<?     // BROWSE TABLE SIZE different in IE and Mozilla (bigger in Mozilla so the the current max fits Mozilla but leaves space in IE )
if (($startnum - 20) > -1){ ?>
<a href="index.php?num=<?= $startnum - 20 ?>" style="color:#FFEECC">
<img src="images/arrow_left.gif" width="19" height="12" border="0" alt="Previous"><? echo $trad['PREVIOUS']; ?> </a>
<?  }
if($query_rows == 20){ // theres another row for another page so show the Next Link.
?>
<a href="index.php?num=<?= $startnum + 20 ?>" style="color:#FFEECC"><? echo $trad['NEXT']; ?>
<img src="images/arrow_right.gif" width="19" height="12" border="0" alt="Next"></a>
<? } ?>
</span>
[/php]
Un grazie in anticipo, per chi fosse interessato al progetto non esiti a contattarmi, naturalmente il progetto dovrà rimanere opensource anche dopo le varie modifiche.
Saluti
Salve a tutti,
Ho problemi a collegarmi tramite desktop remoto su un virtual server linux (il + economico di aruba), io lavoro in ambiente windows e non mi fa accedere.
Non so se è possibile, ma mi chiedevo se potevo controllare il mio server in qualche modo oltre al plesk.
Visto che ci sono porgo anche un'altra domanda: come posso installare altre applicazioni sul mio server che non siano a pagamento(ad esempio moduli di plesk)?
Grazie mille
probabilmente questo argomento è stato affrontato centinaia di volte...ma non trovo il tasto cerca.