Jump to content

script errors


semperfi

Recommended Posts

Hi everyone

 

I am pretty new to php but have been playing around with it for awhile. I have been trying to include a offline script from codecanyon located (http://codecanyon.net/item/web-construct/61643). The problem I am having is when I try to include the file as per the scripts instruction (<?php include("offline.php");?>) I get all sorts of errors on mysite (please see below for one error). I read his discussion section were one person is having the same problem I am having the script developers answers was (Place the webconstruct include after the session_start() line). I have tried that or think I did it right but still getting the same errors as before. Can someone please help me in getting this script installed? I will copy the session code below and if someone can point me to the right direction in how to resolve this issue I would be thankful.

 

(error)

Notice: Use of undefined constant

 

(my session code)

 

<?

if ( isset($_SESSION['url']) && $_SESSION['url'] != $SITE_URL ) {

    session_destroy();

    ?>

<script language="javascript">window.location.href="index.php";</script>

 

Thanks in advance for anyone's help!

Link to comment
Share on other sites

Update

 

This is the file I think were I should place the include file at and here is the code to the file. I tried every way and I still get errors same errors as above.

 

<?php

  include 'config/connect.php';

  include_once 'functions.php';

  include_once 'include/advertisefunction.php';

  $uid = (isset ($_SESSION['userid']) ? $_SESSION['userid'] : 0);

  $changeimage = 'home';

  $pagename = 'index';

  if ((!isset ($_SESSION['ipid']) AND !isset ($_SESSION['login_logout'])))

  {

    $_SESSION['ipid'] = date ('Y-m-d G:i:s');

    $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR'];

    $qryipins = 'Insert into login_logout (ipaddress,load_time) values(\'' . $_SESSION['ipaddress'] . '\', \'' . $_SESSION['ipid'] . '\')';

    if (!(mysql_query ($qryipins)))

    {

      exit (mysql_error ());

      (bool)true;

    }

  }

 

  $qryauc = 'select a.auctionID, adt.auc_due_price, price,adt.auc_due_time, p.name, p.picture1, p.productID from auction a ' . 'left join products p on a.productID=p.productID left join auc_due_table adt on a.auctionID=adt.auction_id ' . 'where adt.auc_due_time!=0 and a.auc_status=\'2\' order by adt.auc_due_time limit 0, 8';

  $resauc = mysql_query ($qryauc);

  $totalauc = mysql_num_rows ($resauc);

?>

 

Link to comment
Share on other sites

Thank you

 

This is one of many errors when I include the php file. It has to do with the session start putting it after but when i do I still get the same errors. I am sure that i am place the php file in the wrong place or need to change something simple to make it work.

 

Notice: Use of undefined constant RRP - assumed 'RRP' in /home/content/01/******/html/index.php on line 100

Notice: Use of undefined constant MORE_***** - assumed 'MORE_******' in /home/content/01/*****/html/index.php on line 143

 

This is only on the home page when I go to other pages in the site I get the undefined error in other places.

 

Again thank you for your help.....

 

Link to comment
Share on other sites

Here is the code and in bold is the php include file that is working when set offline but causing all kinds of DB errors when not set to offline.

 

<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />

<link rel="icon" href="animated_favicon.gif" type="image/gif" >

<link rel="apple-touch-icon" href="apple-touch-icon.png">

<div style="display: none">

 

</div>

<script language="javascript" type="text/javascript">

    var CurrencySymbol='<?php echo $Currency; ?>';

 

    function _delete_login_fields(_field, _default, _current) { if (_default == _current) { _field.value=''; } }

 

 

    function onBeforeUnloadAction() {

        $.ajax({

            type: "GET",

            url: "*******.php",

            success: function(responseData){

            }

        });

 

    }

 

    window.onbeforeunload = function(f) {

        if (!f) f = window.event;

        if (typeof f.pageX == "number") { X = f.pageX; Y = f.pageY; } else { X = f.clientX; Y = f.clientY; };

        if((X<0) || (Y<0)) { return onBeforeUnloadAction(); }

    }

 

    function UpdateLoginLogout() {

        $.ajax({

            type: "GET",

            url: "*******.php",

            success: function(responseData){

            }

        });

    }

</script>

<?

if ( isset($_SESSION['url']) && $_SESSION['url'] != $SITE_URL ) {

    session_destroy();

    ?>

<?php

include("offline.php");

?>

<script language="javascript">window.location.href="index.php";</script>

    <?

    exit;

}

 

function checkaucstatus($status) {

    if ( $status == "2" ) {

        $qryauc = "select count(*) from auction a left join auc_due_table adt on a.auctionID=adt.auction_id where adt.auc_due_time!=0 and auc_status='$status'";

    } elseif ( $status == 3 ) {

        $qryauc = "select count(*) from auction where auc_status='$status' and auc_final_end_date>='".CreateSelEndDate()."' and auc_final_end_date<='".date("Y-m-d")." 23:59:59'";

    } else {

        $qryauc = "select count(*) from auction where auc_status='$status'";

    }

    $rsauc = mysql_query($qryauc);

    $totalauc = mysql_result($rsauc, 0);

    mysql_free_result($rsauc);

 

    return $totalauc;

}

?>

 

<div id="header">

    <!--<div id="login-area">-->

            <div id="">

    </div><!-- /login-area -->

</div><!-- /header -->

<script language='javascript'>UpdateLoginLogout();</script>

 

I tried every way with the <? php ?> without it even tried every where on the page and still get the error. Any help now would be greatly appreciated.

 

Thank you

Link to comment
Share on other sites

You are getting 'Notices' which shouldn't terminate your script and are different from errors.  These types of Notices usually mean you're trying to use a string without quotes or you're just defining a constant incorrectly.  In your code I also noticed:

if ( isset($_SESSION['url']) && $_SESSION['url'] != $SITE_URL ) {

 

Where is $SITE_URL defined?

 

- I'm still not seeing where 'RRP' and 'MORE_*****' are being defined.  They should be in one of your include files.

- When posting code, please place your code inside


tags for syntax highlighting, formatting and general readability.

- The link you posted in your first post doesn't work, or at least we can't see the script you're trying to implement.

Link to comment
Share on other sites

Sorry new to this! and you are right about the differences between errors and Notices (My mistake). In regards to Where is $SITE_URL defined? It is defined in the config file

 <? php $SITE_URL='http://mysite.com/'; ?>

Also in regard to the RRP and More**** amongst other things they are defined from another file that gets updated via a cron job. Again new to this and if there is anymore info you need please let me know and thanks for your help. Only have this issue when I place the offline file into the site the offline when activated works great its just when turning it off the offline thats when I get the Notices. If I remove the php offline file everything works perfect. I know I am doing something wrong or not placing it in the right spot or the right way. 

 

Link to comment
Share on other sites

I cannot read your code, it doesn't have the use of CODE or PHP tags. Also, please change all your "<?" opening tags to "<?php" Stop being lazy :P

 

Notices, are quite often not very important, they can be turned off via having error reporting off. Although, in your notices, you are using a constant that isn't defined.

 

Is this the following line in which the notices you are getting are occurring?

if ( isset($_SESSION['url']) && $_SESSION['url'] != $SITE_URL ) {

Shortening the above, it could be used as..

if($_SESSION['url'] != $SITE_URL) {

because, if the session isn't set, well then it still wouldn't equal the site URL.

 

Now as I can't read your code, I can't find out the exact problem. connect.php has the mysql connection, defines $SITE_URL, and does your code have session_start() anywhere? Other than them... I can't exactly find a fix with the code being so hard to read.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.