Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Force PHP Redirect Instead Of Displaying CGI Error


I am sure I found the answer before on here but I cant for the life of me find it now. I need to change the way one site in iis works when someone tries and goes to a non-existant php page, instead of displaying:

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Displaying An Image Based On URL Origination-URL Redirect
I have several domains that use splash pages that point to my main
site:
i.e. http://www.mysite.com/index.php.

How do I replace an image, named "Logo.gif" on the main page
"http://www.mysite.com/index.php" with the image named "logo.gif"
from the URL splashpage, " http://www.mysite.com/SanDiego/"

Both images are named logo.gif because the PHP script references
logo.gif through the script in too many places...It is just easier to
keep the name logo.gif

Problem:
If a user is on the San Diego page and clicks to the main page I want
the user to feel that the site is all about SanDiego.
If a user is on the Los Angeles page and clicks to the main page I want
the user to feel that the site is all about Los Angeles.

Hence the site and database will still be the same..I just want them to
feel the experience is personalized for their city and this will be
determined by changing the logo.gif.

I am using an image named logo.gif that will display SanDiego for the
San Diego page
I am using an image named logo.gif that will display Los Angeles for
the Los Angeles page

I have seen some PHP code that uses php echo $picture I am not sure if
this will work....

Redirect Error Reported As SQL Syntax Error
I just spent way too much time trying to track down an error that was incorrectly reported just now, and I would like to see if someone can explain to me why it was reported that way.

The purpose of the code is simply to delete a record and then redirect back to the page where the delete was started. The code looks like this:

elseif ($_GET[action] == "delete")
{
$query = "delete from product_subcategory2 where product_sku=$_GET[product_sku] and subcategory2_id=$_GET[subcategory2_id]";
$result = mysql_query($query) or die (mysql_error());
$affected_rows = mysql_affected_rows();

if ($affected_rows == 1)
{
header("Location:product.php?action=edit&product_sku=$product_sku");
}
else
{
do_header();
echo("<center><p class="body">Unable to delete Subcategory2. Please try again.</p>");
echo("<a href="product.php?action=edit&product_sku=$product_sku">Edit Product</a>");
do_footer();
}
}

The SQL was find, but the error I had was in the header line. What I had was this:

header("Location:product.php?action=edit&product_sku=<?php echo $product_sku?>");

so since I was already in PHP, I didn't need the "<?php echo" for $product_sku.

Redirect If Error 404
This is an apache question (little off-topic)

I have this .htaccess in web root
--------------
ErrorDocument 404 /error404handler.php
--------------
BUT I take in Mozilla this when I call a URL that dont exist:
--------------------
Not Found
The requested URL /this_dont_exist was not found on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an
ErrorDocument to handle the request.
---------------------

Redirect On Error Connecting To DB
When connecting to the DB and an error is thrown because let's say the DB is not running, can the browser be redirected to another page using an include or something. PHP Code:

Parse Error Redirect
lets say that a customer gets this error "parse error: parse error in C:*****secret root *****httpdocserror.php on line 1"

is there a way to have the customer redirected to an error page? i have custom error pages turn on in my plesk cp, but i cant figure out which one is for parsing errors. I got it to redirect if you went to a page that doesnt exists, but how do you that with pages that exists but has errors?

Header Error Using Redirect Scripts
I'm working on a site for a racquetball goods company where sponsored players can sign in each year using a unique player number. Before they can order their equipment for the year, they have to do three things; enter/update their personal information (personal.php), fill out fields in the contract (contract.php), and complete a questionaire on their home club (questionaire.php).

Once that is done, they will get to a menu page where they can order equipment, go back and update personal informa tion, and do other things. They way I'm controlling this is by using three Y/N fields in the player table that indicate whether or not these three steps have been completed. Once each step is completed, the appropriate field is updated, and they go to the next step. When all three steps are complete, they will be taken to the menu page.

This way, they can't get to the menu page until the three steps are complete, and if for some reason they bail between the first and second steps or between the second and third steps, when they log back in, they just pick up where they left off.

After reading through old posts on sessions and using header() to redirect the user to the appropriate page, I decided to use a couple redirect scripts for processing the form. So, for instance, when the user first logs in, redirect.php looks in the database to see which steps have been completed and redirects the user to the appropriate page. Here is the code:

Displaying Error Message
I've got a problem. I need to display an error message when unable to find a record. Below is one section of the code I'm working on. Code:

Not Displaying Error Messages
Is there a simple way to prevent error messages (falsely connecting to
database etc.) being diplayed?
My own build in messages are enough...

Error In Displaying MYSQL
I am having this problem at the moment with this script below. The probelm is that it keeps on chucking out an error:

QuoteParse error: parse error, unexpected $end in index.php on line 559
Online 559 is just the close of the html tag outside of the php. Code:

How To Redirect User To A Page When Error Occurs ?
I tried to play around with "error_reporting(0);" and "set_error_handler("showError");" but failed. How can I redirect a user to a page, like saying "sorry ...etc" whenever there's error occur, rather than showing the error message for every single error ?

Error Reporting And Displaying Errors
I've just switched to a dedicated server where php.ini has error_reporting all and display_errors off I need to see errors for debugging and when I try to set the local display_errors value to "1" or "ON" for a 1 page script that I know has errors, I still get no output.

I know its being set, because i run phpinfo() right after setting it and the display_errors value changes to ON NOTE: When I change display_errors in php.ini, they show up on the page Code:

Help With Displaying Selecting A Date Range And Displaying Results
I wish to create a simple form that allows the selection of a start date and a stop date with the ability to select what columns to be displayed in the result page.

How Do You Force A Download?
Hello, how do I force a file to be downloaded instead of displaying it? I have PHP and HTML files that I don't want to be displayed but downloaded. How would I do this?

Force Https
I want to make sure people are on the secure version of a page (https). If a person is on the regular http, how can I force them to go to https?

Trying To Force A Login
I have an include file that I use to secure pages with a login. When I check the password, Im also trying to check the login date While testing, Im setting the time difference to less than 10 seconds. So the idea is that when i login, then come back to a protected page more than 10 seconds later, I should be forced to login again. However, im not getting forced to login after a 10 second wait. Code:

$sQuery = "Select iUser From Table Where sGUID = '$sGUID' and TIMEDIFF($login_date,LogInDate) < &#3900;:00:10'";
. . .
//so if no returned records...
header('Location: Login.php');

Force PHP CLI To Stay In RAM?
I have a couple of command-line PHP scripts that are often called, and
I was wondering if it were possible to have the PHP interpreter remain
in RAM instead of being removed after the scipts end?

Force Reload
Is there any way I can force my php scripts to reload everytime they are used ?

Force A Download
i know that when i place a .zip, or .exe in my web directory, the  browser automatically asled the user to download the file. however i want to place a PDF into my site, and only make it available as a download, becauase i know that especially with IE and Firefox, it reads it within the browser instead.

how can i have the file a download, instead of read?

Force Post?
I'm wondering if there's a way to force a post from one page to another, without the user having to send it in a form.

If not, how do you make a textbox in a form automatically conain a variable in it (the post from the last page)?

Zip Files, Then Force Download
Is there any examples or scripts that already will do this?

I need to zip an arbitrary amount of files, say maybe a $files array full of path names to the files filled dynamically from database based on an id number...

then i need it to automatically force a download of the zip file to the browser, then automatically delete the zip file when its finished...

Force A Number To Have 2 Decimals
I have a query, and one of the results is a number that I want to forcefully have rounded to 2 decimal places. I couldn't find a good search query to find this if it's been asked before How can I achieve it, so it's like 1.00 or 187.25

$_REQUEST With Force Download
Im using this code forom the code snipits bit of the forum, but cant work out how to enter the file name?

I tried$file = $_REQUEST['/var/www/html/file.mp3']
but it gave me the error: QuoteNotice: Undefined index: /var/www/vhosts/qrecords.co.uk/httpdocs/PumpUpThePirates.mp3 in /var/www/html/file.mp3 on line 2
Code:

Force A Page To Be Re-validated?
I'm trying to force a page to be re-validated every time someone views it, even when they click the back button. I'm currently using:

header("Expires: " . gmdate("D, d M Y H:i:s", strtotime("-1 year")) . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");

However, my pages still seem to display without the server being called when the back button is pressed.

Can anyone suggest the correct headers/code I can use to force the server to be re-called when the back button is pressed?

Force Download .adr File
I have a .adr file (Opera bookmarks) that I want users of my website to download. The problem is that when I open it in my browser, it shows up just like a .css or .txt file, but I want to automatically start to download the file. I know there is a way to do that in php, but I don't know how.

How To Force A Download Of An Html File
I'm making a poll management system, and when the administrator creates a new poll I want an html file (containing the actual voting form) to be automatically forced to download via the save as dialog. How is this done? Secondly, I would prefer it not to have to be written to the server first. I just want to dump all of the text in a string variable to the save dialog.

Force Browser Download Of Content
Ok, this isn't a "How do i force the browser to download my file..." question.

This is a bit different because what i want to give the user isn't a file.

I want to provide a copy of a database table as a CSV file.

(force) Delete A Session File, How?
I dunno if this is meant for here or apache anyway.. my script uses sessions... if the person logsout.. the session is closed and the session file is deleted.. if the person just shuts down the browser the session file is not deleted and hence i've got hundreds of redundant session files.

Force 2 Decimal Places For Currency
How can I force a value to retain 2 decimal places (or atleast display them)? E.G. force $19.90 to be displayed as such, not $19.9

How Best To Avoid Brute-force Looping?
I have a style/php question. (I am a C hacker by background, and
thus everything is a loop... But PHP is different...)

I write out my array and read it back in. It comes in thus:

Array (
[currentField] => 103
[brgf1] => 0.000000
[brgt1] => 1.000000
[axa1] => 1
[brgf2] => 2.000000
[brgt2] => 2.000000
[axa2] => 2
[axb2] => 2
[axc2] => 2
[axd2] => 2
[brgf3] => 2.000000
[brgt3] => 3.000000
[axa3] => 2
[axb3] => 2
[axc3] => 2
[axd3] => 2

.....
.....
)

Basically each line consists of two bearings and 4 true/false switches.
The line number in the schedule is apended to the name of the field.

In my C mind, this calls for a loop, bruteforcing our way and appending
the counter to each name....

But I *know* there is a more elegant PHP way to do this. While it makes
sense in C, it just looks fugly in PHP....

As I use PHP to generate the field names, I can change those if it makes
things easier....

Force Download On Win2k Server
My win2k server has read write and execute permissions throughout the entire account and I can't really change it without removing those permissions throught the entire account, so what I need to do is force download an exe file, since just linking to it tries to execute it on the server. Is there some way in PHP or ASP that I can force it to download and not execute?

Any Way To Force Implict Variable Definition Etc?
A lot of languages you can force implict variable definition, where you must declare your variables at the top of the function/code before it's used. This way you create less bugs using the wrong variable name, which may not crop up until later on....

How Do I Force A FRESH RELOAD Of A Page
I've built a few php scripts, but since its reloading the same page I can't get it to refresh the page. I've implemented some expire meta tag...but is there anyway I can try and force it to refresh?

How Do You Force Received: Variable In Mail()?
I was able to change my Return-Path parameter
seen in the full headers of email sent with mail().

Now I still see my userID in the parameter as shown here seen in my full
headers of my email sent.

Received: (from userID@localhost) by mydomain.com

Is There A PHP Function To Force A Browser Refresh
I have an html page that gets updated about once a week. I would like to FORCE the browser (IE, Firefox, Netscape, or Opera) to REFRESH when the user opens the page to ensure they receive the latest update. Been searching around for some php code to add to the page to accomplish this without success. Can anyone give me a steer to how to accomplish this.

Create/force A New Session ID Different From The Existing One?
Is there a way to create/force a new session ID different from the existing one?

Force Header To Download File
I've created a document system that allows our company to upload files and create documents for internal use. I've completed the system except for the download system. When a user uploads a physical file say a .xls it's uploads outside of the home dir so it's not accessible via the web to anyone.

I'm trying to figure out the standard method for creating a download link for such a file. what it's the most common method for this? How can I cause the header or browser to call and then dowload the said file?

Php COPY Command... Any Way To Force Chmod 0660?
I want to copy my MySQL table via copy(oldtable, newtable) but I hear that the mode it sets is 0777.... Is there any way to force it to be anything else?

How Do You Force Return-Path: Variable In Mail()?
I am sending email using the mail() function on a hosted account. I am
trying to override the RETURN-PATH variable but it is not working. The
server keeps overriding the variable I put in.

Here's what I have:
.....
$headers = "From: me <me@mine.com>
"
$headers .= "Return-Path: me <me@mine.com>
";
.....

When I send one to myself and display full headers, it shows my
userID@myserver.com as the Return-Path.

WWW-Authenticate: How To Force Password Login At Every Page Refresh ?
<!--
The following sample should authorize the user to log on the site.
This works once but after refreshing the browser, it does not prompt
again for login until all browser (IE 6) windows are closed and the
same page is opened.
I turned off all caching but still it does cache (as a refresh doen
not promt again).

How can I force the page to prompt for a password at every refresh

-->

<html>
<head>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<?php

$showall = false;
error_reporting (E_ERROR);

if (($PHP_AUTH_USER != "myname") || ($PHP_AUTH_PW != "mypass"))
{
header('WWW-Authenticate: Basic realm="Secure Login"');
header('HTTP/1.0 401 Unauthorized');
$showall = false;
}
else
{
error_reporting (E_ALL ^ E_NOTICE);
$showall = true;
}

if (!showall) {
echo "access denied";
} else {
?>

................

</head>
<body>

.................

<? } ?>

</body>
</html>

How To Allow Downloaded Files To Be Splitted When Using A Force-download Script ?
I suppose you all know force-download scripts. The problem is that
these scripts don't allow files to be splitted when downloading them
via a download manager.
I've found a solution to enable download resuming, but now, it remains
the splitting problem. Does anyone have any idea ?

Force-downloading / Octet-streaming Multiple Files At Once
as my methods of file distribution involve the cloaking of the source, i am using application/force-download via urls using get variable methods to give authenticated users the file... only thing is, i can't get more than one stream to happen simultaneously.  when i choose another file, the page perpetually loads until the first download has finished.   

Anyone know how to make this work in my favor?  I have considered ziping the files into one, and am seeking out a script for that to happen (can that be done on the fly?).  I would like to do both. 

Force User To Enter Characters Into A Form Field?
I have a form that our visitors need to use to sign up for our newsletter... Country is a required field on this form.. and I have it set up for PHP to check and make sure some thing was entered but what I am finding is that lot of visitors are just putting in several spaces. I have it validating to make sure something was put it in and to make sure that it wasnt just one space.. but if they enter multiple spaces the form processes. Is there any way or built in function that anyone knows about that will make sure that characters are entered and just not a series of spaces? or will I have to look to javascript for that?

Force Reload Of Page When User Press "Back" Button
Is there a way to force a page to reload if a user har pressed the "Back" button in the browser.

"Force Download" Function
I've built a website that uses a force-download php script that's triggered by an on-click javascript event.

The script works fine when fired via javascript, but I'm trying to tweak it into an includable function that's generically portable and is triggered by an input button within an "empty" form - nothing's between the form tags but the input button and two hidden fields which feed the file name and directory path of the file to the download function.

The input trigger works, and the file name and path are passed succesfully, but I get a bunch of "can't modify header information" warnings.

The force-download script does have a bunch of header information in it.

Anyway, is there a way to make this work without using javascript?

"force" A Download
Ive got the following code.  however its telling me to download itself ( download.php), and not the file in the $_GET data...

<?php
header("Content-type: application/".$_GET['type']."");
header("Content-Disposition: attachment; ".$_GET['file'].";");
readfile("$_GET['file']");
?>

is this the correct code or do i need to try something different?  The data type will change.  at the moment the data types are as following:  .py, .java, .zip, .js( not sure).  We may also be downloading .exe etc.  *its a programmign website.

Email Script/Javascript Parse Error: Syntax Error, Unexpected T_STRING
I've made a email script to include javascript. Now what I want to do, is that I want to hide the link in status bar when I hover over it. I've implemented javascript into the code but I keep getting the following error:

Parse error: syntax error, unexpected T_STRING in /home/****/public_html/fbmail/contact.php on line 12

Here is line 12:
$message .= '<a href="http://www.mysite.com/" onMouseOver="window.status='Click here to continue.'; return true;" onMouseOut="window.status=''; ">Click here to continue ..</a>'; The complete code:

Error Reading WWW Server Response (HTTP Header). Error Code: 0
I have been trying out the web based email program on this website to connect to a pop 3 client...it worked ok...but now when i try to logg in all i get is this error message...on the page Error occurred!

Description: Error reading WWW server response (HTTP Header). Error code: 0(0 = client terminated the connection unexpectedly, 2 = too many header lines) Code:

Parse Error: Syntax Error, Unexpected T_ENCAPSED_AND_WHITESPACE, Expecting T_STR
I am having troubles entering this info into my db. Cna someone help? This is the error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/realfina/public_html/ec/testdobaapi.php on line 22 Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved