Run query sql

Asked

Viewed 1,198 times

0

$sql = "exec atualizar_feira '".$nome."', '".$endereco."', '".$cep."', '".$escolaridade."', '".$instituicao."', '".$telefone."', '".$email."', '".$aluno_cairu."', '".$curso."', '".$curso2."', '".$palestra."', '".$data."' ";

$result = mssql_query($sql); 

How do I run this $sql?

  • msql_query???? It’s been a long time since I’ve used this because I migrated to the PDO, but if I’m not mistaken the memory is mysql_query($query).

  • This is a Function or stored Procedure?

  • @Thomsontorvalds mssql_query is a function that accesses Microsoft’s SQL Server, another database, which is not Mysql.

2 answers

2

The way it is in the question, it already executes, to get the results, you can use the mssql_fetch_array as described in the previous answer.

Taking the opportunity to indicate the strong possibility of SQL Injection in this code, in addition to the function depreciation in PHP 7.0 - migrate to PDO if possible.

1

Now just use a repeat loop (while) to work with the results:

$result = mssql_query($sql); 
while ($results = mssql_fetch_array($result)) {
    $nome = $results['nome'];
    $endereco = $results['endereco'];
    ...
}

Then you exchange $Results['] for the fields in your table you want to use.

  • thanks already managed just add Return ($variable)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.