Foros del Web » Programando para Internet » PHP »

PHP me da error con tan solo cambiar " por \"

Estas en el tema de PHP me da error con tan solo cambiar " por \" en el foro de PHP en Foros del Web. Tengo este action en un form: action=\"/jquery_upload_cropv1.2 (Aleluya)/upload_crop_v1.2.php?t=".$_SESSION['random_key'].$_SESSION['user_file_ext']."\" De esta manera me aparece forbidden, You don't have permission to access /"/jquery_upload_cropv1.2 on this server. Pero ...
  #1 (permalink)  
Antiguo 02/11/2013, 11:38
jorgemibanez
Invitado
 
Mensajes: n/a
Puntos:
Pregunta PHP me da error con tan solo cambiar " por \"

Tengo este action en un form:
action=\"/jquery_upload_cropv1.2 (Aleluya)/upload_crop_v1.2.php?t=".$_SESSION['random_key'].$_SESSION['user_file_ext']."\"

De esta manera me aparece forbidden, You don't have permission to access /"/jquery_upload_cropv1.2 on this server.

Pero si lo pongo así:
action="/jquery_upload_cropv1.2 (Aleluya)/upload_crop_v1.2.php?t='.$_SESSION['random_key'].$_SESSION['user_file_ext'].'"

Si funciona.

¿Alguien sabe por qué?

PD: Es necesario que lo use de la primera forma, por eso pregunto.
  #2 (permalink)  
Antiguo 02/11/2013, 11:50
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: PHP me da error con tan solo cambiar " por \"

Es difícil adivinar tanto porque no hay contexto, no podemos deducir que hay alrededor, que haces exactamente y como luce el código real.

Lo mas probable es que tengas problemas de comillas, pero a simple vista es imposible ayudarte si no comparte información más precisa.
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 02/11/2013, 12:10
jorgemibanez
Invitado
 
Mensajes: n/a
Puntos:
Exclamación Respuesta: PHP me da error con tan solo cambiar " por \"

Cita:
Iniciado por pateketrueke Ver Mensaje
Es difícil adivinar tanto porque no hay contexto, no podemos deducir que hay alrededor, que haces exactamente y como luce el código real.

Lo mas probable es que tengas problemas de comillas, pero a simple vista es imposible ayudarte si no comparte información más precisa.
Disculpa, no quise poner tanto porque es muy largo, pero bueno, ahí va:

(He cortado varias partes que no era necesarias para la consulta que hago ya que no se pueden superar los 10000 carácteres)

<?php

error_reporting (E_ALL ^ E_NOTICE);
session_start(); //Do not remove this
//only assign a new timestamp if the session variable is empty
if (!isset($_SESSION['random_key']) || strlen($_SESSION['random_key'])==0){
$_SESSION['random_key'] = strtotime(date('Y-m-d H:i:s')); //assign the timestamp to the session variable
$_SESSION['user_file_ext']= "";
}


if (isset($_POST["upload_thumbnail"]) && strlen($large_photo_exists)>0) {
//Get the new coordinates to crop the image.
$x1 = $_POST["x1"];
$y1 = $_POST["y1"];
$x2 = $_POST["x2"];
$y2 = $_POST["y2"];
$w = $_POST["w"];
$h = $_POST["h"];
//Scale the image to the thumb_width set above
$scale = $thumb_width/$w;
$cropped = resizeThumbnailImage($thumb_image_location, $large_image_location,$w,$h,$x1,$y1,$scale);
//Reload the page again to view the thumbnail
header("location:".$_SERVER["PHP_SELF"]);
exit();
}

if (isset($_POST["cancel_upload_thumbnail"]) && strlen($_GET['t'])>0) {

$large_image_location = $upload_path.$large_image_prefix.$_GET['t'];
if (file_exists($large_image_location)) {
unlink($large_image_location);
}
header("location:".$_SERVER["PHP_SELF"]);
exit();
}

if ($_GET['a']=="delete" && strlen($_GET['t'])>0){
//get the file locations
$large_image_location = $upload_path.$large_image_prefix.$_GET['t'];
$thumb_image_location = $upload_path.$thumb_image_prefix.$_GET['t'];
if (file_exists($large_image_location)) {
unlink($large_image_location);
}
if (file_exists($thumb_image_location)) {
unlink($thumb_image_location);
}
header("location:".$_SERVER["PHP_SELF"]);
exit();
}
?>




<!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" />
<meta name="generator" content="WebMotionUK" />
<title>Sistema de subida y edición de fotos de perfil</title>
<link rel="stylesheet" type="text/css" href="css/imgareaselect-default.css" />
<script type="text/javascript" src="scripts/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-pack.js"></script>
<script type="text/javascript" src="js/jquery.imgareaselect.min.js"></script>
</head>
<body style="margin: 0px;">
....

<?php
//Only display the javacript if an image has been uploaded
if(strlen($large_photo_exists)>0){
$current_large_image_width = getWidth($large_image_location);
$current_large_image_height = getHeight($large_image_location);?>
<script type="text/javascript">
function preview(img, selection) {
var scaleX = <?php echo $thumb_width;?> / selection.width;
var scaleY = <?php echo $thumb_height;?> / selection.height;

$('#thumbnail + div > img').css({
width: Math.round(scaleX * <?php echo $current_large_image_width;?>) + 'px',
height: Math.round(scaleY * <?php echo $current_large_image_height;?>) + 'px',
marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px',
marginTop: '-' + Math.round(scaleY * selection.y1) + 'px'
});
$('#x1').val(selection.x1);
$('#y1').val(selection.y1);
$('#x2').val(selection.x2);
$('#y2').val(selection.y2);
$('#w').val(selection.width);
$('#h').val(selection.height);
}

$(document).ready(function () {
$('#save_thumb').click(function() {
var x1 = $('#x1').val();
var y1 = $('#y1').val();
var x2 = $('#x2').val();
var y2 = $('#y2').val();
var w = $('#w').val();
var h = $('#h').val();
if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){
alert("You must make a selection first");
return false;
}else{
return true;
}
});
});

$(window).load(function () {
$('#thumbnail').imgAreaSelect({ aspectRatio: '1:<?php echo $thumb_height/$thumb_width;?>', aspectRatio: '1:<?php echo $thumb_height/$thumb_width;?>', handles: true, Height: 120, Width: 120, minHeight: 120, minWidth: 120, x1: 0, y1: 0, x2: 120, y2: 120, onSelectChange: preview });
});

</script>
<?php }?>

<?php
//Display error message if there are any
if(strlen($error)>0){
echo "<ul><li><strong>Error!</strong></li><li>".$error."</li></ul>";
}
if(strlen($large_photo_exists)>0 && strlen($thumb_photo_exists)>0){
echo $large_photo_exists."&nbsp;".$thumb_photo_exists;
echo "
<form id=\"_abcdef\" action=\"".$_SERVER["PHP_SELF"]."?a=delete&t=".$_SESSION['random_key'].$_SESSION['user_file_ext']."\">
<input type=\"submit\" value=\"Delete images\" aria-pressed=\"false\" role=\"button\">
</form>
";
echo "
<form action=\"".$_SERVER["PHP_SELF"]."\">
<input id=\"_uvwxyz\" type=\"submit\" value=\"Upload another\" aria-pressed=\"false\" role=\"button\">
</form>
";
//Clear the time stamp session and user file extension
$_SESSION['random_key']= "";
$_SESSION['user_file_ext']= "";
}else{
if(strlen($large_photo_exists)>0){?>
<div style="
width: 800px;
height: 420px;
margin: 0;
">
<div style="position: absolute; width: 800px; height: 375px; text-align: center;">
<div align="center">
<img src="<?php echo $upload_path.$large_image_name.$_SESSION['user_file_ext'];?>" style="display: block; margin: 0 auto;" id="thumbnail" alt="Create Thumbnail" />
<div style="border:1px #d8d8d8 solid; position: fixed; overflow:hidden; width: <?php echo $thumb_width;?>px; height: <?php echo $thumb_height;?>px; bottom: 370px; left: 710px; z-index: 2;">
<img src="<?php echo $upload_path.$large_image_name.$_SESSION['user_file_ext'];?>" style="position: relative;" alt="Thumbnail Preview" />
</div>

<form name="thumbnail" action="/jquery_upload_cropv1.2 (Aleluya)/upload_crop_v1.2.php" method="post">
<input type="hidden" name="x1" value="" id="x1" />
<input type="hidden" name="y1" value="" id="y1" />
<input type="hidden" name="x2" value="" id="x2" />
<input type="hidden" name="y2" value="" id="y2" />
<input type="hidden" name="w" value="" id="w" />
<input type="hidden" name="h" value="" id="h" />
<input type="submit" name="upload_thumbnail" value="Guardar foto de perfil" id="save_thumb">
</form>

<form id="_abcdef" action=\"".$_SERVER["PHP_SELF"]."?a=delete&t=".$_SESSION['random_key'].$_SESSION['user_file_ext']."\">
<input type="submit" value="Delete images" aria-pressed="false" role="button">
</form>


Lo que estoy intentando hacer es crear un botón "cancelar" que limpie la variables que cargan las fotos de perfil. Aunque esta página entera está un poco

Pero bueno, agradezco comentarios.
  #4 (permalink)  
Antiguo 02/11/2013, 12:57
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 1 mes
Puntos: 574
Respuesta: PHP me da error con tan solo cambiar " por \"

Código PHP:
Ver original
  1. <form id="_abcdef" action="<?php echo $_SERVER["PHP_SELF"]
  2.                                                          ."?a=delete&t="
  3.                                                          .$_SESSION["random_key"]
  4.                                                          .$_SESSION["user_file_ext"]; ?>">
  5. <input type="submit" value="Delete images" aria-pressed="false" role="button">
  6. </form>

Esto no sirve?

\" la barra esta combirtiendo las comillas dobles con significado de programación a un caracter normal....

igual que aqui \n convierte la n en un salto de linea...o a la inversa la n deja de ser un caracter normal...
__________________
Quim
--------------------------------------------------
Ayudar a ayudar es una buena práctica!!! Y da buenos resultados.

Última edición por quimfv; 02/11/2013 a las 13:04

Etiquetas: Ninguno
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:26.