mfreitas Posted August 15, 2011 Share Posted August 15, 2011 This PHP script I wrote has somethimg wrong, as the page appears all blank. There are other things in the page that are not working/showing up, so I assume that its a syntax error (I think the {} are ok) in this script. If you could please check it to see if there isn't anything wrong with it..... Here I'll send the code: <?php $db = mysql_connect("localhost", "x", "x"); $basedados = "Y" ; mysql_select_db($basedados, $db) ; $passi = $_POST['password'] ; $equipa = $_POST['Comprador'] ; $querypc = "SELECT Password FROM Password WHERE IDEquipa = $equipa" ; $passc2 = mysql_query($querypc, $db) ; while($as = mysql_fetch_array($passc2)) { $passc = $as['Password'] ; } if($passi != $passc) { $Estado = "Transferência Cancelada: Password Incorrecta" ; } else { $Jogador = $_POST['jogador'] ; $querycj = "SELECT IDEquipa FROM Jogadores WHERE IDJogador = $Jogador" ; $clubejog = mysql_query($querycj, $db) ; while($ford = mysql_fetch_array($clubejog)) { $cjogador = $ford['Equipa'] ; } if($cjogador == "ZZZ") { $qvalorj = "SELECT Preco FROM Val_Jog WHERE Valor = (SELECT Valor FROM Jogadores WHERE IDJogador = $Jogador)" ; $valorj = mysql_query($qvalorj, $db) ; while($ab = mysql_fetch_array($valorj)) { $vjogador = $ab['Preco'] ; } $vprop = $_POST['valor'] ; if($vprop == $vjogador) { $querync = "UPDATE Jogadores SET IDEquipa = $equipa WHERE IDJogador = $Jogador" ; $novoclube = $mysql_query($querync, $db) ; $queryif = "INSERT INTO Mov_Fin (IDEquipa, Montante, Descricao) VALUES ($Equipa, "-$vprop", "compra jogador $Jogador")" ; $insfin = mysql_query($queryif, $db) ; $Estado = "Transferência bem sucedida..." ; } else { $estado = "Transferência Cancelada: O valor da proposta não é aceitável..." ; } else { $queryip = "INSERT INTO Propostas (IDEquipa, Jogador, Valor, Tipo) VALUES ($Equipa, $Jogador, $vprop, "Compra")" ; $insprop = mysql_query($queryip, $db) ; $queryup = "UPDATE Propostas SET Vendedor = (SELECT Equipa FROM Jogadores WHERE IDJogador = $Jogador") ; $updprop = mysql_query($queryup, $db) ; $mensagem = "Caro Treinador, o clube acaba de receber uma nova proposta que envolve o jogador nr $Jogador. Para mais informações consulte o site do Campeonato de Futebol de Dados. Cumprimentos, OCFDO " ; $queryomail = "SELECT mail FROM Equipa WHERE IDEquipa = (SELECT Equipa FROM Jogadores WHERE IDJogador = $Jogador)" ; $omail = mysql_query($queryomail, $db) ; while($sup = mysql_fetch_array($omail)) { $mail = $sup['mail'] ; } } } echo $Estado; ?> Thanks for the help. Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted August 15, 2011 Share Posted August 15, 2011 if you have error_reporting set to E_ALL and display_errors set to ON, all of the relavant errors will be displayed to you on the page Quote Link to comment Share on other sites More sharing options...
mfreitas Posted August 15, 2011 Author Share Posted August 15, 2011 How do you change it in the code? Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted August 15, 2011 Share Posted August 15, 2011 place these 2 lines on the top of your php.. ini_set("error_reporting",E_ALL); ini_set("display_errors","ON"); Quote Link to comment Share on other sites More sharing options...
mikosiko Posted August 15, 2011 Share Posted August 15, 2011 most likely you have a mismatch { around this lines $estado = "Transferência Cancelada: O valor da proposta não é aceitável..." ; } else { /// seems that you are missing a { before this else Quote Link to comment Share on other sites More sharing options...
mfreitas Posted August 15, 2011 Author Share Posted August 15, 2011 It still dosn't work. I did what both told me and its still blank, I don't get why.... Here it is updated: <?php $db = mysql_connect("localhost", "Miguel", "MPSMFJ"); $basedados = "OCFDO2011" ; mysql_select_db($basedados, $db) ; $passi = $_POST['password'] ; $equipa = $_POST['Comprador'] ; $querypc = "SELECT Password FROM Password WHERE IDEquipa = $equipa" ; $passc2 = mysql_query($querypc, $db) ; while($as = mysql_fetch_array($passc2)) { $passc = $as['Password'] ; } if($passi != $passc) { $Estado = "Transferência Cancelada: Password Incorrecta" ; } else { $Jogador = $_POST['jogador'] ; $querycj = "SELECT IDEquipa FROM Jogadores WHERE IDJogador = $Jogador" ; $clubejog = mysql_query($querycj, $db) ; while($ford = mysql_fetch_array($clubejog)) { $cjogador = $ford['Equipa'] ; } if($cjogador == "ZZZ") { $qvalorj = "SELECT Preco FROM Val_Jog WHERE Valor = (SELECT Valor FROM Jogadores WHERE IDJogador = $Jogador)" ; $valorj = mysql_query($qvalorj, $db) ; while($ab = mysql_fetch_array($valorj)) { $vjogador = $ab['Preco'] ; } $vprop = $_POST['valor'] ; if($vprop == $vjogador) { $querync = "UPDATE Jogadores SET IDEquipa = $equipa WHERE IDJogador = $Jogador" ; $novoclube = $mysql_query($querync, $db) ; $queryif = "INSERT INTO Mov_Fin (IDEquipa, Montante, Descricao) VALUES ($Equipa, "-$vprop", "compra jogador $Jogador")" ; $insfin = mysql_query($queryif, $db) ; $Estado = "Transferência bem sucedida..." ; } else { $estado = "Transferência Cancelada: O valor da proposta não é aceitável..." ; } } else { $queryip = "INSERT INTO Propostas (IDEquipa, Jogador, Valor, Tipo) VALUES ($Equipa, $Jogador, $vprop, "Compra")" ; $insprop = mysql_query($queryip, $db) ; $queryup = "UPDATE Propostas SET Vendedor = (SELECT Equipa FROM Jogadores WHERE IDJogador = $Jogador") ; $updprop = mysql_query($queryup, $db) ; } } echo $Estado; ?> I really don't whats wrong !! Please help me! Quote Link to comment Share on other sites More sharing options...
mikosiko Posted August 15, 2011 Share Posted August 15, 2011 - I don't see in your new code what AyKay suggested. - How are you debugging your code? - what result are you expecting? (I see only an echo $Estado, that could or couldn't echo something on the screen). - Did you echo your queries to see if they are valid? - Did you echo your POSTed values ? you have several things to do to debug for yourself your code Quote Link to comment Share on other sites More sharing options...
Network_ninja Posted August 19, 2011 Share Posted August 19, 2011 I modified your code a little bit. You can try out this one.. So I also do believe that you have a correct HTML form to accept the inputs... Here is the code: <?php $db = mysql_connect("localhost", "Miguel", "MPSMFJ")or die(mysql_error()); $basedados = "OCFDO2011" ; mysql_select_db($basedados, $db)or die(mysql_error()); $passi = $_POST['password'] ; $equipa = $_POST['Comprador'] ; $querypc = "SELECT Password FROM Password WHERE IDEquipa = '$equipa'" ; $passc2 = mysql_query($querypc, $db)or die(mysql_error()); while($as = mysql_fetch_array($passc2)) { // you can ommit the while statement if you only have to fetch 1 record, You can also do it this way $passc = $as['Password'] ; // $as = mysql_fetch_array($passc2); } // $passc = $as['Password']; But it's still your preference if you do it that way if($passi != $passc) { $Estado = "Transferência Cancelada: Password Incorrecta" ; } else { $Jogador = $_POST['jogador'] ; $querycj = "SELECT IDEquipa FROM Jogadores WHERE IDJogador = '$Jogador'" ; $clubejog = mysql_query($querycj, $db)or die(mysql_error()); while($ford = mysql_fetch_array($clubejog)) { $cjogador = $ford['Equipa'] ; } if($cjogador == "ZZZ") { $qvalorj = "SELECT Preco FROM Val_Jog WHERE Valor = (SELECT Valor FROM Jogadores WHERE IDJogador = '$Jogador')" ; $valorj = mysql_query($qvalorj, $db)or die(mysql_error()); while($ab = mysql_fetch_array($valorj)) { $vjogador = $ab['Preco'] ; } $vprop = $_POST['valor'] ; if($vprop == $vjogador) { $querync = "UPDATE Jogadores SET IDEquipa = $equipa WHERE IDJogador = '$Jogador'" ; $novoclube = mysql_query($querync, $db)or die(mysql_error()); $queryif = "INSERT INTO Mov_Fin (IDEquipa, Montante, Descricao) VALUES ($Equipa, '-$vprop', 'compra jogador $Jogador')" ; $insfin = mysql_query($queryif, $db)or die(mysql_error()); $Estado = "Transferência bem sucedida..." ; } else { $estado = "Transferência Cancelada: O valor da proposta não é aceitável..." ; } } else { $queryip = "INSERT INTO Propostas (IDEquipa, Jogador, Valor, Tipo) VALUES ($Equipa, $Jogador, $vprop, 'Compra')" ; $insprop = mysql_query($queryip, $db)or die(mysql_error()); $queryup = "UPDATE Propostas SET Vendedor = (SELECT Equipa FROM Jogadores WHERE IDJogador = '$Jogador'"); $updprop = mysql_query($queryup, $db)or die(mysql_error()); } } echo $Estado; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.