|
-
Jan 25th, 2006, 01:57 PM
#1
Thread Starter
Lively Member
Why is this happening?
Code:
$err_message='#0';
header('Location: ../index.php?a=1'.$err_message.'');
Somehow, the # character and everything after it is disappearing? I tried to rawurlencode the # character, and rawurldecoded it's equivalent %23. No dice.
Anyone know what is going on here or how I could fix it?
Many thanks.
Last edited by solitario; Jan 25th, 2006 at 02:27 PM.
-
Jan 25th, 2006, 02:57 PM
#2
Re: Why is this happening?
 Originally Posted by solitario
Code:
$err_message='#0';
header('Location: ../index.php?a=1'.$err_message.'');
Somehow, the # character and everything after it is disappearing? I tried to rawurlencode the # character, and rawurldecoded it's equivalent %23. No dice.
Anyone know what is going on here or how I could fix it?
Many thanks.
WHat do you missapearing? it can't just didsapear, something must either stop it being inserted ot has removed it.
Is that the old part of code related?
On another note the .'' at the end is nt required, this will work:
PHP Code:
header('Location: ../index.php?a=1' . $err_message);
Cheers,
Ryan Jones
-
Jan 25th, 2006, 03:35 PM
#3
Thread Starter
Lively Member
Re: Why is this happening?
I know, it's very strange.
Here's the whole page.
Basically, I'm trying to put in some error handling in which if a user tries to upload an image which does not match specific dimensions, that user would then be redirected back with, e.g., "#0" in the URL. I would then use that to display an error.
Everything is working, except this $err_message variable.
Again, thanks to anyone who can figure this out.
Code:
<?
## DO A SECURITY CHECK ##
$can_modify=true;
if ($_COOKIE['permissions']>1) {if ($_COOKIE['restaurant_id'] != $_GET['restaurant_id']) {$can_modify=false;}}
if ($can_modify==false) {
mysql_close();
} else {
## PROCESS SOME VARIABLES ##
$err_message='';
## LOCK THE TABLES ##
$sql='LOCK TABLES dining_users WRITE';
mysql_query($sql) or die (mysql_error());
## UPDATE THE image_thumbnail COLUMN IN THE DATABASE ##
if (strlen($_FILES['txt_thumbnail']['name'])>0) {
$split_name = explode(".", $_FILES['txt_thumbnail']['name']);
if (end($split_name) ==strtolower('jpg') || end($split_name) ==strtolower('gif')) {
$file_extension = '.'.end($split_name);
if ($_FILES['txt_thumbnail']['size']>6144) {
## SELECTED FILE => 6K ##
$err_message='#0';
} else {
## READ THE TEMPORARY FILE ##
$temp_name = $_FILES['txt_thumbnail']['tmp_name'];
$temp_file = fopen($temp_name, "r");
$binary_data = fread($temp_file, fileSize($temp_name));
$old_error_reporting = error_reporting(E_ALL & ~(E_WARNING));
## CREATE THE FILE ##
$file_name = '../images/temp/'.$_GET['restaurant_id'].$file_extension;
touch($file_name);
$fp = fopen($file_name, 'w');
fwrite($fp, $binary_data);
error_reporting($old_error_reporting);
## CHECK THE IMAGE DIMENSIONS ##
$image = getimagesize('../images/temp/'.$_GET['restaurant_id'].$file_extension);
$width=$image[0];
$height=$image[1];
if ($width != 60 || $height != 60) {
$err_message='#1';
} else {
## GOOD TO GO ##
## UPDATE THE DATABASE ##
$sql='UPDATE dining_users SET image_thumbnail="'.$_GET['restaurant_id'].$file_extension.'" WHERE restaurant_id='.$_GET['restaurant_id'].'';
mysql_query($sql) or die (mysql_error());
## MOVE THE FILE ##
$temp_file = fopen('../images/temp/'.$_GET['restaurant_id'].$file_extension, "r");
$binary_data = fread($temp_file, fileSize($temp_name));
$old_error_reporting = error_reporting(E_ALL & ~(E_WARNING));
## CREATE THE FILE ##
$file_name = '../images/restaurant_thumbnails/'.$_GET['restaurant_id'].$file_extension;
touch($file_name);
$fp = fopen($file_name, 'w');
fwrite($fp, $binary_data);
error_reporting($old_error_reporting);
## DELETE THE TEMP FILE ##
@unlink('../images/temp/'.$_GET['restaurant_id'].$file_extension);
}
}
} else {
$err_message='#2';
}
}
## UNLOCK THE TABLES ##
$sql='UNLOCK TABLES';
mysql_query($sql) or die (mysql_error());
mysql_close();
## REDIRECT THE USER ##
header('Location: ../index.php?a=1'.$err_message);
}
?>
-
Jan 25th, 2006, 03:39 PM
#4
Re: Why is this happening?
Have you tried something like this:
PHP Code:
<?php
$err_message = '#0';
$err_string_full = 'Location: ../index.php?a=1' . $err_message;
header($err_string_full);
?>
Also, have you debugged and made shure that $err_message is getting set?
Cheers,
Ryan Jones
-
Jan 26th, 2006, 03:12 AM
#5
Thread Starter
Lively Member
Re: Why is this happening?
Thanks sciguyryan.
Ok folks, the mystery deepens:
At the bottom of the processing page I wrote:
Code:
$err_message = '#0';
$err_string_full = 'Location: ../index.php?a=1'.$err_message;
echo $err_string_full; die();
//The above worked just fine, producing "Location: ../index.php?a=1#0"
Now, on the index page (to which the above script redirected) I wrote:
Code:
echo $_SERVER["QUERY_STRING"]; die();
// Which produced "a=1". The anchor tag was gone.
Very strange.
-
Jan 26th, 2006, 04:19 AM
#6
Re: Why is this happening?
The anchor location is not part of the query string 
Does it not work at all? i.e. it does not jump to that anchor position?
-
Jan 26th, 2006, 10:12 AM
#7
Thread Starter
Lively Member
Re: Why is this happening?
 Originally Posted by penagate
Does it not work at all? i.e. it does not jump to that anchor position?
The pound sign and everything after it disappears.
I've just found I'm not the only one:
bugs.php.net
#9699
#24554
#17067
Oh well, I guess I'm going to have to use javascript.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|