|
Forum Flash, Actionscript, PHP e MySQL
|
|
|
|
|
|
| Autore |
Messaggio |
fedyfausto
intermedio


Età: -1989
Registrato: 26/07/07 00:41
Messaggi: 124
Località: Catania
|
Oggetto:
Inviato: 17.09.08 | 23:37 |
|
|
niente purtroppo anche senza le UNIQUE continua a dare questo risultato quando un utente cerca di registrarsi ad un secondo torneo:
Valore duplicato '3' per la chiave 1
ti ripropongo sql delle tabelle iscrizioni e giocatori:
| Codice: | -- phpMyAdmin SQL Dump
-- version 2.6.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generato il: 17 Set, 2008 at 11:36 PM
-- Versione MySQL: 4.1.9
-- Versione PHP: 4.3.10
--
-- Database: `smashitalia`
--
-- --------------------------------------------------------
--
-- Struttura della tabella `giocatori`
--
CREATE TABLE `giocatori` (
`id` int( NOT NULL auto_increment,
`nickname` varchar(20) NOT NULL default '',
`password` varchar(12) NOT NULL default '',
`email` varchar(255) NOT NULL default '',
`nazione` varchar(255) NOT NULL default '',
`codice_wii` varchar(16) NOT NULL default '',
`codice_amicobrawl` varchar(12) NOT NULL default '0',
`personaggio_brawl` varchar(20) NOT NULL default '',
`punteggio` int(5) NOT NULL default '0',
`avatar` varchar(255) default 'immagini/noavatar.gif',
`primepos` int(11) NOT NULL default '0',
`secondepos` int(11) NOT NULL default '0',
`terzepos` int(11) NOT NULL default '0',
`quartepos` int(11) NOT NULL default '0',
`admin` char(2) NOT NULL default 'no',
`iscrittotorneo` char(2) NOT NULL default 'no',
`valcomune` char(1) NOT NULL default '1',
PRIMARY KEY (`id`),
UNIQUE KEY `nickname` (`nickname`),
UNIQUE KEY `email` (`email`),
UNIQUE KEY `codice_wii` (`codice_wii`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Dump dei dati per la tabella `giocatori`
--
INSERT INTO `giocatori` VALUES (3, 'fedyfausto', '10018', 'fedyfausto@hotmail.com', 'immagini/flags/italy.gif', '1121023823888128', '064572387409', 'Kirby', 0, 'http://www.uploadgeek.com/uploads456/0/ava.gif', 0, 0, 0, 0, 'si', 'no', '1');
-- --------------------------------------------------------
--
-- Struttura della tabella `iscrizioni`
--
CREATE TABLE `iscrizioni` (
`id` int( NOT NULL auto_increment,
`id_torneo` int( NOT NULL default '0',
`id_iscritto` int( NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `id_torneo` (`id_torneo`),
KEY `id_iscritto` (`id_iscritto`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--
-- Dump dei dati per la tabella `iscrizioni`
--
INSERT INTO `iscrizioni` VALUES (3, 1, 3); |
P.S.
Potrebbe essere che essendoci già un'iscrizione ad un torneo cmq diverso trova già l'ID dello stesso giocatore e quindi non lo aggiunge? nonostante nn sia UNIQUE
Cmq un secondo account riesce a iscriversi anche se è la prima volta per lui... XD ripeto se mi spiegate come farvi vedere questo sito ke ho in locale vi posto IP e tutto  ____________________________________________________________
Fedyfausto's Blog | Zero No Tsukaima Italia |
|
| Torna in cima |
|
|
Sponsor
|
|
 |
AngaraT
intermedio


Registrato: 23/03/04 21:10
Messaggi: 152
|
Oggetto:
Inviato: 18.09.08 | 10:01 |
|
|
;) non ho molto tempo da dedicare al testing di app di terze parti... ...sai come la è in sto periodo...
cmq si dovrebbe capire quale query crea l'errore, una volta trovata la tabella e la query probabilmente si capisce il perchè e si possono prendere le contromisure.
per capire quale query crea l'errore quando scrivi "or die(mysql_error());" mettigli anche un marcatore di riconoscimento es:
or die("Errore query di ...:".mysql_error());
ciao ciao
[edit]
mi fai vedere la query di inserimento del record nella tabella "iscrizione" ho come l'impressione che il valore duplicato sia l'ID di quella tabella
[/edit] |
|
| Torna in cima |
|
|
fedyfausto
intermedio


Età: -1989
Registrato: 26/07/07 00:41
Messaggi: 124
Località: Catania
|
|
| Torna in cima |
|
|
AngaraT
intermedio


Registrato: 23/03/04 21:10
Messaggi: 152
|
Oggetto:
Inviato: 19.09.08 | 14:03 |
|
|
;) vabbe sarebbe interessante sapere quale campo era doppio
hai provato a fare un echo della query ed un echo di $loginFoundUser per capire che accade?
e dato che ci sei raccontaci anche del problema serio :)
ciao ciao |
|
| Torna in cima |
|
|
fedyfausto
intermedio


Età: -1989
Registrato: 26/07/07 00:41
Messaggi: 124
Località: Catania
|
Oggetto:
Inviato: 19.09.08 | 16:19 |
|
|
no vabbe io davo i valori degli id del torneo e del giocatore a due campio nascosti ocn lo stesso nome XD cmq..
Non ho capito ke devo fare con gli echo XD ma scusa con gli echo nn lo stampa su schermo? O_O
il problema serio è che sto cercando di fare in modo ke l'untete possa cancellare la sua iscrizione al torneo e cosi ho creato 2 pagine..
Una dove conferma e aggiorna il suo status di iscrittotorneo da si a no e poi rimanda in altra pagina dove cancella l'id dell'iscirzione e rimanda ancora alla sua scheda... pero nn riesco a mandare nella seconda pagina una variabile via URL :\ ____________________________________________________________
Fedyfausto's Blog | Zero No Tsukaima Italia |
|
| Torna in cima |
|
|
AngaraT
intermedio


Registrato: 23/03/04 21:10
Messaggi: 152
|
Oggetto:
Inviato: 19.09.08 | 17:02 |
|
|
| Codice: | <?php
// vedo la query e mi assicuro che gli arrivino i dati giusti
echo "SELECT nickname, password FROM giocatori WHERE nickname=".$loginUsername." AND password=".$password;
// vedo quanti record vengono selezionati
echo $loginFoundUser
?> |
Ciao ciao
A. |
|
| Torna in cima |
|
|
fedyfausto
intermedio


Età: -1989
Registrato: 26/07/07 00:41
Messaggi: 124
Località: Catania
|
Oggetto:
Inviato: 19.09.08 | 17:36 |
|
|
lasciando perdere il problema del login ke n come va cmq funziona.. potrei chiederti delle info su ocme risolvere il problema della cancellazione dell'iscrizione? ^^
ecco la pagina dove l'untente conferma l'iscrizione e premendo il tasto aggiorna il suo status e poi DOVREBBE inviare la variabile via URL alla seconda pagina:
| Codice: | <?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "cancellazioneiscrizione")) {
$updateSQL = sprintf("UPDATE giocatori SET iscrittotorneo=%s WHERE id=%s",
GetSQLValueString($_POST['iscrittotorneo'], "text"),
GetSQLValueString($_POST['idutente'], "int"));
mysql_select_db($database_smash_italia, $smash_italia);
$Result1 = mysql_query($updateSQL, $smash_italia) or die(mysql_error());
$updateGoTo = "cancellazioneiscrizione2.php?idiscrizione=";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
?> |
purtroppo qui
| Codice: | $updateGoTo = "cancellazioneiscrizione2.php?idiscrizione="; |
se metto cosi:
| Codice: | $updateGoTo = "cancellazioneiscrizione2.php?idiscrizione=".$row_cancellazioneiscrizione['id']; |
mi da errore :\ ____________________________________________________________
Fedyfausto's Blog | Zero No Tsukaima Italia |
|
| Torna in cima |
|
|
AngaraT
intermedio


Registrato: 23/03/04 21:10
Messaggi: 152
|
Oggetto:
Inviato: 19.09.08 | 17:39 |
|
|
che errore ti da?
 |
|
| Torna in cima |
|
|
fedyfausto
intermedio


Età: -1989
Registrato: 26/07/07 00:41
Messaggi: 124
Località: Catania
|
|
| Torna in cima |
|
|
AngaraT
intermedio


Registrato: 23/03/04 21:10
Messaggi: 152
|
Oggetto:
Inviato: 19.09.08 | 17:54 |
|
|
| evidentemente è venerdi sera e non capisco + nulla :(, ma da dove prendi questa $row_cancellazioneiscrizione ??? |
|
| Torna in cima |
|
|
fedyfausto
intermedio


Età: -1989
Registrato: 26/07/07 00:41
Messaggi: 124
Località: Catania
|
|
| Torna in cima |
|
|
fedyfausto
intermedio


Età: -1989
Registrato: 26/07/07 00:41
Messaggi: 124
Località: Catania
|
|
| Torna in cima |
|
|
fedyfausto
intermedio


Età: -1989
Registrato: 26/07/07 00:41
Messaggi: 124
Località: Catania
|
Oggetto:
Inviato: 24.09.08 | 15:54 |
|
|
ok signori ho capito il problema!
In poche parole già dalla scheda personale il codice SQL che dovrebbe prendere 3 semplici ID continua a richiamarne uno totalmente sbagliato vecchio e KE NON ESISTE NEL DB!!
Vi faccio un esempio... se utilizzo l'SQL che vedreto sotto mi appagliono questi risultiati:
Ecco vedete il primo campo dove ID è uguale a 17? bene quello è l'ID dell'iscrizione dell'utente... ma ora xke se utilizzo lo stesso SQL in una pagina PHP e utilizzo un normalissimo ECHO invece di 17 mi spunta sempre 3? e soprattutto come fa a spuntare se nel databse NON ESISTE?!?!?
HELP ME PLS ____________________________________________________________
Fedyfausto's Blog | Zero No Tsukaima Italia |
|
| Torna in cima |
|
|
fedyfausto
intermedio


Età: -1989
Registrato: 26/07/07 00:41
Messaggi: 124
Località: Catania
|
Oggetto:
Inviato: 03.10.08 | 01:43 |
|
|
Ecco il codice PHP che potrebbe dare questo problema ma nn riesco a trovare l'errore...
| Codice: | <?php require_once('Connections/smash_italia.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "index.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_tabellanews = 5;
$pageNum_tabellanews = 0;
if (isset($_GET['pageNum_tabellanews'])) {
$pageNum_tabellanews = $_GET['pageNum_tabellanews'];
}
$startRow_tabellanews = $pageNum_tabellanews * $maxRows_tabellanews;
mysql_select_db($database_smash_italia, $smash_italia);
$query_tabellanews = "SELECT * FROM news ORDER BY id DESC";
$query_limit_tabellanews = sprintf("%s LIMIT %d, %d", $query_tabellanews, $startRow_tabellanews, $maxRows_tabellanews);
$tabellanews = mysql_query($query_limit_tabellanews, $smash_italia) or die(mysql_error());
$row_tabellanews = mysql_fetch_assoc($tabellanews);
if (isset($_GET['totalRows_tabellanews'])) {
$totalRows_tabellanews = $_GET['totalRows_tabellanews'];
} else {
$all_tabellanews = mysql_query($query_tabellanews);
$totalRows_tabellanews = mysql_num_rows($all_tabellanews);
}
$totalPages_tabellanews = ceil($totalRows_tabellanews/$maxRows_tabellanews)-1;
mysql_select_db($database_smash_italia, $smash_italia);
$query_giochicompatibili = "SELECT * FROM giochicompatibili ORDER BY id ASC";
$giochicompatibili = mysql_query($query_giochicompatibili, $smash_italia) or die(mysql_error());
$row_giochicompatibili = mysql_fetch_assoc($giochicompatibili);
$totalRows_giochicompatibili = mysql_num_rows($giochicompatibili);
$colname_giocatori = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_giocatori = $_SESSION['MM_Username'];
}
$colname_giocatori = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_giocatori = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_smash_italia, $smash_italia);
$query_giocatori = sprintf("SELECT * FROM giocatori WHERE nickname = '%s'", $colname_giocatori);
$giocatori = mysql_query($query_giocatori, $smash_italia) or die(mysql_error());
$row_giocatori = mysql_fetch_assoc($giocatori);
$totalRows_giocatori = mysql_num_rows($giocatori);
mysql_select_db($database_smash_italia, $smash_italia);
$query_teamspeak = "SELECT * FROM teamspeak";
$teamspeak = mysql_query($query_teamspeak, $smash_italia) or die(mysql_error());
$row_teamspeak = mysql_fetch_assoc($teamspeak);
$totalRows_teamspeak = mysql_num_rows($teamspeak);
$colname_torneochestapartecipando = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_torneochestapartecipando = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_smash_italia, $smash_italia);
$query_torneochestapartecipando = sprintf("SELECT iscrizioni.id, iscrizioni.id_torneo, iscrizioni.id_iscritto, tornei.id, tornei.titolo, giocatori.id, tornei.aperto, giocatori.nickname FROM giocatori, iscrizioni, tornei WHERE giocatori.id = iscrizioni.id_iscritto AND iscrizioni.id_torneo = tornei.id AND tornei.aperto = 'si' AND giocatori.nickname = '%s' LIMIT 1 ", $colname_torneochestapartecipando);
$torneochestapartecipando = mysql_query($query_torneochestapartecipando, $smash_italia) or die(mysql_error());
$row_torneochestapartecipando = mysql_fetch_assoc($torneochestapartecipando);
$totalRows_torneochestapartecipando = mysql_num_rows($torneochestapartecipando);
?> |
____________________________________________________________
Fedyfausto's Blog | Zero No Tsukaima Italia |
|
| Torna in cima |
|
|
|
|
Non puoi inserire nuovi Topic in questo forum Non puoi rispondere ai Topic in questo forum Non puoi modificare i tuoi messaggi in questo forum Non puoi cancellare i tuoi messaggi in questo forum Non puoi votare nei sondaggi in questo forum Non puoi allegare files in questo forum Non puoi downloadare gli allegati in questo forum
|
|