Autor Tema: [ayuda] Sistema de noticias  (Leído 1065 veces)

Desconectado Katuz

  • PHPer@
  • **
  • Mensajes: 65
  • Karma: 1
  • Sexo: Masculino
  • TheGroX
    • Ver Perfil
    • HabbaThe Web fan
[ayuda] Sistema de noticias
« en: 05 de Agosto de 2011, 05:14:07 am »
bueno amigo andaba creando un sistema de noticias para mi pag pero me salieron algunos errores aqui les dejare los archivo y sus errores

mipagina.php
Código: [Seleccionar]
<!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=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<style type="text/css">
<!--
body {
margin-top: 0px;
}
-->
</style></head>

<body>
<table width="39%" border="1" align="center" cellpadding="5" cellspacing="2" bordercolor="#0066FF">
<tr bgcolor="#71B8FF">
  <td><div align="center">Noticias</div></td>
</tr>
<tr><td align="left" valign="top">

<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><?php 
mysql_connect
("mysql.webcindario.com","nueva_noticias");
mysql_select_db(&#39;nueva_noticias&#39;);
$re=mysql_query(&#39;select * from noticias order by id desc limit 0 ,3 &#39;);
while($f=mysql_fetch_array($re)){
echo &
#39;<tr>&#39;.$f[&#39;fecha&#39;].&#39;</td><br />&#39;;
echo &#39;<tr><a href="noticia.php?id=&#39;.$f[&#39;id&#39;].&#39;">&#39;.$f[&#39;titulo&#39;].&#39;</a></td></tr><br /><br />&#39;;

}
echo&
#39;<a href="todas.php">mas noticias</a>&#39;;
?>
</td>
        </tr>
      </table></td>
  </tr>
</table>
<div align="center"></div>
</body>
</html>

Error: http://nueva-noticias.webcindario.com/mipagina.php


noticia.php

Código: [Seleccionar]
<table width="50%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><?php 
mysql_connect
("mysql.webcindario.com","nueva_noticias");
mysql_select_db(&#39;nueva_noticias&#39;);
$re=mysql_query(&#39;select * from noticias where id ="&#39;.$_GET[&#39;id&#39;].&#39;" &#39;);
while($f=mysql_fetch_array($re)){
echo &
#39;<tr>&#39;.$f[&#39;fecha&#39;].&#39;</td><br />&#39;;
echo &#39;<tr>&#39;.$f[&#39;titulo&#39;].&#39;</td></tr><br /><br />&#39;;
echo &#39;<tr>&#39;.$f[&#39;noticia&#39;].&#39;</td></tr><br /><br />&#39;;
}

?>

</td>
  </tr>
</table>

Error: http://nueva-noticias.webcindario.com/noticia.php

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'nueva_noticias'@'192.168.0.61' (using password: NO) in /home/webcindario/n/u/nueva-noticias/noticia.php on line 4

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'apache'@'192.168.0.61' (using password: NO) in /home/webcindario/n/u/nueva-noticias/noticia.php on line 5

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/webcindario/n/u/nueva-noticias/noticia.php on line 5

Warning: mysql_query() [function.mysql-query]: Access denied for user 'apache'@'192.168.0.61' (using password: NO) in /home/webcindario/n/u/nueva-noticias/noticia.php on line 6

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/webcindario/n/u/nueva-noticias/noticia.php on line 6

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/webcindario/n/u/nueva-noticias/noticia.php on line 7


sistnoticias.php

Código: [Seleccionar]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>mis noticias</title>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script src="ckeditor/_samples/sample.js" type="text/javascript"></script>
<link href="ckeditor/_samples/sample.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- This <fieldset> holds the HTML that you will usually find in your
     pages. -->
<form action="sistnoticias.php" method="post">
<p>
<label for="editor1">Sistemas de noticia </label>
</p>
<p>
  <label>
  titulo
  <input name="titulo" type="text" id="titulo" />
  </label>
  <br/>
  <textarea cols="80" id="editor1" name="editor1" rows="10"></textarea>
  <script type="text/javascript">
//<![CDATA[

// This call can be placed at any point after the
// <textarea>, or inside a <head><script> in a
// window.onload event handler.

// Replace the <textarea id="editor"> with an CKEditor
// instance, using default configurations.
CKEDITOR.replace( 'editor1' );

//]]>
</script>
  </p>
<p>
  <label for="editor2"></label><input type="submit" value="Publicar"/>
      <a href="mipagina.php">ver noticia </a></p>
</form>
<?php 
$noticia 
$_POST[&#39;editor1&#39;];
$fecha=date(&#39;y-m-d&#39;);
$titulo=$_POST[&#39;titulo&#39;];
if($noticia!="" and $titulo!=""){
mysql_connect("mysql.webcindario.com","nueva_noticias");
mysql_select_db(&#39;nueva_noticias&#39;);
mysql_query("insert into noticias(titulo,fecha,noticia) values(&#39;$titulo&#39;,&#39;$fecha&#39;,&#39;$noticia&#39;)");
}
?>

<div id="footer"></div>
</body>
</html>

Error: http://nueva-noticias.webcindario.com/sistnoticias.php

Al publicar un mensaje sale lo siguiente:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'nueva_noticias'@'192.168.0.62' (using password: NO) in /home/webcindario/n/u/nueva-noticias/sistnoticias.php on line 51

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'apache'@'192.168.0.62' (using password: NO) in /home/webcindario/n/u/nueva-noticias/sistnoticias.php on line 52

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/webcindario/n/u/nueva-noticias/sistnoticias.php on line 52

Warning: mysql_query() [function.mysql-query]: Access denied for user 'apache'@'192.168.0.62' (using password: NO) in /home/webcindario/n/u/nueva-noticias/sistnoticias.php on line 53

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/webcindario/n/u/nueva-noticias/sistnoticias.php on line 53

todas.php

Código: [Seleccionar]
<table width="50%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><?php 
mysql_connect
("mysql.webcindario.com","nueva_noticias");
mysql_select_db(&#39;nueva_noticias&#39;);
$re=mysql_query(&#39;select * from noticias order by id desc &#39;);
while($f=mysql_fetch_array($re)){
echo &
#39;<tr>&#39;.$f[&#39;fecha&#39;].&#39;</td><br />&#39;;
echo &#39;<tr><a href="noticia.php?id=&#39;.$f[&#39;id&#39;].&#39;">&#39;.$f[&#39;titulo&#39;].&#39;</a></td></tr><br /><br />&#39;;
}

?>

</td>
  </tr>
</table>

Erro: http://nueva-noticias.webcindario.com/todas.php

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'nueva_noticias'@'192.168.0.65' (using password: NO) in /home/webcindario/n/u/nueva-noticias/todas.php on line 4

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'apache'@'192.168.0.65' (using password: NO) in /home/webcindario/n/u/nueva-noticias/todas.php on line 5

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/webcindario/n/u/nueva-noticias/todas.php on line 5

Warning: mysql_query() [function.mysql-query]: Access denied for user 'apache'@'192.168.0.65' (using password: NO) in /home/webcindario/n/u/nueva-noticias/todas.php on line 6

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/webcindario/n/u/nueva-noticias/todas.php on line 6

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/webcindario/n/u/nueva-noticias/todas.php on line 7

Bueno si ahy alguien que me ayude se lo pido =D  :D

Comunidad PHPeros

[ayuda] Sistema de noticias
« en: 05 de Agosto de 2011, 05:14:07 am »

Desconectado joshka

  • PHPerit@
  • *
  • Mensajes: 9
  • Karma: 0
  • Nuev@ PHPer@
    • Ver Perfil
Re:[ayuda] Sistema de noticias
« Respuesta #1 en: 05 de Agosto de 2011, 08:29:44 am »
Buenas Katuz, el problema creo que está en la llama a la función mysql_connect:

Código: [Seleccionar]
mysql_connect("mysql.webcindario.com","nueva_noticias");
¿nueva_noticias es un usuario?, si lo es ¿tiene contraseña?

Porque normalmente esa función suele usarse así:

Código: [Seleccionar]
mysql_connect(host, usuario, contraseña);
Mirate eso, porque está claro que ese tiene que ser el error.

Desconectado judoka

  • PHPero Avanzado
  • ****
  • Mensajes: 255
  • Karma: 4
  • Sexo: Masculino
  • Programando hasta lo mas alto.
    • Ver Perfil
Re:[ayuda] Sistema de noticias
« Respuesta #2 en: 05 de Agosto de 2011, 13:29:16 pm »
concuerdo con joshka, el error es la conexión a la BD.
Hazlo así:
Citar

$conectar 
mysql_connect(&#39;hostname&#39;, &#39;usuario&#39;, &#39;contraseña&#39;) or die(mysql_error()); //Esto abre la conexión con MySQL
mysql_select_db(&#39;BD_NAME&#39;, $conectar) or die(&#39;No se puede conectar con la base de datos.&#39;); //Esto selecciona la BD con la que trabajarás
mysql_query("SET NAMES &#39;utf8&#39;"); //Esto es opcional, pero te lo recomiendo para lo típico de los acentos, ñ, y tal...

Cambia los datos por los correctos y te debería funcionar ;)

Desconectado nmartin021

  • PHPero Avanzado
  • ****
  • Mensajes: 250
  • Karma: 9
    • Ver Perfil
Re:[ayuda] Sistema de noticias
« Respuesta #3 en: 05 de Agosto de 2011, 13:37:43 pm »
concuerdo con joshka, el error es la conexión a la BD.
Hazlo así:Cambia los datos por los correctos y te debería funcionar ;)
O eso, o ha ocultado la pass, no sería nada nuevo (para protegerla, claro)
EDIT:
Acabo de ver que el error sí está en lo que afirmas, en que no ha puesto la contraseña de la base de datos. Lo comprobé gracias al error que puso, decía: "using password: NO"
« Última modificación: 05 de Agosto de 2011, 13:39:40 pm por nmartin021 »

Desconectado guitobon

  • PHPerit@
  • *
  • Mensajes: 14
  • Karma: 0
  • Sexo: Masculino
  • Nuev@ PHPer@
    • Ver Perfil
    • Optimizacion WEB
Re:[ayuda] Sistema de noticias
« Respuesta #4 en: 05 de Agosto de 2011, 13:48:48 pm »
El error te lo da porque no le gusta el usuario/pass

En mysql, las cuentas se definen por "usuario", "pass" u "maquina o IP".

Que el usario/pass funcione desde shell (127.0.0.1) no quiere decir que vaya desde '192.168.0.61' (aunque sea tambien una IP del mismo server).

Comprueba que el usuario/pass para esa IP existe realmente.