I can't fix this error

A

Anonymous

Guest
My host required all of my .php files to be in a CGI directory. All the files must have this line of code at the top of the file:

#!/usr/local/bin/php4

I have a page that I have just received where the top has the following code:

#!/usr/local/bin/php4
<SCRIPT LANGUAGE="php">
session_cache_limiter('none');
session_start();
if(@$_SESSION["loggedon"] != "virtualstore"){
header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/login.php");
exit;
}
</SCRIPT>

This page can't even be viewed. But when I change the second line to:
<?php

and I put a:
?>

at the end of the 4 th line, I can then view the page from my server.

The problem is, that it is still not reading:
if(@$_SESSION["loggedon"] != "virtualstore"){
header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/login.php");
exit;

Anyone know what I can do?

Thanks,
Tom
 
try this

Code:
<?php
php code.....

instead of
<script....
 
ruturajv,

can you tell me exactly what I'm supposed to try. I'm new.

you said to try:
<?php
php code...

What comes after code? and do I still use: ?> and a </SCRIPT> in my script.

Here is exactly what I have at the moment:

#!/usr/local/bin/php4
<?php
session_cache_limiter('none');
session_start(); ?>

//This code is copyright (c) Internet Business Solutions SL, all rights reserved.
//The contents of this file are protect under law as the intellectual property
//of Internet Business Solutions SL. Any use, reproduction, disclosure or copying
//of any kind without the express and written permission of Internet Business
//Solutions SL is forbidden.
//Author: Vince Reid, vince@virtualred.net
if(@$_SESSION["loggedon"] != "virtualstore"){
header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/login.php");
exit;
}

<html>
<head>
<title>Admin</title>
<LINK REL=STYLESHEET TYPE="text/css" HREF="styles.css">

This is a template that I bought for my site. The only problem is, now when I go back them and ask how to fix it, they just tell me I should get another host. That I will do, but not until July 1st and I need to get this resolved .

Thanks for your help.
 
What ruturajv wanted to say was for you to try using the php's block code: <?php instead of <SCRIPT LANGUAGE="php">!

Ok, but like you´ve said, that way you can view the page source, right!?
Strange...!

Anyway, i suggest you to remove the @ in your if statement, so you can see the errors!
Code:
This:

if($_SESSION["loggedon"] != "virtualstore")

instead of:

if(@$_SESSION["loggedon"] != "virtualstore")
It´s possible for you to post the code of the page witch calls this one!? I mean where you set this: $_SESSION["loggedon"]!
 
Here is the URL of the page I'm having the problems with.

http://www.funny-tshirts.com/cgi/vsadmin/admin.php

Is that what you needed?
 
gesf,

I tried what you said. My code now looks like this:

#!/usr/local/bin/php4
<?php
session_cache_limiter('none');
session_start();

//This code is copyright (c) Internet Business Solutions SL, all rights reserved.
//The contents of this file are protect under law as the intellectual property
//of Internet Business Solutions SL. Any use, reproduction, disclosure or copying
//of any kind without the express and written permission of Internet Business
//Solutions SL is forbidden.
//Author: Vince Reid, vince@virtualred.net
if(@$_SESSION["loggedon"] != "virtualstore"){
header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/login.php");
exit; ?>
}

<html>

After I do this, I get the following error when I try to go to that page:
Parse error: parse error in /cgi/vsadmin/admin.php on line 139

I went and looked at line 139 and it is:
</html>

Not sure what to do.
 
Your if statement ends after this: }
So, it should be something like:
Code:
#!/usr/local/bin/php4 
<?php 
session_cache_limiter('none'); 
session_start(); 

//This code is copyright (c) Internet Business Solutions SL, all rights reserved. 
//The contents of this file are protect under law as the intellectual property 
//of Internet Business Solutions SL. Any use, reproduction, disclosure or copying 
//of any kind without the express and written permission of Internet Business 
//Solutions SL is forbidden. 
//Author: Vince Reid, vince@virtualred.net 

if(@$_SESSION["loggedon"] != "virtualstore"){ 
header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/login.php"); 
exit; 
} 
?>

BTW: Please use the code tag´s when posting a code!
 
gesf,

I tried the code you gave me and i'm getting a:

Http 500 - Internal server error
Internet Explorer
 
Just to let you know, here is the code for the whole page.

Code:
#!/usr/local/bin/php4 
<?php 
session_cache_limiter('none'); 
session_start(); 

//This code is copyright (c) Internet Business Solutions SL, all rights reserved. 
//The contents of this file are protect under law as the intellectual property 
//of Internet Business Solutions SL. Any use, reproduction, disclosure or copying 
//of any kind without the express and written permission of Internet Business 
//Solutions SL is forbidden. 
//Author: Vince Reid, vince@virtualred.net 

if(@$_SESSION["loggedon"] != "virtualstore"){ 
header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/login.php"); 
exit; 
} 
?>
<html>
<head>
<title>Admin</title>
<LINK REL=STYLESHEET TYPE="text/css" HREF="styles.css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">

</script>
</head>

<body bgcolor="#000033" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('images/homeov.gif','images/mainov.gif','images/passwordov.gif','images/logoutov.gif','images/catsov.gif','images/prodsov.gif','images/prodoptsov.gif','images/statesov.gif','images/countriesov.gif','images/postalov.gif','images/paymentov.gif','images/affiliatesov.gif','images/submitov.gif','images/feedbackov.gif','images/ordersov.gif','images/affiliateov.gif','images/discountsov.gif')">
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#000033">
  <tr> 
    <td width="280" rowspan="2"><img src="../../images/logo.gif" width="277" height="80"></td>
    <td class="dark" align="right" valign="bottom"><a class="dark" href="http://www.ecommercetemplates.com/help.asp" target="_blank">help</a> 
      - <a class="dark" href="http://www.ecommercetemplates.com/support/" target="_blank">forum</a> 
      - <a class="dark" href="http://www.ecommercetemplates.com/support/search.asp" target="_blank">search forum</a> - <a class="dark" href="http://www.ecommercetemplates.com/updaters.asp" target="_blank">updaters</a> - 
      <a class="dark" href="logout.php">log-out</a>  </td>
  </tr>
  <tr> 
    <td align="right"><img src="../../images/boxes.gif" width="450" height="27"></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td width="123" align="center" valign="top" bgcolor="#E7EAEF"><img src="../../images2/admin.gif" width="123" height="19"><br>
      <a href="admin.php"><img src="../../images2/homeov.gif" name="Image11" width="123" height="19" border="0"></a><br>
        <img src="../../images2/menuline.gif" width="119" height="1"><br>
      <a href="adminmain.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image15','','../../images2/mainov.gif',1)"><img src="../../images2/main.gif" name="Image15" width="123" height="19" border="0"></a><br>
        <img src="../../images2/menuline.gif" width="119" height="1"><br>
      <a href="adminorders.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image42','','../../images2/ordersov.gif',1)"><img src="../../images2/orders.gif" name="Image42" width="123" height="19" border="0"></a><br>
      <img src="../../images2/menuline.gif" width="119" height="1"><br>
      <a href="adminlogin.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image17','','../../images2/passwordov.gif',1)"><img src="../../images2/password.gif" name="Image17" width="123" height="19" border="0"></a><br>
		<img src="../../images2/menuline.gif" width="119" height="1"><br>
      <a href="adminpayprov.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image34','','../../images2/paymentov.gif',1)"><img src="../../images2/payment.gif" name="Image34" width="123" height="19" border="0"></a><br>
      <img src="../../images2/menuline.gif" width="119" height="1"><br>     <a href="adminaffil.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image45','','../../images2/affiliateov.gif',1)"><img src="../../images2/affiliate.gif" name="Image45" width="123" height="19" border="0"></a><br>
	  <img src="../../images2/menuline.gif" width="119" height="1"><br>
      <a href="logout.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image18','','../../images2/logoutov.gif',1)"><img src="../../images2/logout.gif" name="Image18" width="123" height="19" border="0"></a><br>
    
				
        <img src="../../images2/categories.gif" width="123" height="19"><br>
      <a href="admintopcats.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image20','','../../images2/topcatsov.gif',1)"><img src="../../images2/topcats.gif" name="Image20" width="123" height="19" border="0"></a><br>
		<img src="../../images2/menuline.gif" width="119" height="1"><br>
      <a href="admincats.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image22','','../../images2/catsov.gif',1)"><img src="../../images2/cats.gif" name="Image22" width="123" height="19" border="0"></a><br>
	  <img src="../../images2/products.gif"><br>
      <a href="adminprods.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image24','','../../images2/prodsov.gif',1)"><img src="../../images2/prods.gif" name="Image24" width="123" height="19" border="0"></a><br>
	  <img src="../../images2/menuline.gif" width="119" height="1"><br>
	  <a href="admindiscounts.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image47','','../../images2/discountsov.gif',1)"><img src="../../images2/discounts.gif" name="Image47" width="123" height="19" border="0"></a><br>
	  <img src="../../images2/menuline.gif" width="119" height="1"><br>
      <a href="adminprodopts.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image26','','../../images2/prodoptsov.gif',1)"><img src="../../images2/prodopts.gif" name="Image26" width="123" height="19" border="0"></a><br>
      <img src="../../images2/shipping.gif" width="123" height="19"><br>
      <a href="adminstate.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image28','','../../images2/statesov.gif',1)"><img src="../../images2/states.gif" name="Image28" width="123" height="19" border="0"></a><br>
	  <img src="../../images2/menuline.gif" width="119" height="1"><br>
      <a href="admincountry.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image30','','../../images2/countriesov.gif',1)"><img src="../../images2/countries.gif" name="Image30" width="123" height="19" border="0"></a><br>
	  <img src="../../images2/menuline.gif" width="119" height="1"><br>
      <a href="adminzones.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image32','','../../images2/postalov.gif',1)"><img src="../../images2/postal.gif" name="Image32" width="123" height="19" border="0"></a><br>
      <img src="../../images2/extras.gif" width="123" height="19"><br>
      <a href="http://www.ecommercetemplates.com/affiliateinfo.asp" target="_blank" onmouseover="MM_swapImage('Image36','','../../images2/affiliatesov.gif',1)" onmouseout="MM_swapImgRestore()"><img src="../../images2/affiliates.gif" name="Image36" width="123" height="19" border="0"></a><br>
	  <img src="../../images2/menuline.gif" width="119" height="1"><br>
      <a href="http://www.ecommercetemplates.com/addsite.asp" target="_blank" onmouseover="MM_swapImage('Image38','','../../images2/submitov.gif',1)" onmouseout="MM_swapImgRestore()"><img src="../../images2/submit.gif" name="Image38" width="123" height="19" border="0"></a><br>
	  <img src="../../images2/menuline.gif" width="119" height="1"><br>
      <a href="http://www.ecommercetemplates.com/support/" target="_blank" onmouseover="MM_swapImage('Image40','','../../images2/feedbackov.gif',1)" onmouseout="MM_swapImgRestore()"><img src="../../images2/feedback.gif" name="Image40" width="123" height="19" border="0"></a><br>
      <img src="../../images2/menuline.gif" width="119" height="1"><br>
      
      <p> </p></td>
    <td width="1" bgcolor="#000033"><img src="../../images2/clearpixel.gif" width="1" height="1"></td>
    <td width="19" valign="top" bgcolor="#FFFFFF"><img src="../../images2/tl.gif" width="19" height="19"></td>
    <td width="100%" valign="top" bgcolor="#FFFFFF"><br> 
      <table width="100%" border="0" cellpadding="2" cellspacing="2" bgcolor="#FFFFFF">
        <tr> 
          <td>
<SCRIPT LANGUAGE="php"> 
include "db_conn_open.php";
include "includes.php";
include "inc/incfunctions.php";
include "inc/incadmin.php";
</SCRIPT></td>
        </tr>
      </table></td>
    <td width="19" align="right" valign="top" bgcolor="#FFFFFF"><img src="../../images/tr.gif" width="19" height="19"></td>
    <td width="6" bgcolor="#000033"><img src="../../images/clearpixel.gif" width="6" height="1"></td>
  </tr>
  <tr> 
    <td bgcolor="#000033"> </td>
    <td width="1" bgcolor="#000033"><img src="../../images/clearpixel.gif" width="1" height="1"></td>
    <td><img src="../../images/bl.gif" width="19" height="19"></td>
    <td class="smaller" align="center" bgcolor="#FFFFFF">© Copyright 2002 <a href="http://www.ecommercetemplates.com/" target="_blank">Shopping 
      cart software</a> by ecommercetemplates.com</td>
    <td align="right"><img src="../../images/br.gif" width="19" height="19"></td>
  <td width="6" bgcolor="#000033"><img src="../../images/clearpixel.gif" width="6" height="1"></td>
  </tr>
  <tr> 
    <td colspan="3" bgcolor="#000033"> </td>
    <td bgcolor="#000033"> </td>
    <td colspan="2" bgcolor="#000033"> </td>
  </tr>
  
</table>
</body>
</html>

I think this is the code in the page that is not showing up:

Code:
<SCRIPT LANGUAGE="php"> 
include "db_conn_open.php";
include "includes.php";
include "inc/incfunctions.php";
include "inc/incadmin.php";
</SCRIPT></td>
 
1) Get rid of you <script language="PHP"></script> tags and put <?php ?> tags instead.
2) That 500 error is not a script error, HTTP 500 - Internal server error
In Internet Explorer
This problem occurs because there is an error processing the ASP or PHP script and "Friendly HTTP error messages" are enabled in Internet Explorer which do not allow you to see the details of the problem.
Solution:
In IE, turn off Friendly HTTP error messages by choosing tools - internet options - advanced. Then you should get the real error message and line number of the error.
3) There is no need to use include statements, use require_once() or just the require() functions, they seem to work better.
4) Get rid of your @ in front of $_Session variable

Instructions:
follow the instructions above one by one (meaning first you change the tags, then the IE error and so on). As you do each step execute the code and see whether the results change. If they do, post the new successes or failures, if not, continue following through with the instructions...
 
1st: I suggest you to don´t use yet the first php code (where is the session thing), untill everything is working properly!

2nd: Alex is right! Use this, instead of the above one:
Code:
<?php 
require "db_conn_open.php"; 
require "includes.php"; 
require "inc/incfunctions.php"; 
require "inc/incadmin.php"; 
?>
3rd: Try to comment/remove the following line to see what happens:
Code:
#!/usr/local/bin/php4
I think is is causing your '500 - Internal server error '!
 
AWESOME AWESOME!!!!!!

I followed the steps and BAM! Everything works great.

Thanks for all your help guys.

If your ever in Orlando, let me know and I will buy ya a beer!

Thanks again,
tom
 
there is nothing like to see a programmer feel yippy!!!! :-D :grin: :-D
 
I absolutely agree, there is nothing better than to see a programmer in a happy mood :grin: :-D :grin: :-D :grin: :-D :grin: :-D :grin:
 
Hey, I don't know anything about programming. I know a little HTML here and there. I'm pretty much a graphics guy.

I would like to learn how to code in PHP and use MYSQL. Anyone have a suggestion on how I could get started?

Thanks,
Tom
 
That´s true guys!

Thomhee, here you have a little php/mysql tutorial.
You can find more out there! Well, this will only give an idea on how to work with both php and mysql and will not teach you how to code!

Anyway, i suggest you to always use Php.net ... and this forum of course ;)
 
gesf,

If this will "not" teach me how to code, where would I start to learn how to code?

Thanks,
Tom
 
Well... i really don´t know!

It could be easier if you already have some programming languages knowledge, mainly C#!

I would suggest you to start read about php!
Try to make yourself some different scripts!
Use php.net the most you can!

You have to try and fail... this was what i did!
You can buy a php book too...!
 
Well, there are a few things you can do...
there are a lot of books on PHP out there that you can buy, and they seem to teach you very well how to code php and programming principals in general.
I also dont think that its a really good idea to learn C#, it is one of those .net based languages, and the only language i really think that is any good in .net platforms was VB.net just didnt like anything else. But for a beginner, PHP is a lot better to learn then C#, you dont have to deal with complicated object model and so forth, really PHP is great for beginners and pro's, it offers a great variety of different aspects that are easy to learn, yet can be used to create very complex websites or have a lot of other interesting applications...
Another great aspect of PHP is that it's free, the server, compiler and database are all free and available from their creator websites:
Apache
PHP
MySQL
Although it would be a lot easier for you to learn PHP if you have already had a little programming experience, i do not think that there is anything that will block you from learning it as a first.
There are a lot of tutorials that you can view online or even download that will teach you any language especially PHP, since it is the most widely used server side language on the entire net, just google it and you will find something out there that will sooth your needs...
 
Back
Top