Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/10/2011, 16:07
Lusini
 
Fecha de Ingreso: julio-2008
Mensajes: 84
Antigüedad: 15 años, 10 meses
Puntos: 0
Exclamación Gestor de noticias.

Buenas, estoy intentando crear un gestor de noticias para mi web, algo sencillo, no muy complicado, pero vistoso. Con la opción de subir una imagen. Bueno y encontre un tutorial en internet, pero lo puse a funcionar y me han salido los siguientes errores.


Notice: Undefined variable: usuario in C:\inetpub\vhosts\131innova.es\httpdocs\web\admin. php on line 15

Warning: imagejpeg() [function.imagejpeg]: Unable to open '/tmp/thumbtemp' for writing in C:\inetpub\vhosts\131innova.es\httpdocs\web\admin. php on line 44

Warning: fopen(/tmp/thumbtemp) [function.fopen]: failed to open stream: No such file or directory in C:\inetpub\vhosts\131innova.es\httpdocs\web\admin. php on line 59

Warning: filesize() [function.filesize]: Stat failed for /tmp/thumbtemp (errno=2 - No such file or directory) in C:\inetpub\vhosts\131innova.es\httpdocs\web\admin. php on line 60

Warning: fread(): supplied argument is not a valid stream resource in C:\inetpub\vhosts\131innova.es\httpdocs\web\admin. php on line 60

Warning: fclose(): supplied argument is not a valid stream resource in C:\inetpub\vhosts\131innova.es\httpdocs\web\admin. php on line 62

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: YES) in C:\inetpub\vhosts\131innova.es\httpdocs\web\admin. php on line 72

Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in C:\inetpub\vhosts\131innova.es\httpdocs\web\admin. php on line 72

En el servidor que lo he querido instalar es Windows no Linux, y creo que eso proboca vario de los fallos.

A continuacion les pongo el código:

Código PHP:
<?php include_once("config.php"); ?>
 
<?php 
// Verificamos que el formulario no ha sido enviado aun 
$postback = (isset($_POST["enviar"])) ? true false
if(
$postback){ 
// errores 
error_reporting(E_ALL); 
# Altura de el thumbnail en píxeles 
define("ALTURA"100); 
# Nombre del archivo temporal del thumbnail 
define("NAMETHUMB""/tmp/thumbtemp"); 
define("DBHOST""$servidor"); 
define("DBNAME""$database"); 
define("DBUSER""$usuario"); 
define("DBPASSWORD""$password"); 
$mimetypes = array("image/jpeg""image/pjpeg""image/gif""image/png"); 
$name $_FILES["foto"]["name"]; 
$type $_FILES["foto"]["type"]; 
$tmp_name $_FILES["foto"]["tmp_name"]; 
$size $_FILES["foto"]["size"]; 
if(!
in_array($type$mimetypes)) 
die(
"Seleciones una Imagen o El archivo que subiste no es una Imagen válida"); 
switch(
$type) { 
case 
$mimetypes[0]: 
case 
$mimetypes[1]: 
$img imagecreatefromjpeg($tmp_name); 
break; 
case 
$mimetypes[2]: 
$img imagecreatefromgif($tmp_name); 
break; 
case 
$mimetypes[3]: 
$img imagecreatefrompng($tmp_name); 
break; 

$datos getimagesize($tmp_name); 
$ratio = ($datos[1]/ALTURA); 
$ancho round($datos[0]/$ratio); 
$thumb imagecreatetruecolor($anchoALTURA); 
imagecopyresized($thumb$img0000$anchoALTURA$datos[0], $datos[1]); 
switch(
$type) { 
case 
$mimetypes[0]: 
case 
$mimetypes[1]: 
imagejpeg($thumbNAMETHUMB); 
break; 
case 
$mimetypes[2]: 
imagegif($thumbNAMETHUMB); 
break; 
case 
$mimetypes[3]: 
imagepng($thumbNAMETHUMB); 
break; 

# foto original 
$fp fopen($tmp_name"rb"); 
$tfoto fread($fpfilesize($tmp_name)); 
$tfoto addslashes($tfoto); 
fclose($fp); 
# thumbnail 
$fp fopen(NAMETHUMB"rb"); 
$tthumb fread($fpfilesize(NAMETHUMB)); 
$tthumb addslashes($tthumb); 
fclose($fp); 
// Borra archivos temporales 
@unlink($tmp_name); 
@
unlink(NAMETHUMB); 
//proceso de almacenamiento 
$fuente $_POST["fuente"]; 
$categoria $_POST["categoria"]; 
$titulo = (ucfirst($_POST["titulo"])); 
$subtitulo $_POST["subtitulo"]; 
$detalle = (nl2br(htmlspecialchars(urldecode($_POST["detalle"])))); 
$link mysql_connect(DBHOSTDBUSERDBPASSWORD) or die(mysql_error($link));; 
mysql_select_db(DBNAME$link) or die(mysql_error($link)); 
$sql "INSERT INTO noticia(fuente, categoria, titulo, subtitulo, detalle, foto, thumb, mime) 
VALUES 
('$fuente', '$categoria', '$titulo', '$subtitulo', '$detalle', '$tfoto', '$tthumb', '$type')"

mysql_query($sql$link) or die(mysql_error($link)); 
echo 
" Archivos Guardados, correctamente "
exit(); 

?>
 
<html> 
<head> 
<title>Mi Sistema de Noticia</title> 
</head> 
<body> 
<form name="frmimage" id="frmimage" method="post" 
enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>"> 
<p>Titulo<br /> 
<input name="titulo" type="text" class="text" id="titulo" /> 
</p> 
<p> Subtitulo<br /> 
<textarea name="subtitulo" id="subtitulo" cols="60" rows="5" tabindex="4"></textarea> 
</p> 
<p> Detalle<br /> 
<textarea name="detalle" id="detalle" cols="60" rows="10" tabindex="4"></textarea> 
</p> 
<p> 
Seleciones una imagen<br> 
<input name="foto" type="file" class="text" id="foto" /> 
</p> 
<p> 
</p> 
Fuente de la Noticia <br> 
<input name="fuente" type="text" class="text" id="fuente" /> 
</p> 
<p> 
Categoria:<br> 
<select name="categoria" id="categoria"> 
<option>PHP</option> 
<option>MySql</option> 
<option>CSS</option> 
<option>AJAX</option> 
<option>Seguridad</option> 
</select> 
</p> 
<p> 
<input name="fecha" type="hidden" id="fecha" /> 
<input name="enviar" type="submit" id="enviar" value="Publicar" /> 
</p> 
</form> 
</body> 
</html>
Si alguien sabe de algun gestor de noticias de codigo libre que funcione y tenga la opción de subir una imagen, y me lo puede aconsejar se lo agradeceria...

Gracias de antemano!