Estou estreando neste fórum com uma dúvida que me persegue já há algum tempo.
estou desenvolvendo um sistema simples que insere um artigo com seus dados e logo após em outra tabela o(s) seu(s) autor(es) em um looping usando o mysql_insert_id() da primeira operação.
Tudo funciona beleza no localhost (uso o XAMPP 1.7.0), mas quando subo para o servidor e rodo o script, obtenho uma tela branca e um famigerado "No database selected".
Posto o código aqui na esperança de que alguém venha a perceber algo que não percebi.
<?php require_once('../../Connections/sistema.php');
ob_start();
?>
<?php session_start(); ?>
<?php include("../includes/prot_session.php"); ?>
<?php include("../../includes/functions.php"); ?>
<?php
$_SESSION['artigos'] = array();
if((!isset($_POST['enviar'])) AND (!isset($_POST['definir'])) AND (!isset($_POST['remover_autor'])) AND (!isset($_POST['inserir_autor']))){
unset($_SESSION['autores']);
}
function post_envio()
{
mantemTudo();
$artigo_tipoletra = $_SESSION['artigos']['tipoc'];
$artigo_tipo = $_SESSION['artigos']['tipo'];
$artigo_resumo = $_SESSION['artigos']['resumo'];
$artigo_link = $_SESSION['artigos']['link'];
$artigo_palavra = $_SESSION['artigos']['palavra'];
mysql_select_db($database_sistema);
$insertSQL = "insert into artigo (tipo, palavra, resumo, link, tipoc) values ('$artigo_tipo', '$artigo_palavra', '$artigo_resumo', '$artigo_link', '$artigo_tipoletra')";
$Gravacao = mysql_query($insertSQL) or die(mysql_error());
$_SESSION['last_id'] = mysql_insert_id();
$w = 0;
for($w=0; $w<count($_SESSION['autores']); $w++)
{
$id2 = $_SESSION['last_id'];
$autor = $_SESSION['autores'][$w]['autor'];
mysql_select_db($database_sistema);
$insertSQL_2 = "insert into autor_artigo (id_artigo, autor) values ('$id2', '$autor')";
$Gravacao2 = mysql_query($insertSQL_2) or die(mysql_error());
}
/////
unset($_SESSION['artigos']);
unset($_SESSION['autores']);
$updateGoTo = "../inicio/comeco.php";
header(sprintf("Location: %s", $updateGoTo));
}
function post_inserir_autor()
{
$pos = count($_SESSION['autores']);
$_SESSION['autores'][$pos]['autor'] = $_POST['autor'];
// echo count($_SESSION['fontes']) ."<br />";
// print_r($_SESSION['fontes']);
mantemTudo();
}
function post_remover_autor()
{
$i = 0;
$tmp_localidade = array();
while ($i < count($_SESSION['autores']))
{
if (!isset($_POST['remover_autor'][$i]))
$tmp_localidade[count($tmp_localidade)] = $_SESSION['autores'][$i];
$i = $i + 1;
}
unset($_SESSION['autores']);
$_SESSION['autores'] = $tmp_localidade;
mantemTudo();
}
function mantemTudo(){
$_SESSION['artigos']['tipoc'] = $_POST['tipoc'];
if($_SESSION['artigos']['tipoc'] == "O"){
$_SESSION['artigos']['tipo'] = $_POST['tipo'];
}else{
$_SESSION['artigos']['tipo'] = descricao_artigo($_POST['tipoc']);
}
$_SESSION['artigos']['resumo'] = $_POST['resumo'];
$_SESSION['artigos']['link'] = $_POST['link'];
$_SESSION['artigos']['palavra'] = $_POST['palavra'];
}
if(isset($_POST['definir'])){
mantemTudo();
}
if(isset($_POST['inserir_autor'])){
post_inserir_autor();
}
if(isset($_POST['remover_autor'])){
post_remover_autor();
}
if(isset($_POST['enviar'])){
post_envio();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="../css/manut.css">
<title>PAINEL DE CONTROLE - Inserir Artigo</title>
</head>
<body>
<div id="engloba">
<div><?php include("../includes/topo_int.php"); ?></div>
<div id="bloco">
<div id="menulat">
<div id="bloco2">
<div id="stufflayer">
<div id="primaLayer">
<div align="right">Usuário conectado - <a class="respondas_menos"><?php echo $MEU_NOME ?></a>.<img src="../img/line_dot.png" width="575" height="10" /></div>
<span class="breadcrumb"><a href="../inicio/comeco.php">Início</a> > Inserir Artigo, Parecer ou Outro</span></div>
<div align="center" class="respondas">Inserir Artigo, Parecer ou Outro</div>
<br />
<form action="inserir_artigo.php?" method="post" name="form1" id="form1" enctype="multipart/form-data" >
<table width="575" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="125" class="respondas_menos"> Tipo:</td>
<td width="450" height="35"><select name="tipoc" class="fakebody" id="tipoc" onchange="form.definir.click()">
<option value="A" <?php if (!(strcmp("A", $_SESSION['artigos']['tipoc']))) {echo "selected=\"selected\"";} ?>>Artigos</option>
<option value="P" <?php if (!(strcmp("P", $_SESSION['artigos']['tipoc']))) {echo "selected=\"selected\"";} ?>>Pareceres</option>
<option value="O" <?php if (!(strcmp("O", $_SESSION['artigos']['tipoc']))) {echo "selected=\"selected\"";} ?>>Outros</option>
</select>
<div style="display:none;">
<input type="submit" name="definir" id="definir" value="Definir" />
</div></td>
</tr>
<?php
if($_POST['tipoc']=="O")
{
?>
<tr>
<td class="respondas_menos"> Descrição:</td>
<td height="35"><input name="tipo" type="text" class="fakebody" id="tipo" value="<?php echo $_SESSION['artigos']['tipo'] ?>" size="70" width="450" /></td>
</tr>
<?php
}
?>
<tr>
<td class="respondas_menos"> Resumo:</td>
<td height="80"><textarea name="resumo" cols="70" rows="4" class="fakebody" width="450"><?php echo $_SESSION['artigos']['resumo'] ?></textarea></td>
</tr>
<tr>
<td class="respondas_menos"> Link</td>
<td height="35"><input name="link" type="text" class="fakebody" id="link" value="<?php echo $_SESSION['artigos']['link'] ?>" size="70" width="450" /></td>
</tr>
<tr>
<td class="respondas_menos"> Palavras-chaves</td>
<td height="35"><input name="palavra" type="text" class="fakebody" id="palavra" value="<?php echo $_SESSION['artigos']['palavra'] ?>" size="70" width="450" /></td>
</tr>
<tr>
<td class="respondas_menos"> Autores</td>
<td height="35"><input name="autor" type="text" class="fakebody" id="autor" size="70" width="450" /></td>
</tr>
<tr>
<td height="45" colspan="2"><img height="1" width="430" src="../../imagens/spacer.gif" />
<input name="inserir_autor" type="submit" class="button2" id="inserir_autor" value="Inserir Autor" /></td>
</tr>
<?php
for($i=0; $i<count($_SESSION['autores']); $i++)
{
$escrevinhador = $_SESSION['autores'][$i]['autor'];
if(count($_SESSION['autores']) > 0 )
{
?>
<tr>
<td height="45" colspan="2"><table width="549" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="53"> </td>
<td width="429" class="simulabody"> <?php echo $escrevinhador ?></td>
<td width="67"><input name='remover_autor[<?php echo $i ?>]' type='submit' class='button' value='deletar' /></td>
</tr>
</table></td>
</tr>
<?php
}
}
?>
<tr>
<td height="45" colspan="2"><img height="1" width="430" src="../../imagens/spacer.gif" />
<input name="enviar" type="submit" class="button2" id="inserir_autor" value="Gravar Dados" /></td>
</tr>
</table>
</form>
</div>
<div id="menulat2">
<?php include("../includes/menu.php"); ?>
</div>
</div>
</div>
</div>
</div><!--/*fim do div principal*/-->
<br />
</body>
</html>
<?php
ob_end_flush();
?>Agradeço antecipadamente à atenção de todos.
Brito










