Olá.. Estou tentando gerar pdf...a partir de uma consulta mysql....vou postar o meu código ...se alguém puder me ajudar...agradeço... No código eu faço inserção de <a href='#' onClick="hwClick15028925030835(-926903868);return false;" style='cursor: hand; color:#006600; text-decoration:underline; border-bottom:dotted 1px;' onmouseover="hw15028925030835(event, this, '-926903868'); this.style.cursor='hand'; this.style.textDecoration='underline'; this.style.borderBottom='solid';" onmouseout="hideMaybe(event, this); this.style.cursor='hand'; this.style.textDecoration='underline'; this.style.borderBottom='dotted 1px'; " oncontextmenu="return false;">dados</a>, visualizo, deleto...tá dando problema só na hora de gerar o pdf....abaixo a mensagem de erro: Warning: Cannot modify header information - headers already sent by (output started at /home/httpd/htdocs/ensin1br/SistemaEscolar/frm_admin/alexa1br/Users.php:18) in /home/httpd/htdocs/ensin1br/SistemaEscolar/fpdf/fpdf.php on line 1022 FPDF error: Some data has already been output to browser, can't send PDF file Meu código: USERS.php <?php session_start(); ob_start(); if (isset($_GET["order"])) $order = @$_GET["order"]; if (isset($_GET["type"])) $ordtype = @$_GET["type"]; if (isset($_POST["filter"])) $filter = @$_POST["filter"]; if (isset($_POST["consult"])) $filter = @$_POST["consult"]; if (isset($_POST["filter_field"])) $filterfield = @$_POST["filter_field"]; $wholeonly = false; if (isset($_POST["wholeonly"])) $wholeonly = @$_POST["wholeonly"]; if (!isset($order) && isset($_SESSION["order"])) $order = $_SESSION["order"]; if (!isset($ordtype) && isset($_SESSION["type"])) $ordtype = $_SESSION["type"]; if (!isset($filter) && isset($_SESSION["filter"])) $filter = $_SESSION["filter"]; if (!isset($filter) && isset($_SESSION["consult"])) $filter = $_SESSION["consult"]; if (!isset($filterfield) && isset($_SESSION["filter_field"])) $filterfield = $_SESSION["filter_field"]; ob_end_flush(); ?> <html> <head> <title>Usuários</title> <meta name=generator" http-equiv="content-type" content="text/html"> <style type="text/css"> body { background-color: #FFFFFF; color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif;; font-size: 11px; } .bd { background-color: #FFFFFF; color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif;; font-size: 11px; } .tbl { background-color: #DEE7DE; } a:link { color: #FF0000; font-family: Verdana, Arial, Helvetica, sans-serif;; font-size: 11px; } a:active { color: #0000FF; font-family: Verdana, Arial, Helvetica, sans-serif;; font-size: 11px; } a:visited { color: #800080; font-family: Verdana, Arial, Helvetica, sans-serif;; font-size: 11px; } .hr { background-color: #CFCFCF; color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif;; font-size: 11px; } a.hr:link { color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif;; font-size: 12px; } a.hr:active { color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif;; font-size: 11px; } a.hr:visited { color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif;; font-size: 11px; } .dr { background-color: #DEE7DE; color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif;; font-size: 11px; } .sr { background-color: #FFFBF0; color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif;; font-size: 11px; } .style1 {background-color: #CFCFCF; color: #585858; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; } .style2 { font-size: 11px; font-weight: bold; } </style> </head> <body> <table class="bd" width="100%"><tr><td class="hr"><span class="style2">CADASTRAR USUÁRIOS </span></td> </tr> </table> <?php $conn = connect(); $showrecs = 20; $pagerange = 10; $a = @$_GET["a]; $recid = @$_GET["recid"]; $page = @$_GET["page"]; if (!isset($page)) $page = 1; $sql = @$_POST["sql"]; switch ($sql) { case "insert": sql_insert(); break; case "update": sql_update(); break; case "delete": sql_delete(); break; } switch ($a) { case "add": addrec(); break; case "view": viewrec($recid); break; case "edit": editrec($recid); break; case "del": deleterec($recid); break; case "rel": relrec(); break; default: select(); break; } if (isset($order)) $_SESSION["order"] = $order; if (isset($ordtype)) $_SESSION["type"] = $ordtype; if (isset($filter)) $_SESSION["filter"] = $filter; if (isset($consult)) $_SESSION["consult"] = $consult; if (isset($filterfield)) $_SESSION["filter_field"] = $filterfield; if (isset($wholeonly)) $_SESSION["wholeonly"] = $wholeonly; mysql_close($conn); ?> <table class=bd" width="100%"><tr> <td class="style1"><div align="center">http://www.alexanderfleming.com.br</div></td> </tr> </table> </body> </html> <?php function select() { global $a; global $showrecs; global $page; global $filter; global $filterfield; global $wholeonly; global $order; global $ordtype; if ($a == "reset") { $filter = ""; $filterfield = ""; $wholeonly = ""; $order = ""; $ordtype = ""; } $checkstr = ""; if ($wholeonly) $checkstr = " checked"; if ($ordtype == "asc") { $ordtypestr = "desc"; } else { $ordtypestr = "asc"; } $res = sql_select(); $count = sql_getrecordcount(); if ($count % $showrecs != 0) { $pagecount = intval($count / $showrecs) + 1; } else { $pagecount = intval($count / $showrecs); } $startrec = $showrecs * ($page - 1); if ($startrec < $count) {mysql_data_seek($res, $startrec);} $reccount = min($showrecs * $page, $count); ?> <table class="bd" border="0" cellspacing="1" cellpadding="4"> <tr><td>Encontrados <?php echo $startrec + 1 ?> - <?php echo $reccount ?> de <?php echo $count ?></td></tr> </table> <hr size="1" noshade> <form action="Users.php" method="post"> <table class="bd" border="0" cellspacing="1" cellpadding="4"> <tr> <td><b>Busca:</b> </td> <td><input type="text" name="filter" value="<?php echo $filter ?>"></td> <td><select name="filter_field"> <option value="">Todos os campos</option> <option value="<?php echo "nome" ?>"<?php if ($filterfield == "nome") { echo "selected"; } ?>><?php echo htmlspecialchars("Nome") ?></option> <option value="<?php echo "email" ?>"<?php if ($filterfield == "email") { echo "selected"; } ?>><?php echo htmlspecialchars("Email") ?></option> </select></td> <td><input type="checkbox" name="wholeonly"<?php echo $checkstr ?>>Palavras inteiras</td> </td></tr> <tr> <td> </td> <td><input type="submit" name="action" value="Buscar"></td> <td> <td><a href="Users.php?a=rel">Relatório</a></td> <td><a href="Users.php?a=reset">Limpar Pesquisa</a></td> </tr> </table> </form> <hr size="1" noshade> <?php showpagenav($page, $pagecount); ?> <br> <table class="tbl" border="0" cellspacing="1" cellpadding="5"width="100%"> <tr> <td class="hr"> </td> <td class="hr"> </td> <td class="hr"> </td> <td class="hr"><a class="hr" href="Users.php?order=<?php echo "id" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("Código") ?></a></td> <td class="hr"><a class="hr" href="Users.php?order=<?php echo "nome" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("Nome") ?></a></td> <td class="hr"><a class="hr" href="Users.php?order=<?php echo "usuario" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("Login") ?></a></td> <td class="hr"><a class="hr" href="Users.php?order=<?php echo "senha" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("Senha") ?></a></td> <td class="hr"><a class="hr" href="Users.php?order=<?php echo "nivel" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("Nível") ?></a></td> <td class="hr"><a class="hr" href="Users.php?order=<?php echo "cargo" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("Cargo") ?></a></td> <td class="hr"><a class="hr" href="Users.php?order=<?php echo "email" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("Email") ?></a></td> </tr> <?php for ($i = $startrec; $i < $reccount; $i++) { $row = mysql_fetch_assoc($res); $style = "dr"; if ($i % 2 != 0) { $style = "sr"; } ?> <tr> <td class="<?php echo $style ?>"><a href="Users.php?a=view&recid=<?php echo $i ?>">Visualizar</a></td> <td class="<?php echo $style ?>"><a href="Users.php?a=edit&recid=<?php echo $i ?>">Editar</a></td> <td class="<?php echo $style ?>"><a href="Users.php?a=del&recid=<?php echo $i ?>">Apagar</a></td> <td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["id]) ?></td> <td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["nome"]) ?></td> <td class=<?php echo $style ?>"><?php echo htmlspecialchars($row["usuario]) ?></td> <td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["senha"]) ?></td> <td class=<?php echo $style ?>"><?php echo htmlspecialchars($row["nivel]) ?></td> <td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["cargo"]) ?></td> <td class=<?php echo $style ?>"><?php echo htmlspecialchars($row["email]) ?></td> </tr> <?php } mysql_free_result($res); ?> </table> <br> <?php showpagenav($page, $pagecount); ?> <?php } ?> <?php function showrow($row, $recid) { ?> <table class="tbl" border="0" cellspacing="1" cellpadding="5"width="50%"> <tr> <td class="hr"><?php echo htmlspecialchars("Código")." " ?></td> <td class="dr"><?php echo htmlspecialchars($row["id"]) ?></td> </tr> <tr> <td class=hr"><?php echo htmlspecialchars("Nome")." " ?></td> <td class="dr"><?php echo htmlspecialchars($row["nome]) ?></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Login")." " ?></td> <td class="dr"><?php echo htmlspecialchars($row["usuario"]) ?></td> </tr> <tr> <td class=hr"><?php echo htmlspecialchars("Senha")." " ?></td> <td class="dr"><?php echo htmlspecialchars($row["senha]) ?></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Nível")." " ?></td> <td class="dr"><?php echo htmlspecialchars($row["nivel"]) ?></td> </tr> <tr> <td class=hr"><?php echo htmlspecialchars("Cargo")." " ?></td> <td class="dr"><?php echo htmlspecialchars($row["cargo]) ?></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Email")." " ?></td> <td class="dr"><?php echo htmlspecialchars($row["email"]) ?></td> </tr> </table> <?php } ?> <?php function showroweditor($row, $iseditmode) { global $conn; ?> <table class=tbl" border="0" cellspacing="1" cellpadding="5"width="50%"> <tr> <td class="hr"><?php echo htmlspecialchars("Código")." " ?></td> <td class="dr"><input type="text" name="id" value="<?php echo str_replace('"', '"', trim($row["id])) ?>"></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Nome")." " ?></td> <td class="dr"><textarea cols="35" rows="4" name="nome" maxlength="100"><?php echo str_replace('"', '"', trim($row["nome"])) ?></textarea></td> </tr> <tr> <td class=hr"><?php echo htmlspecialchars("Login")." " ?></td> <td class="dr"><input type="text" name="usuario" maxlength="50" value="<?php echo str_replace('"', '"', trim($row["usuario])) ?>"></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Senha")." " ?></td> <td class="dr"><input type="text" name="senha" maxlength="6" value="<?php echo str_replace('"', '"', trim($row["senha"])) ?>"></td> </tr> <tr> <td class=hr"><?php echo htmlspecialchars("Nível")." " ?></td> <td class="dr"><input type="text" name="nivel" maxlength="10" value="<?php echo str_replace('"', '"', trim($row["nivel])) ?>"></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Cargo")." " ?></td> <td class="dr"><textarea cols="35" rows="4" name="cargo" maxlength="80"><?php echo str_replace('"', '"', trim($row["cargo"])) ?></textarea></td> </tr> <tr> <td class=hr"><?php echo htmlspecialchars("Email")." " ?></td> <td class="dr"><textarea cols="35" rows="4" name="email" maxlength="100"><?php echo str_replace('"', '"', trim($row["email])) ?></textarea></td> </tr> </table> <?php } ?> <?php function showpagenav($page, $pagecount) { ?> <table class="bd" border="0" cellspacing="1" cellpadding="4"> <tr> <td><a href="Users.php?a=add">Adicionar</a> </td> <?php if ($page > 1) { ?> <td><a href="Users.php?page=<?php echo $page - 1 ?>"><< Anterior</a> </td> <?php } ?> <?php global $pagerange; if ($pagecount > 1) { if ($pagecount % $pagerange != 0) { $rangecount = intval($pagecount / $pagerange) + 1; } else { $rangecount = intval($pagecount / $pagerange); } for ($i = 1; $i < $rangecount + 1; $i++) { $startpage = (($i - 1) * $pagerange) + 1; $count = min($i * $pagerange, $pagecount); if ((($page >= $startpage) && ($page <= ($i * $pagerange)))) { for ($j = $startpage; $j < $count + 1; $j++) { if ($j == $page) { ?> <td><b><?php echo $j ?></b></td> <?php } else { ?> <td><a href="Users.php?page=<?php echo $j ?>"><?php echo $j ?></a></td> <?php } } } else { ?> <td><a href="Users.php?page=<?php echo $startpage ?>"><?php echo $startpage ."..." .$count ?></a></td> <?php } } } ?> <?php if ($page < $pagecount) { ?> <td> <a href="Users.php?page=<?php echo $page + 1 ?>">Próximo >></a> </td> <?php } ?> </tr> </table> <?php } ?> <?php function showrecnav($a, $recid, $count) { ?> <table class="bd" border="0" cellspacing="1" cellpadding="4"> <tr> <td><a href="Users.php">Início</a></td> <?php if ($recid > 0) { ?> <td><a href="Users.php?a=<?php echo $a ?>&recid=<?php echo $recid - 1 ?>">Anterior</a></td> <?php } if ($recid < $count - 1) { ?> <td><a href="Users.php?a=<?php echo $a ?>&recid=<?php echo $recid + 1 ?>">Próximo</a></td> <?php } ?> </tr> </table> <hr size="1" noshade> <?php } ?> <?php function addrec() { ?> <table class="bd" border="0" cellspacing="1" cellpadding="4"> <tr> <td><a href="Users.php">Início</a></td> </tr> </table> <hr size="1" noshade> <form enctype="multipart/form-data" action="Users.php" method="post"> <p><input type="hidden" name="sql" value="insert"></p> <?php $row = array( "id" => "", "nome" => "", "usuario" => "", "senha" => "", "nivel" => "", "cargo" => "", "email" => ""); showroweditor($row, false); ?> <p><input type="submit" name="action" value="Salvar"></p> </form> <?php } ?> <?php function viewrec($recid) { $res = sql_select(); $count = sql_getrecordcount(); mysql_data_seek($res, $recid); $row = mysql_fetch_assoc($res); showrecnav("view", $recid, $count); ?> <br> <?php showrow($row, $recid) ?> <br> <hr size="1" noshade> <table class="bd" border="0" cellspacing="1" cellpadding="4"> <tr> <td><a href="Users.php?a=add">Adicionar</a></td> <td><a href="Users.php?a=edit&recid=<?php echo $recid ?>">Editar</a></td> <td><a href="Users.php?a=del&recid=<?php echo $recid ?>">Apagar</a></td> </tr> </table> <?php mysql_free_result($res); } ?> <?php function relrec() { global $conn; global $order; global $ordtype; global $filter; global $filterfield; global $wholeonly; global $consult; $filterstr = sqlstr($filter); if (!$wholeonly && isset($wholeonly) && $filterstr!='') $filterstr = "%" .$filterstr ."%"; $sql = "SELECT `id`, `nome`, `usuario`, `senha`, `nivel`, `cargo`, `email` FROM `Users`"; if (isset($filterstr) && $filterstr!='' && isset($filterfield) && $filterfield!='') { $sql .= " where " .sqlstr($filterfield) ." like '" .$filterstr ."'"; } elseif (isset($filterstr) && $filterstr!='') { $sql .= " where (`id` like '" .$filterstr ."') or (`nome` like '" .$filterstr ."') or (`usuario` like '" .$filterstr ."') or (`senha` like '" .$filterstr ."') or (`nivel` like '" .$filterstr ."') or (`cargo` like '" .$filterstr ."') or (`email` like '" .$filterstr ."')"; $servidor = "mysql.alexanderfleming.com.br"; $usuario = "alexa1br"; $senha = "38alex14"; $bd = "alexa1br"; $titulo = "Relatório de Usuários do Sistema"; $imagem = "../../imagens/logorel.jpg"; $end_fpdf = "../../fpdf"; $por_pagina = 13; $end_final = "usuarios.pdf"; //D-> DOWNLOAD OU I-> MOSTRA O ARQUIVO NO BROWSER $tipo_pdf = "I"; $conn = mysql_connect("host", "user", "password"); $db = mysql_select_db("alexa1br", $conn); $sql = mysql_query($sql, $conn); $row = mysql_num_rows($sql); if(!$row) { echo "Não retornou nenhum registro"; die; } $paginas = ceil($row/$por_pagina); //PREPARA PARA GERAR O PDF define("FPDF_FONTPATH", "$end_fpdf/font/"); require_once("$end_fpdf/fpdf.php"); $pdf = new FPDF("L","mm","A4"); //P - Retrato e L - Paisagem $linha_atual = 0; $inicio = 0; for($x=1; $x<=$paginas; $x++) { //VERIFICA $inicio = $linha_atual; $fim = $linha_atual + $por_pagina; if($fim > $row) $fim = $row; $pdf->Open(); $pdf->AddPage(); $pdf->SetFont("Arial", "B", 10); $pdf->Image($imagem, 10, 8); // imagem, deslocamento da esquerda, altura. $pdf->Ln(2); $pdf->Cell(270, 8, "Página $x de $paginas", 0, 0, 'R'); $pdf->Ln(20); $pdf->Cell(5, 8, "", 1, 0, 'C'); $pdf->Cell(90, 8, "NOME", 1, 0, 'C'); $pdf->Cell(20, 8, "USUARIO", 1, 0, 'C'); $pdf->Cell(15, 8, "SENHA", 1, 0, 'C'); $pdf->Cell(15, 8, "NIVEL", 1, 0, 'C'); $pdf->Cell(40, 8, "CARGO", 1, 0, 'C'); $pdf->Cell(90, 8, "EMAIL", 1, 1, 'C'); for($i=$inicio; $i<$fim; $i++) { $pdf->Cell(5, 8, mysql_result($sql, $i, "ID"), 1, 0, 'C'); $pdf->Cell(90, 8, mysql_result($sql, $i, "NOME"), 1, 0, 'L'); $pdf->Cell(20, 8, mysql_result($sql, $i, "USUARIO"), 1, 0, 'L'); $pdf->Cell(15, 8, mysql_result($sql, $i, "SENHA"), 1, 0, 'L'); $pdf->Cell(15, 8, mysql_result($sql, $i, "NIVEL"), 1, 0, 'C'); $pdf->Cell(40, 8, mysql_result($sql, $i, "CARGO"), 1, 0, 'L'); $pdf->Cell(90, 8, mysql_result($sql, $i, "EMAIL"), 1, 1, 'L'); $linha_atual++; }//FECHA FOR(REGISTROS - i) }//FECHA FOR(PAGINAS - x) //SAIDA DO PDF $pdf->Output("$end_final", "$tipo_pdf"); } } ?> <?php function editrec($recid) { $res = sql_select(); $count = sql_getrecordcount(); mysql_data_seek($res, $recid); $row = mysql_fetch_assoc($res); showrecnav("edit", $recid, $count); ?> <br> <form enctype="multipart/form-data" action="Users.php" method="post"> <input type="hidden" name="sql" value="update"> <input type="hidden" name="xid" value="<?php echo $row["id"] ?>"> <?php showroweditor($row, true); ?> <p><input type=submit" name="action" value="Salvar"></p> </form> <?php mysql_free_result($res); } ?> <?php function deleterec($recid) { $res = sql_select(); $count = sql_getrecordcount(); mysql_data_seek($res, $recid); $row = mysql_fetch_assoc($res); showrecnav("del", $recid, $count); ?> <br> <form action="Users.php" method="post"> <input type="hidden" name="sql" value="delete"> <input type="hidden" name="xid" value="<?php echo $row["id] ?>"> <?php showrow($row, $recid) ?> <p><input type="submit" name="action" value="Confirmar"></p> </form> <?php mysql_free_result($res); } ?> <?php function connect() { $conn = mysql_connect("host", "user", "password"); mysql_select_db("alexa1br"); return $conn; } function sqlvalue($val, $quote) { if ($quote) $tmp = sqlstr($val); else $tmp = $val; if ($tmp == "") $tmp = "NULL"; elseif ($quote) $tmp = "'".$tmp."'"; return $tmp; } function sqlstr($val) { return str_replace("'", "''", $val); } function sql_select() { global $conn; global $order; global $ordtype; global $filter; global $filterfield; global $wholeonly; global $consult; $filterstr = sqlstr($filter); if (!$wholeonly && isset($wholeonly) && $filterstr!='') $filterstr = "%" .$filterstr ."%"; $sql = "SELECT `id`, `nome`, `usuario`, `senha`, `nivel`, `cargo`, `email` FROM `Users`"; if (isset($filterstr) && $filterstr!='' && isset($filterfield) && $filterfield!='') { $sql .= " where " .sqlstr($filterfield) ." like '" .$filterstr ."'"; } elseif (isset($filterstr) && $filterstr!='') { $sql .= " where (`id` like '" .$filterstr ."') or (`nome` like '" .$filterstr ."') or (`usuario` like '" .$filterstr ."') or (`senha` like '" .$filterstr ."') or (`nivel` like '" .$filterstr ."') or (`cargo` like '" .$filterstr ."') or (`email` like '" .$filterstr ."')"; } if (isset($order) && $order!='') $sql .= " order by `" .sqlstr($order) ."`"; if (isset($ordtype) && $ordtype!='') $sql .= " " .sqlstr($ordtype); $res = mysql_query($sql, $conn) or die(mysql_error()); return $res; } function sql_getrecordcount() { global $conn; global $order; global $ordtype; global $filter; global $filterfield; global $wholeonly; $filterstr = sqlstr($filter); if (!$wholeonly && isset($wholeonly) && $filterstr!='') $filterstr = "%" .$filterstr ."%"; $sql = "SELECT COUNT(*) FROM `Users`"; if (isset($filterstr) && $filterstr!='' && isset($filterfield) && $filterfield!='') { $sql .= " where " .sqlstr($filterfield) ." like '" .$filterstr ."'"; } elseif (isset($filterstr) && $filterstr!='') { $sql .= " where (`id` like '" .$filterstr ."') or (`nome` like '" .$filterstr ."') or (`usuario` like '" .$filterstr ."') or (`senha` like '" .$filterstr ."') or (`nivel` like '" .$filterstr ."') or (`cargo` like '" .$filterstr ."') or (`email` like '" .$filterstr ."')"; } $res = mysql_query($sql, $conn) or die(mysql_error()); $row = mysql_fetch_assoc($res); reset($row); return current($row); } function sql_insert() { global $conn; global $_POST; $sql = "insert into `Users` (`id`, `nome`, `usuario`, `senha`, `nivel`, `cargo`, `email`) values (" .sqlvalue(@$_POST["id"], false).", " .sqlvalue(@$_POST["nome"], true).", " .sqlvalue(@$_POST["usuario"], true).", " .sqlvalue(@$_POST["senha"], true).", " .sqlvalue(@$_POST["nivel"], true).", " .sqlvalue(@$_POST["cargo"], true).", " .sqlvalue(@$_POST["email"], true).")"; mysql_query($sql, $conn) or die(mysql_error()); } function sql_update() { global $conn; global $_POST; $sql = "update `Users` set `id`= .sqlvalue(@$_POST["id], false).", `nome`=" .sqlvalue(@$_POST["nome"], true).", `usuario`= .sqlvalue(@$_POST["usuario], true).", `senha`=" .sqlvalue(@$_POST["senha"], true).", `nivel`= .sqlvalue(@$_POST["nivel], true).", `cargo`=" .sqlvalue(@$_POST["cargo"], true).", `email`= .sqlvalue(@$_POST["email], true) ." where " .primarykeycondition(); mysql_query($sql, $conn) or die(mysql_error()); } function sql_delete() { global $conn; $sql = "delete from `Users` where " .primarykeycondition(); mysql_query($sql, $conn) or die(mysql_error()); } function primarykeycondition() { global $_POST; $pk = ""; $pk .= "(`id`"; if (@$_POST["xid"] == "") { $pk .= " IS NULL"; }else{ $pk .= " = " .sqlvalue(@$_POST["xid"], false); }; $pk .= ")"; return $pk; } ?>