Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/244834-php-script/
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/244834-php-script/#findComment-1257769
Share on other sites

- 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

Link to comment
https://forums.phpfreaks.com/topic/244834-php-script/#findComment-1257775
Share on other sites

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;
?>

Link to comment
https://forums.phpfreaks.com/topic/244834-php-script/#findComment-1259219
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.