Jump to content

Parse Error


carnot

Recommended Posts

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\VertrigoServ\www\SuperNews\admin\editar.php on line 152


Line 152 is <form action=\"$_SERVER['PHP_SELF']\" method=\"post\" onsubmit=\"return formCheck(this);\">

[code]<html>
<?php
/***************************************************************************
*                                editar.php
*                            -------------------
*   início                : Sexta-feira, 07 de novembro, 2003
*   copyright            : (C) 2003 Fernando Pontes
*   email                : odnanrefsetnop@uol.com.br
*
*   $Id: editar.php,v 1.00 07/11/2003 09:51:00
*
*
***************************************************************************/

/***************************************************************************
*
*
*
***************************************************************************/
include("../versao.inc"); ?>
<head>
<title>|--|<?php echo $versao; ?> - Editar Notíci@|--|</title>
<LINK href="adiminsupernews.css" type="text/css" rel="stylesheet">
<script language="JavaScript">
<!--

/*
Script que verifica se os campos foram preenchidos
Required field(s) validation- By NavSurf
Visit NavSurf.com at http://navsurf.com
Visit http://www.dynamicdrive.com for this script
*/

function formCheck(formobj){
//1) Enter name of mandatory fields
var fieldRequired = Array("titulo", "conteudo");
//2) Enter field description to appear in the dialog box
var fieldDescription = Array("titulo", "conteudo");
//3) Enter dialog message
var alertMsg = "O(s) campo(s) abaixo(s) é\\são obrigatório(s):\n";

var l_Msg = alertMsg.length;

for (var i = 0; i < fieldRequired.length; i++){
var obj = formobj.elements[fieldRequired[i]];
if (obj){
switch(obj.type){
case "select-one":
if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
case "select-multiple":
if (obj.selectedIndex == -1){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
case "text":
case "textarea":
if (obj.value == "" || obj.value == null){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
default:
if (obj.value == "" || obj.value == null){
alertMsg += " - " + fieldDescription[i] + "\n";
}
}
}
}

if (alertMsg.length == l_Msg){
return true;
}else{
alert(alertMsg);
return false;
}
}
//-->
</script>

<script language="JavaScript">
//redirecionamento de páginas
redirTime = "3000"; //Tempo
redirURL = "adm_noticias.php";  //url
function redirTimer(){
self.setTimeout("self.location.href = redirURL;",redirTime);}
</script>
</head>
<?php
require("../conexao.inc");
echo("<font face=\"Verdana,Arial,Helvetica,sans-serif\" size=\"2\" color=\"#000000\">");

//Conecta-se ao mysql
$conexao = @mysql_connect($host, $user, $pass);
if(!$conexao){
die("Impossível conectar-se ao mysql...<br>");
}

//Seleciona o banco de dados
if(! @mysql_select_db($db_super_news)){
die("Impossível conectar-se com o banco de dados: " . $db_super_news . '<br>');
}
?>

<?php //Verifica se a variavel envia foi setada
if(isset($_POST['envia'])):
echo("<body onLoad=\"redirTimer()\">");
echo("<font face=\"Verdana,Arial,Helvetica,sans-serif\" size=\"2\">");
//Se a notícia for submetida
//Adicina ao banco de dados supernews
if(isset($_POST['envia'])){
$id = $_POST['id'];
$titulo = $_POST['titulo'];
$conteudo = $_POST['conteudo'];
$sql =  "UPDATE supernews SET
        titulo='$titulo',
        conteudo='$conteudo'
        WHERE ID=$id";
if(@mysql_query($sql)){
echo("<p align=\"center\"><font color=\"#FF0000\">A not&iacute;cia foi alterada com sucesso!
      <br>Voc&ecirc; est&aacute; sendo redirecionado para o
      Painel de Administra&ccedil;&atilde;o</font></p>");
} else {
echo("<p align=\"center\"><font color=\"#FF0000\">Erro na altera&ccedil;&atilde;o da not&iacute;cia " . mysql_error() . '</font></p><br>');
}
}
echo("</body></html>");
?>

<?php
else://Caso a variavel envia não foi setada
?>

<body>
<?php //Verifica se a variavel editar foi setada
if(isset($_GET['editar'])):
//Realiza a consulta no banco de dados, e coloca o resultado no formulário
if(isset($_GET['editar'])){
$id = $_GET['editar'];
$sql = "SELECT titulo, conteudo FROM supernews WHERE ID=$id";
$resultado = mysql_query($sql);
while(list($titulo, $conteudo) = mysql_fetch_row($resultado)){
echo("<div align=\"center\">
<center>
<table border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"50%\">
<tr>
<td><p align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\" size=\"3\"><b>Alterar Not&iacute;cia</b></font></p><hr color=\"#000000\"></td>
</tr>
<tr>
<td>
<form action=\"$_SERVER['PHP_SELF']\" method=\"post\" onsubmit=\"return formCheck(this);\">
<input type=\"hidden\" name=\"id\" value=\"$id\">
<p align=\"left\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\" size=\"1\"><b>T&iacute;tulo:</b></font></p>
</td>
</tr>
<tr>
<td>
<input type=\"text\" maxlenght=\"250\" size=\"50\" name=\"titulo\" value=\"$titulo\">
</td>
</tr>
<tr>
<td>
<p align=\"left\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\" size=\"1\"><b>Conte&uacute;do</b></font></p>
</td>
</tr>
<tr>
<td>
<textarea rows=\"10\" cols=\"43\" name=\"conteudo\">$conteudo</textarea>
</td>
</tr>
<tr>
<td><input type=\"submit\" name=\"envia\" value=\"Enviar\"> | <input type=\"reset\" name=\"resetar\" value=\"Resetar\"></form>
</td>
</tr>
<tr>
<td>
<hr color=\"#000000\">
</td>
</tr>
</table>
</center>
</div>
<br><br>
<center>
<a class=\"noticia\" href=\"adm_noticias.php\" target=\"_self\">&laquo;&laquo; Painel de Administra&ccedil;&atilde;o</a>
<br><br>
<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">
Copyright &copy; 2003 - <a class=\"email\" href=\"mailto:odnanrefsetnop@bol.com.br\">SuperNews - Sistema de Not&iacute;cias</a> - Todos os direitos reservados - all rights reserved</font>
</center>");
}
} else {
echo("<font color=\"#FF0000\">Erro na altera&ccedil;&atilde;o da not&iacute;cia " . mysql_error() . '</font><br>');
}
?>

<?php
else: //Caso a variável Editar não esteja setada
echo("<center><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">A Not&iacute;cia n&atilde;o foi especificada para edi&ccedil;&atilde;o,
      retorne para o arquivo <a class=\"noticia\" href=\"noticias.php\" target=\"_self\">noticias.php</a> e
      especifique a Not&iacute;cia para edi&ccedil;&atilde;o</font></center>");

endif;
?>
</body>
</html>
<?php
endif;
?>[/code]
Link to comment
Share on other sites

the error changed to Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\Program Files\VertrigoServ\www\SuperNews\admin\editar.php on line 152
to explain this script...
it does the database query and put the result on a form so that i can edit it and post it again, then updating the database...
Link to comment
Share on other sites

basically, i want to


$sql = "SELECT titulo, conteudo FROM supernews WHERE ID=$id";
$resultado = mysql_query($sql);

and put the 'titulo' and 'conteudo' in a place where I can edit it... and then press some kind of submit button... submit will update the database with information I just edited

$sql =  "UPDATE supernews SET
        titulo='$titulo',
        conteudo='$conteudo'
        WHERE ID=$id";
Link to comment
Share on other sites

to tell you the truth, i don't even know what the heck was that line 152 doing here(the script didn't work without it...), I got this script from some random place and the author discontinued it... if you can do what I said... then i think, everything will be alright... thanks for your help man...

One thing I noticed, it's that when I take out line 152, the script will get the info from the database and put it on the form, but i can't submit it, when i press submit it just doesn't move, the button has no function, if you can fix this... i think it would work!
Link to comment
Share on other sites

I think this should work, tell me if it does or doesn't:
[code]
<?php
if(isset($_POST['submit'])){

$titulo = $_POST['titulo'];
$conteudo = $_POST['conteudo'];

if ($titulo == "" or $conteudo == ""){echo "Required fields are left blank";}
else
{
$resultado = mysql_query("UPDATE titulo FROM supernews titulo='$titulo' WHERE ID='$id'") or die(mysql_error()); 
$resultado = mysql_query("UPDATE conteudo FROM supernews conteudo='$conteudo' WHERE ID='$id'") or die(mysql_error());}}

$result = mysql_query("SELECT titulo, conteudo FROM supernews WHERE ID='$id'") or die(mysql_error()); 
$row = mysql_fetch_array( $result );
?>
<form  name="editar" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input name="titulo" value="<?php echo $row['titulo']?>" type="text" size="30" maxlength="30" />
<input name="conteudo" value="<?php echo $row['conteudo']?>" type="text" size="30" maxlength="30" />
<input class="button" name="submit" type="submit" />
</form>
[/code]
Link to comment
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.