carnot Posted December 25, 2006 Share Posted December 25, 2006 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 152Line 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 : [email protected] * * $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 preenchidosRequired field(s) validation- By NavSurfVisit NavSurf.com at http://navsurf.comVisit 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áginasredirTime = "3000"; //TemporedirURL = "adm_noticias.php"; //urlfunction redirTimer(){self.setTimeout("self.location.href = redirURL;",redirTime);}</script></head><?phprequire("../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 dadosif(! @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 setadaif(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 supernewsif(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ícia foi alterada com sucesso! <br>Você está sendo redirecionado para o Painel de Administração</font></p>");} else {echo("<p align=\"center\"><font color=\"#FF0000\">Erro na alteração da notícia " . mysql_error() . '</font></p><br>');}}echo("</body></html>");?><?phpelse://Caso a variavel envia não foi setada?><body><?php //Verifica se a variavel editar foi setadaif(isset($_GET['editar']))://Realiza a consulta no banco de dados, e coloca o resultado no formulárioif(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í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í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ú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\">«« Painel de Administração</a><br><br><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">Copyright © 2003 - <a class=\"email\" href=\"mailto:[email protected]\">SuperNews - Sistema de Notícias</a> - Todos os direitos reservados - all rights reserved</font></center>");}} else {echo("<font color=\"#FF0000\">Erro na alteração da notícia " . mysql_error() . '</font><br>');}?><?phpelse: //Caso a variável Editar não esteja setadaecho("<center><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">A Notícia não foi especificada para edição, retorne para o arquivo <a class=\"noticia\" href=\"noticias.php\" target=\"_self\">noticias.php</a> e especifique a Notícia para edição</font></center>");endif;?></body></html><?phpendif;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/ Share on other sites More sharing options...
ted_chou12 Posted December 25, 2006 Share Posted December 25, 2006 what language is this in? please explain what it is trying to say and indicate line 152 where the error is Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147683 Share on other sites More sharing options...
carnot Posted December 25, 2006 Author Share Posted December 25, 2006 line 152 is <form action=\"$_SERVER['PHP_SELF']\" method=\"post\" onsubmit=\"return formCheck(this);\">this is portuguese...this is a script to edit news... a very basic one.This one is part of the admins scripts... Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147685 Share on other sites More sharing options...
ted_chou12 Posted December 25, 2006 Share Posted December 25, 2006 try<form action=\"$_SERVER['PHP_SELF']\" method=\"post\" onsubmit=\"javascript:(return formCheck(this));\">btw i dont know if it might work or not... Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147686 Share on other sites More sharing options...
carnot Posted December 25, 2006 Author Share Posted December 25, 2006 no, it didn't work... Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147688 Share on other sites More sharing options...
ted_chou12 Posted December 25, 2006 Share Posted December 25, 2006 <form action=\"$_SERVER['PHP_SELF']\" method=\"post\" onsubmit=\"formCheck(this);\">ps. is the return important? do you really need it? Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147691 Share on other sites More sharing options...
kenrbnsn Posted December 25, 2006 Share Posted December 25, 2006 Try using single quotes around the string and concatenation so you get rid of the escaped quotes:[code]<?phpecho '<form action="' . $_SERVER['PHP_SELF'] . '" method="post" onsubmit="javascript:(return formCheck(this));">';?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147692 Share on other sites More sharing options...
carnot Posted December 25, 2006 Author Share Posted December 25, 2006 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 152to 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... Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147694 Share on other sites More sharing options...
ted_chou12 Posted December 26, 2006 Share Posted December 26, 2006 try it without the ";" so just this:<?phpecho '<form action="' . $_SERVER['PHP_SELF'] . '" method="post" onsubmit="javascript:(return formCheck(this))">';?> Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147703 Share on other sites More sharing options...
carnot Posted December 26, 2006 Author Share Posted December 26, 2006 it didn't work...same error...Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\Program Files\VertrigoServ\www\SuperNews\admin\editar.php on line 152 Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147706 Share on other sites More sharing options...
ted_chou12 Posted December 26, 2006 Share Posted December 26, 2006 is not very esay to solve, maybe you should try another approach method, instead of using javascript to check, why not all php? what do you want to check for, i can write it for you. Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147708 Share on other sites More sharing options...
carnot Posted December 26, 2006 Author Share Posted December 26, 2006 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"; Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147711 Share on other sites More sharing options...
ted_chou12 Posted December 26, 2006 Share Posted December 26, 2006 how about the form check? the javascript function? Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147712 Share on other sites More sharing options...
carnot Posted December 26, 2006 Author Share Posted December 26, 2006 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! Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147715 Share on other sites More sharing options...
ted_chou12 Posted December 26, 2006 Share Posted December 26, 2006 I think this should work, tell me if it does or doesn't:[code]<?phpif(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] Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147716 Share on other sites More sharing options...
carnot Posted December 26, 2006 Author Share Posted December 26, 2006 in which line of the code am i supposed to add this? Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147718 Share on other sites More sharing options...
ted_chou12 Posted December 26, 2006 Share Posted December 26, 2006 add it anywhere you like, if you dont know just add it at the end. Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147719 Share on other sites More sharing options...
ted_chou12 Posted December 26, 2006 Share Posted December 26, 2006 do you wish to check the input fields, if they are empty or not? Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147720 Share on other sites More sharing options...
carnot Posted December 26, 2006 Author Share Posted December 26, 2006 no need, dude it's still not working, could u send the whole script, deleting useless parts? Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147724 Share on other sites More sharing options...
ted_chou12 Posted December 26, 2006 Share Posted December 26, 2006 what is the problem? Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147725 Share on other sites More sharing options...
carnot Posted December 26, 2006 Author Share Posted December 26, 2006 Parse error: parse error, unexpected '&' in C:\Program Files\VertrigoServ\www\SuperNews\admin\editar.php on line 172$resultado = mysql_query("UPDATE titulo FROM supernews titulo='$titulo' WHERE ID='$id'") or die(mysql_error());  Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147726 Share on other sites More sharing options...
ted_chou12 Posted December 26, 2006 Share Posted December 26, 2006   this shouldnt be there... Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147728 Share on other sites More sharing options...
ted_chou12 Posted December 26, 2006 Share Posted December 26, 2006 i dont know why, but i think there is a bug in the script of the forum, it adds that into the script i posted. but i didnt put it there at all...Ted Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147729 Share on other sites More sharing options...
carnot Posted December 26, 2006 Author Share Posted December 26, 2006 dude, there is still an error, i'm going nuts...i'm sorry if this is too much to ask, but could you add the line , remove the 152 and let me test it...i've been trying to get this to work since 2pm... i'ts 10pm here Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147730 Share on other sites More sharing options...
ted_chou12 Posted December 26, 2006 Share Posted December 26, 2006 i dont know about your previous script, it drives me nuts...this should work fine independently, whats the problem? is 9am now and i still havnt sleep yet...my whole body is so heavy. Quote Link to comment https://forums.phpfreaks.com/topic/31840-parse-error/#findComment-147732 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.