Error 500 php SQL Server

0

I tried to make a code in PHP and I'm having difficulties with the SQL Server query, now I tried to do a query in another way and gave 500 error in PHP what can it be?

My page code:

       <?php

$servidor = 'VINIPC\SQLEXPRESS';
$db = 'Db_Tank';
$usuario = 'sa';
$senha = 'vini1234';        

$conexao = sqlsrv_connect($servidor, array('Database' => $db, 'UID' => $usuario, 'PWD' => $senha));

$error = null;
$sucses = null;

if(isset($_POST['Promo'])) {
        $AwardID = $_POST['AwardID'];
        $ActiveID = $_POST['ActiveID'];
        $PullDown = $_POST['PullDown'];
        if($AwardID == null)
            $error.= 'Houve um erro em AwardID!<br />';
        if($error == null) {
            $sql = ("INSERT INTO [dbo].[Active_Number] ([AwardID], [ActiveID], [PullDown]) VALUES('$AwardID', '50', 'False')");
            $stmt = sqlsrv_prepare( $conexao, $sql, array($AwardID, $ActiveID, $PullDown);
            if( !$stmt ) {
    die( print_r(sqlsrv_errors());
}
            $sucses = 'O código: "'.$AwardID.'" foi validado com sucesso.<br />';
        }
        }



function geraSenha($tamanho = 18, $maiusculas = true, $numeros = false, $simbolos = false)
{
$lmin = 'abcdefghijklmnopqrstuvwxyz';
$lmai = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$num = '1234567890';
$simb = '!@#$%*-';
$retorno = '';
$caracteres = '';
$caracteres .= $lmin;
if ($maiusculas) $caracteres .= $lmai;
if ($numeros) $caracteres .= $num;
if ($simbolos) $caracteres .= $simb;
$len = strlen($caracteres);
for ($n = 1; $n <= $tamanho; $n++) {
$rand = mt_rand(1, $len);
$retorno .= $caracteres[$rand-1];
}
return $retorno;
}
?>
<div id="tbtoolbar">
<center>
<input name='AwardID' id='AwardID' type='text' maxlength='40' value='<?php echo geraSenha(18, true, false, false); ?>' readonly />
    <button name='Promo' id="Promo" type="submit" class="btn btn-default">Validar código</button>
    <?php echo '<center><div><font color="red">'.$error. '</font></div></center>'; echo '<center><div><font color="green">'.$sucses. '</font></div></center>'; ?></center>
    </center>
</div>
<script>
    
asked by anonymous 12.12.2016 / 21:14

0 answers