Foros del Web » Programando para Internet » PHP »

SOS - Parse error

Estas en el tema de SOS - Parse error en el foro de PHP en Foros del Web. saludos... estoy usando la funcion redimensionar imagen para un catalogo de productos pero tengo un problemilla... al integrarla me da este error... Parse error: syntax ...
  #1 (permalink)  
Antiguo 16/10/2008, 10:39
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
SOS - Parse error

saludos... estoy usando la funcion redimensionar imagen para un catalogo de productos pero tengo un problemilla... al integrarla me da este error...

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/indexa/public_html/multisillas/detalles_prod.php on line 77

aqui les dejo mis codigos a ver si pueden ayudarme...

redimensionar.php
Código PHP:

<?php

function imageResize($width$height$target) {


if (
$width $height) {
$percentage = ($target $width);
} else {
$percentage = ($target $height);
}

$width round($width $percentage);
$height round($height $percentage);


return 
"width=\"$width\" height=\"$height\"";

}

?>
y el catalogo o ficha del producto
Código PHP:
<?php require_once('Connections/multisillas.php'); 
include(
'redimensionar.php');

if (!
function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

$colname_Recordset1 "-1";
if (isset(
$_GET['id'])) {
  
$colname_Recordset1 $_GET['id'];
}
mysql_select_db($database_multisillas$multisillas);
$query_Recordset1 sprintf("SELECT * FROM productos WHERE id = %s"GetSQLValueString($colname_Recordset1"int"));
$Recordset1 mysql_query($query_Recordset1$multisillas) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);

$producto_ID $_GET['id'];

$sqlQuery mysql_query("SELECT * FROM productos
                         WHERE id = '$producto_ID'"
)
                         or die(
mysql_error());
$row mysql_fetch_array($sqlQuery);

if(!empty(
$producto_ID)){
    
$ip $_SERVER['REMOTE_ADDR'];
    
$hitProductoID $row['id']; 
    
$hitIP ip2long($ip);   
    
$date date("F j, Y, g:i a");
    
$sqlInsert mysql_query("INSERT INTO hits (hitIP, date, hitProductoID)
                              VALUES ('$hitIP', '$date', '$hitProductoID')"
)
    or die(
mysql_error());
}

$sqlHitsQuery mysql_query("SELECT * FROM hits
                             WHERE hitProductoID = '$producto_ID'"
)
                             or die(
mysql_error());
$hits mysql_num_rows($sqlHitsQuery);

$comprobarIP "SELECT hitIP FROM hits where hitIP = '$hitIP'" ;  
$res mysql_query($comprobarIP) or die(mysql_error());   

if (
mysql_num_rows($res) == 0) {   

$suma = (hitTotal 1);

mysql_query("UPDATE hits SET hitTotal = '$suma'") or die(mysql_error()); 
}  ;

?>

<?php $mysock getimagesize("imgprod/<?php echo $row_Recordset1['imagen']; ?>"); ?>


<link href="css/estilo.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<link href="lightbox.css" rel="stylesheet" type="text/css">

<table width="400" border="0" align="center" cellpadding="0" cellspacing="3">
  <tr class="textoResNot">
    <td height="10" colspan="2" valign="top"><?php echo "Producto visto"?><span class="textotitResNot"> <?php echo "$hits"?></span>
    <?php echo "veces";?></td>
  </tr>
  <tr>
    <td height="10" colspan="2" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td height="10" colspan="2" valign="top"><span class="textoMulti4"><?php echo $row_Recordset1['nombre']; ?></span></td>
  </tr>
  <tr>
    <td width="291" valign="top" class="textoMulti4"><table width="100%" border="0" cellspacing="3" cellpadding="0">
      <tr>
        <td><span class="textoRequeridos"><span class="textoMulti2">Código:</span> <span class="textoMulti5"><?php echo $row_Recordset1['codigo']; ?></span></span></td>
      </tr>
      <tr>
        <td><p class="textotitResNot">Características del producto: </p>
          <div align="justify"><span class="textoMulti2"><?php echo $row_Recordset1['descripcion']; ?></span> </div></td>
      </tr>
    </table></td>
    <td width="200" valign="top"><div align="center"><a href="imgprod/<?php echo $row_Recordset1['imagen']; ?>" rel="lightbox[roadtrip]"><img src="imgprod/<?php echo $row_Recordset1['imagen']; ?>" width="200" height="200"  border="0"/><br />
        <br />
      </a><span class="textoMulti2">Para ampliar haga click en la foto.</span><a href="imgprod/<?php echo $row_Recordset1['imagen']; ?><?php imageResize($mysock[0],  
$mysock[1], 150); ?> rel="lightbox[roadtrip]"><br />
        </a></div></td>
  </tr>
</table>

<?php
mysql_free_result
($Recordset1);
?>
Linea 77
Código PHP:
<?php $mysock getimagesize("imgprod/<?php echo $row_Recordset1['imagen']; ?>"); ?>
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #2 (permalink)  
Antiguo 16/10/2008, 11:03
Avatar de jaronu  
Fecha de Ingreso: febrero-2008
Mensajes: 2.183
Antigüedad: 16 años, 2 meses
Puntos: 52
Respuesta: SOS - Parse error

Hola

mira en el manual de PHP como se usa esa funcion y lo veras claro el error

http://es2.php.net/manual/es/function.getimagesize.php

pero de todas formas si te fijas en los colores del codigo veras que no es correcto lo que haces
Un saludo
  #3 (permalink)  
Antiguo 16/10/2008, 11:08
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: SOS - Parse error

ok entiendo... pero no puedo usar un echo para llamar a esa imagen??? es lo q no me funciona
ejemplo:
cambio la Linea77 por esto
Código PHP:
$miarchivo = echo $row_Recordset1['imagen']; 
$mysock getimagesize("imgprod/$miarchivo"); 
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #4 (permalink)  
Antiguo 16/10/2008, 11:14
Avatar de jaronu  
Fecha de Ingreso: febrero-2008
Mensajes: 2.183
Antigüedad: 16 años, 2 meses
Puntos: 52
Respuesta: SOS - Parse error

si la informacion de la imagen ya esta en la variable, no te hace falta el echo
echo es para imprimir en pantalla, que yo sepa.

lo has provado??

Un saludo
  #5 (permalink)  
Antiguo 16/10/2008, 11:14
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: SOS - Parse error

No es necesario el echo ahí para asignar la variable, solamente pon $miarchivo = $row...

Saludos.
  #6 (permalink)  
Antiguo 16/10/2008, 11:22
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: SOS - Parse error

uy... miren lo q paso

http://indexa.com.ve/multisillas/ficha_prod.php?id=8

codigo
Código PHP:
<?php require_once('Connections/multisillas.php'); 
include(
'redimensionar.php');

if (!
function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

$colname_Recordset1 "-1";
if (isset(
$_GET['id'])) {
  
$colname_Recordset1 $_GET['id'];
}
mysql_select_db($database_multisillas$multisillas);
$query_Recordset1 sprintf("SELECT * FROM productos WHERE id = %s"GetSQLValueString($colname_Recordset1"int"));
$Recordset1 mysql_query($query_Recordset1$multisillas) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);

$producto_ID $_GET['id'];

$sqlQuery mysql_query("SELECT * FROM productos
                         WHERE id = '$producto_ID'"
)
                         or die(
mysql_error());
$row mysql_fetch_array($sqlQuery);

if(!empty(
$producto_ID)){
    
$ip $_SERVER['REMOTE_ADDR'];
    
$hitProductoID $row['id']; 
    
$hitIP ip2long($ip);   
    
$date date("F j, Y, g:i a");
    
$sqlInsert mysql_query("INSERT INTO hits (hitIP, date, hitProductoID)
                              VALUES ('$hitIP', '$date', '$hitProductoID')"
)
    or die(
mysql_error());
}

$sqlHitsQuery mysql_query("SELECT * FROM hits
                             WHERE hitProductoID = '$producto_ID'"
)
                             or die(
mysql_error());
$hits mysql_num_rows($sqlHitsQuery);

$comprobarIP "SELECT hitIP FROM hits where hitIP = '$hitIP'" ;  
$res mysql_query($comprobarIP) or die(mysql_error());   

if (
mysql_num_rows($res) == 0) {   

$suma = (hitTotal 1);

mysql_query("UPDATE hits SET hitTotal = '$suma'") or die(mysql_error()); 
}  ;

$miarchivo $row_Recordset1['imagen'] ;
$mysock getimagesize("imgprod/$miarchivo");
?>




<link href="css/estilo.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<link href="lightbox.css" rel="stylesheet" type="text/css">

<table width="400" border="0" align="center" cellpadding="0" cellspacing="3">
  <tr class="textoResNot">
    <td height="10" colspan="2" valign="top"><?php echo "Producto visto"?><span class="textotitResNot"> <?php echo "$hits"?></span>
    <?php echo "veces";?></td>
  </tr>
  <tr>
    <td height="10" colspan="2" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td height="10" colspan="2" valign="top"><span class="textoMulti4"><?php echo $row_Recordset1['nombre']; ?></span></td>
  </tr>
  <tr>
    <td width="291" valign="top" class="textoMulti4"><table width="100%" border="0" cellspacing="3" cellpadding="0">
      <tr>
        <td><span class="textoRequeridos"><span class="textoMulti2">Código:</span> <span class="textoMulti5"><?php echo $row_Recordset1['codigo']; ?></span></span></td>
      </tr>
      <tr>
        <td><p class="textotitResNot">Características del producto: </p>
          <div align="justify"><span class="textoMulti2"><?php echo $row_Recordset1['descripcion']; ?></span> </div></td>
      </tr>
    </table></td>
    <td width="200" valign="top"><div align="center"><a href="imgprod/<?php echo $row_Recordset1['imagen']; ?>" rel="lightbox[roadtrip]"><img src="imgprod/<?php echo $row_Recordset1['imagen']; ?><?php imageResize($mysock[0],  
$mysock[1], 150); ?>  border="0"/><br />
        <br />
      </a><span class="textoMulti2">Para ampliar haga click en la foto.</span><a href="imgprod/<?php echo $row_Recordset1['imagen']; ?><?php imageResize($mysock[0],  
$mysock[1], 150); ?> rel="lightbox[roadtrip]"><br />
    </a></div></td>
  </tr>
</table>

<?php
mysql_free_result
($Recordset1);
?>
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #7 (permalink)  
Antiguo 16/10/2008, 11:33
Avatar de jaronu  
Fecha de Ingreso: febrero-2008
Mensajes: 2.183
Antigüedad: 16 años, 2 meses
Puntos: 52
Respuesta: SOS - Parse error

Y que fue lo que paso??

explicalo por que no se ve.
  #8 (permalink)  
Antiguo 16/10/2008, 11:34
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: SOS - Parse error

no se redimensiona y la imagen me la muestra totalmente enorme y fuera de la diagramacion...
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #9 (permalink)  
Antiguo 16/10/2008, 11:42
Avatar de jaronu  
Fecha de Ingreso: febrero-2008
Mensajes: 2.183
Antigüedad: 16 años, 2 meses
Puntos: 52
Respuesta: SOS - Parse error

pues el problema estara en tu codigo de redimension.

include('redimensionar.php');

Y te has dado cuenta, no se si es a proposito, que cuando pones el puntero sobre el sobre de contacto y la flecha de al lado, de tu web, se levanta la pestaña de productos?

Un saludo
  #10 (permalink)  
Antiguo 16/10/2008, 13:04
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: SOS - Parse error

y esto???
Código PHP:
<a href="imgprod/<?php echo $row_Recordset1['imagen']; ?>" rel="lightbox[roadtrip]"><img src="imgprod/<?php echo $row_Recordset1['imagen']; ?><?php imageResize($mysock[0],  
$mysock[1], 150); ?>  border="0"/><br />
y el codigo d redimension esta arriba.... en mi primer post :S
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #11 (permalink)  
Antiguo 16/10/2008, 13:17
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: SOS - Parse error

primero que te hace pensar que la llamada a imageResize debe ir ahí???

luego, que hace imageResize devuelve una ruta, recurso, etc???
(devolviendo la segunda, se resuelve la primera...)

__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #12 (permalink)  
Antiguo 16/10/2008, 13:17
Avatar de jaronu  
Fecha de Ingreso: febrero-2008
Mensajes: 2.183
Antigüedad: 16 años, 2 meses
Puntos: 52
Respuesta: SOS - Parse error

Haz echo algun echo de la variables de altura y anchura?

a ver si estan cogiendo bien su valor.

echo $mysock[1];
echo $mysock[0];
  #13 (permalink)  
Antiguo 16/10/2008, 13:21
Avatar de jaronu  
Fecha de Ingreso: febrero-2008
Mensajes: 2.183
Antigüedad: 16 años, 2 meses
Puntos: 52
Respuesta: SOS - Parse error

No se si leiste bien el manual de php sobre la funcion pero dice literalmente:

"El índice 3 es una cadena de texto con el valor height="yyy" width="xxx" apropiado que puede ser usado directamente en una etiqueta IMG. "

Un saludo
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:02.