cereal 1,524 Nearly a Senior Poster Featured Poster

If you're using composer then the package must be saved in the vendor folder. Run:

composer require dropbox/dropbox-sdk 1.1.*

This should fix the issue.

cereal 1,524 Nearly a Senior Poster Featured Poster

Have you tried to request the video through AJAX? The video link should be a script not a direct access to the file, for example:

<?php

# remove below comment to set the header and try the script
# $_SERVER['HTTP_AUTHENTICATION'] = 'test';

/**
 * verify token example
 * 
 * @param  string $token
 * @return bool
 */
function verify_auth($token)
{
    return in_array($token, ['test', 'abc']) ? :FALSE;
}

if(array_key_exists('HTTP_AUTHENTICATION', $_SERVER) === FALSE || verify_auth($_SERVER['HTTP_AUTHENTICATION']) === FALSE)
{
    header('HTTP/1.1 401 UNAUTHORIZED', TRUE, 401);
    die();
}

$path = '../videos/';
$file = pathinfo($_GET['v'], PATHINFO_BASENAME);
$resource = $path . $file;

if(file_exists($resource))
{
    $mime = (new Finfo(FILEINFO_MIME_TYPE))->file($resource);
    header('Content-Type: '.$mime);
    header('Content-Lenght: '.filesize($resource));
    readfile($resource);
}

else
{
    header('HTTP/1.1 404 NOT FOUND', TRUE, 404);
    die();
}

Example link for the above script looks like this: http://localhost:8888/video.php?v=file.mp4

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, have you tried this?

The SDK is contained in the lib/ folder in the zip file so copy lib/ into your project and name it dropbox-sdk/ and include it in your app:

    require_once "dropbox-sdk/Dropbox/autoload.php";

Source: https://www.dropbox.com/developers-v1/core/sdks/php

cereal 1,524 Nearly a Senior Poster Featured Poster

So, the restricted resource is served by your server, correct? I don't see how a meta tag could be processed by the server: the HTML page is the output of the server, it's the response to the client request.

When client ask access to a page it sends:

  • method (GET, POST)
  • address
  • query string and/or body
  • headers

If the page is returning the auth in his meta tags, it's just because your script prints that value in the meta tag:

<meta http-equiv="Authorization" content="<?php echo $_SERVER['HTTP_AUTHORIZATION']; ?>">

But this will not affect the request flow. Unless you don't want to parse the HTML source and then use it in your scripts.

As I'm not sure to have understood your request: does someone wants to help?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

I'm not sure I've understood what are you trying to do. The http-equiv meta:

it is a pragma directive, i.e. information normally given by the web server about how the web page should be served.

Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta

So, it defines the rendering of the page, not the header of the request that can start from the page.

But I need to add an oauth token, inside the Authorization header field, to get access to various protected resources, like images or video streams, that are not served through ajax but referenced, through an url, directly inside the html.

i.e. is this a clickable link?

Are you going to use PHP? If affirmative then set the headers through a curl request to get the response from the remote service, then output the results:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

it happens because of the variable scope, $conn is defined outside the function, so or you pass it as parameter, or you set it as global, or you use an anonymous function. Example:

$getUsers = function() use($conn) {
    $getAllUsers = mysqli_query($conn,"SELECT * FROM login");

    if($getAllUsers === FALSE)
        return FALSE;

    return mysqli_fetch_all($getAllUsers);
};

print_r($getUsers());
cereal 1,524 Nearly a Senior Poster Featured Poster

Try to remove the first line in the view page, from the screenshot it seems to be an empty line: there could be a BOM (UTF-8 signature) that can lead to problems with PHP.

For more information read:

cereal 1,524 Nearly a Senior Poster Featured Poster

Good, with fputcsv() you can do:

$list = $sql->fetchAll(PDO::FETCH_ASSOC);
$f = fopen('file.txt', 'w');

foreach($list as $line)
    fputcsv($f, $line);

fclose($f);

You need fetchAll() because you need an array, fetch() instead will return a single row of the result set. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,
it happens because fwrite() is outside the loop and will write the last vallue assigned at $line. Use fputcsv():

Look at the first example, it does what you need.

cereal 1,524 Nearly a Senior Poster Featured Poster

Model name is BooksModel (plural), in that method controller you're calling BookModel, (singular). Bye ;)

tejpatel commented: this might have happened +0
cereal 1,524 Nearly a Senior Poster Featured Poster

Oh, a backdoor! :D

I'm afraid it's not legal. If the client signed an agreement then, in cases you don't get payment, it's better to talk to a lawyer.

If you still want help with this, wait for other suggestions, I'm out.

cereal 1,524 Nearly a Senior Poster Featured Poster

So, all you want is to prevent hotlinks? Why don't you use .htaccess? It works without involving Javascript: if the request referer is your domain, then the server will give access to the protected files, otherwise it will deny.

You can try this:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif|css|js)$ - [NC,F,L]

Where the last rewrite rule defines the extensions of the file types you want to protect. By searching you can find many .htaccess rule generators, the above was created by:

But there are other solutions, always with .htaccess file, read here (bit old but always good start):

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

it happens because both tables will return the same column name tableA_id, since you're fetching as assoc, it will create an array in which the first index will be rewritten by the second column value. You see how it works by playing this:

<?php

    $stmt = $conn->prepare("select * from tableA left outer join tableB on tableA.tableA_id = tableB.tableA_id where tableB.tableA_id is null");
    $stmt->execute();
    $result = $stmt->fetchAll();

    print_r($result);

It will return both numeric and assoc index keys, so tableA_id index key will be empty, the numeric [0] and [4], instead, will show the current values i.e. 2 and null. Here's an example:

Array
(
    [0] => Array
        (
            [tableA_id] => 
            [0] => 2
            [title] => pneumonia
            [1] => pneumonia
            [month] => jan
            [2] => jan
            [tableB_id] => 
            [3] => 
            [4] => 
            [correspondence_ref] => 
            [5] => 
            [date_received] => 
            [6] => 
            [date_dispatched] => 
            [7] => 
        )

You see how tableA_id index is appearing only once? If you define the columns you want to return and use a column alias, then you can solve this issue.

So instead of select * do:

select tableA.tableA_id as tableAID, tableA.month, tableA.month, tableB.*

Note that if you were going to define a different WHERE condition (IS NOT NULL instead of IS NULL), you would not notice this error, as also the other columns would return populated. Check the examples here:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,
can you format code properly? At the moment it's very hard to read.

Regarding the user picture, have you tried the /{user-id}/picture endpoint?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

I don't understand what it should do your script, tested with a ciphered string and prints only ====. If you are searching for character frequency, then look at count_chars():

For example:

<?php

$message    = 'pda sknhz eo behhaz sepd oaynapo wjz iuopaneao fqop swepejc pk xa zeoykranaz';
$stats      = count_chars($message, 1);
$chars      = array_map('chr', array_keys($stats));
$frequency  = array_combine($chars, array_values($stats));

arsort($frequency);
print_r($frequency);

returns:

Array
(
    [ ] => 12
    [a] => 9
    [e] => 7
    [p] => 7
    [o] => 7
    [z] => 5
    [n] => 4
    [s] => 3
    [k] => 3
    [h] => 3
    [j] => 2
    [w] => 2
    [d] => 2
    [y] => 2
    [b] => 1
    [u] => 1
    [x] => 1
    [r] => 1
    [i] => 1
    [f] => 1
    [q] => 1
    [c] => 1
)

Example taken from: https://www.khanacademy.org/computing/computer-science/cryptography/ciphers/e/caesar_cipher_frequency_analysis

cereal 1,524 Nearly a Senior Poster Featured Poster

Cache: probably the new thread was appended to the index cache and was not updated after user's edit.

cereal 1,524 Nearly a Senior Poster Featured Poster

Sometimes it happens that the corrupted file will return the server side error instead of the contents, so you end to download a text file with the wrong extension: jpg, pdf, doc...

Try to open the corrupted file with your editor, if it gives problems then change the extension to .txt and see if you see the error message.

Otherwise check the error log of PHP. If still in doubt share your downloader script.

cereal 1,524 Nearly a Senior Poster Featured Poster

MySQL needs single quotes:

P. that should not make difference:

or I'm missing something? :)

@blueguy777

if you using mysql_* then try to add mysql_error() after the query to catch the error, for example:

$q = mysql_query($m_query) or die(mysql_error());

Show also what would be the end query.

cereal 1,524 Nearly a Senior Poster Featured Poster

What's the difference between other website and my website? That's all what I need to know.

That's the knowledge they are suggesting you to learn. It's not just keywords. You can start from Google suggestions:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, you are enclosing the query into single quotes:

$a = 'apples';
$b = 'oranges';

So in order to append another variable you have to use the dot operator:

$c = 'list '. $b . ' and ' .$a;

Basically is this. You have done that when defining the table name ($job_id), so the query would turn to:

$m_query = 'Insert into '.$job_id.'(`mobile`,`routeID`,`status`) values ('.$mobile.','.$routeID.',"Sent")';

Note:

  • the space after the into keyword
  • also 'Sent' becomes "Sent"

But it will not work, unless $mobile and $routeID are integers, if those are strings, then you have to add quotes (double quotes in this case):

$m_query = 'Insert into '.$job_id.'(`mobile`,`routeID`,`status`) values ("'.$mobile.'","'.$routeID."',"Sent")';

This can be refactored with double quotes:

$m_query = "insert into {$job_id} (`mobile`, `routeID`, `status`) values ('{$mobile}', '{$routeID}', 'Sent')";

In any case, you really don't want to create a query like this, you want to use prepared statements, as explained here:

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, that's clear. But, excuse me, I'm a bit lost. At the moment I can only suggest you to try the query from a MySQL client and see if you get results, without involving PHP and sessions. Then you could share tables, data and queries through a service like SQLfiddle, to help us (or at least me :D) to understand better the issue. Here's an example:

Anyone wants to help?

cereal 1,524 Nearly a Senior Poster Featured Poster

Sure? So friends table is not like this:

userid | user_1 | user_2 | status
---------------------------------
  1    | user 1 | user 2 |   1   
  2    | user 1 | user 3 |   0   

but:

userid | user_1  | user_2  | status
-----------------------------------
  1    |    1    |    2    |   1   
  2    |    1    |    3    |   0   

Correct? Because, if the values of user_1 and user_2 are strings, when you do:

$user["user_1"] == $_SESSION["uid"]

you're comparing integers to strings: 'user 1' == 1 and it will not work. Same for messages table. Sorry if I insist on this point, but it's unclear to me.

cereal 1,524 Nearly a Senior Poster Featured Poster

Can you show users table? I don't understand which values will assume uid, to me it should be an integer, but looking at your code it seems it would be a string, like user 1, otherwise those conditional statements are wrong:

if($user["user_1"] == $_SESSION["uid"])
cereal 1,524 Nearly a Senior Poster Featured Poster

@gentlemedia

I completely agree with you, for me it's better to work with classes as suggested by you and diafol in previous posts. I went ahead with OP requests to show him how it can be done, even if this is not the best solution. Anyway, this is what I intended:

In this case the title attribute would work as substitute of a class or an id attribute, since those are not applicable to a <link> tag.

gentlemedia commented: Nice one :) +5
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, few questions:

  • the data is correctly inserted in the database?
  • if, in view, you do var_dump($datame); what you get?
  • have you tried to remove the error control operators @ in your getdata() method? In this stage it's more important to get debug information rather than hiding.
cereal 1,524 Nearly a Senior Poster Featured Poster

Now it looks good, not sure it was you or my cache, in any case, thank you for your time Dani! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Or fileinfo:

$mime = (new finfo(FILEINFO_MIME_TYPE))->file('/path/to/file.ext');

Docs: http://php.net/manual/en/function.finfo-open.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Hmm, is it possible to see an updated online version of this page?

cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

Try to change the delimeter before creating the trigger, like this:

-- temporary delimeter
DELIMETER //
CREATE TRIGGER members_username
    AFTER UPDATE ON members
    FOR EACH ROW BEGIN
        update posts
        set posts.username = NEW.username
        where posts.userid = NEW.userid;
    END//

-- back to default delimeter
DELIMETER ;
cereal 1,524 Nearly a Senior Poster Featured Poster

It happens because the test script will overwrite all the link tags marked with rel="stylesheet", to avoid this add a title attribute: title="colors".

So the link tag related to colors becomes:

<link rel="stylesheet" title="colors" type="text/css" href="/path/to/default.css">

And change the JQuery selectors from:

$('link[rel=stylesheet]').attr('href', '/path/to/red.css');

To:

$('link[rel=stylesheet][title=colors]').attr('href', '/path/to/red.css');

Fix it for all colors, and it should work fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

I can write it for you, it's easy. You have to:

  • click the download link on the right side of this page:
    https://github.com/PHPMailer/PHPMailer
  • create a directory in your server and upload the uncompressed archive
  • then create this script:

    <?php
    
    require './PHPMailerAutoload.php';
    
    $mail = new PHPMailer;
    
    $mail->isSMTP();
    $mail->WordWrap    = 50;
    $mail->SMTPDebug   = 3;
    $mail->Debugoutput = 'html';
    $mail->SMTPAuth    = TRUE;
    
    # Office265 credentials
    $mail->Host        = 'tsl://smtp.office365.com:587;ssl://smtp.office365.com:995';
    $mail->Username    = 'username@domain.tld';
    $mail->Password    = 'password';
    
    # set FROM header
    $mail->From        = 'username@domain.tld';
    $mail->FromName    = 'website';
    
    # set TO header
    $mail->addAddress('recipient@domain.tld', 'Recipient Name');
    
    $mail->Subject     = 'Test';
    $mail->Body        = 'Hello World!';
    
    echo ! $mail->send() ? 'Error: ' . $mail->ErrorInfo : 'Success!';
    

and simply save the file to your server, remember to adjust the require call, in order to start autoload file.

Then load the above script from browser: with correct credentials you should see a log similar to my previous post, else you will see the errors. Note this line:

$mail->Host = 'tsl://smtp.office365.com:587;ssl://smtp.office365.com:995';

it is defining TSL or SSL connection which use different port numbers, these should be 587 and 995. The first line of the log, should tell you what is used, in my case it starts with SSL, while if I try only TSL it fails immediately.

The log should give you some information about what is going wrong: credentials, port numbers, IP and, if problem is on yours end, help you to fix Wordpress configuration.

If in doubt you can post the result here.

cereal 1,524 Nearly a Senior Poster Featured Poster

Are you trying to connect through TLS or SSL port? At the moment I can only think to test PHPMailer to see the telnet session, the result should look like this:

2015-10-04 02:55:31 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP RNDSTRNG.4 - gsmtp
2015-10-04 02:55:31 CLIENT -> SERVER: EHLO my_hostname
2015-10-04 02:55:31 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [0.0.0.0]
                                      250-SIZE 35882577
                                      250-8BITMIME
                                      250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN XOAUTH OAUTHBEARER
                                      250-ENHANCEDSTATUSCODES
                                      250-PIPELINING
                                      250-CHUNKING
                                      250 SMTPUTF8
2015-10-04 02:55:31 CLIENT -> SERVER: AUTH LOGIN
2015-10-04 02:55:31 SERVER -> CLIENT: 334 RNDMSTRNG
2015-10-04 02:55:31 CLIENT -> SERVER: RNDSTRNGFRMSRVR==
2015-10-04 02:55:31 SERVER -> CLIENT: 334 NTHRBT
2015-10-04 02:55:31 CLIENT -> SERVER: NTHNSWR==
2015-10-04 02:55:32 SERVER -> CLIENT: 235 2.7.0 Accepted
2015-10-04 02:55:32 CLIENT -> SERVER: MAIL FROM:<from@gmail.com>
2015-10-04 02:55:32 SERVER -> CLIENT: 250 2.1.0 OK RNDSTRNG.4 - gsmtp
2015-10-04 02:55:32 CLIENT -> SERVER: RCPT TO:<to@gmail.com>
2015-10-04 02:55:32 SERVER -> CLIENT: 250 2.1.5 OK RNDSTRNG.4 - gsmtp
2015-10-04 02:55:32 CLIENT -> SERVER: DATA
2015-10-04 02:55:32 SERVER -> CLIENT: 354  Go ahead RNDSTRNG.4 - gsmtp
2015-10-04 02:55:32 CLIENT -> SERVER: Date: Sun, 4 Oct 2015 04:55:31 +0200
2015-10-04 02:55:32 CLIENT -> SERVER: To: "Name" <to@gmail.com>
2015-10-04 02:55:32 CLIENT -> SERVER: From: Name <from@gmail.com>
2015-10-04 02:55:32 CLIENT -> SERVER: Subject: Test
2015-10-04 02:55:32 CLIENT -> SERVER: Message-ID: <RND1D@my_hostname>
2015-10-04 02:55:32 CLIENT -> SERVER: X-Priority: 3
2015-10-04 02:55:32 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.8 (https://github.com/PHPMailer/PHPMailer/)
2015-10-04 02:55:32 CLIENT -> SERVER: MIME-Version: 1.0
2015-10-04 02:55:32 CLIENT -> SERVER: Content-Type: text/plain; charset=iso-8859-1
2015-10-04 02:55:32 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit …
cereal 1,524 Nearly a Senior Poster Featured Poster

Great! :)

Port 465 is for SSL, 587 for TLS, in order to work with TLS you need to define the certificate through TLScert see:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello,

while browsing my posts I saw that sometimes quoted text is not displayed, yet there is an empty space in the corresponding area, I think the quote block is floating somewhere, if I inspect the document I can see the quoted text, here are few screenshots:

quotes.jpg

inspect.jpg

See how left side message has quoted text, and right text is missing? I also zoomed down to 33% but nothing changed.

Using:

  • Google Chrome: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36

    Works fine on Mozilla Firefox and Opera.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

try to change port number to 465, it works fine for me.

Gribouillis commented: spot-on +14
cereal 1,524 Nearly a Senior Poster Featured Poster

If you're using the resize() method of the image library, it happens because of:

Image_lib class already loaded. Second attempt ignored.

You can see that from the log of CodeIgniter. I don't know if they added something to avoid this problem, I just use this solution:

see the last comment, in practice when you load the library you assign a dynamic name and use that to load the new instance:

private function _resize($source, $filename, $num = 1)
{
    $config['image_library']  = 'gd2';
    $config['source_image']   = $source;
    $config['new_image']      = FCPATH . 'thumbs/' . $filename;
    $config['create_thumb']   = TRUE;
    $config['maintain_ratio'] = TRUE;
    $config['width']          = 75;
    $config['height']         = 50;

    $instance = 'image_lib_'.$num;

    $this->load->library('image_lib', $config, $instance);

    return $this->$instance->resize();
}

Then, you can insert this _resize() method in the for loop:

$this->_resize($upload_data['full_path'], $upload_data['file_name'], $i);

And it should work fine.

Just a note: imagine what can happen if N users start to upload images at the same time, they could kill the server, since this is an intensive task for the CPU, if you can, you should consider to go asynchronous and let the server start just few resize processes (no more than a resize process per core). It can be done with tools like beanstalkd or gearman:

This requires access to a ssh session and the privilege to install apps. See example here:

shany0786 commented: thnks for reply plz see below it's not working yet +0
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, you can do that with git-rm but if you want to remove it from repository's history, then you can follow these instructions:

Or you can use BFG Repo Cleaner as suggested in the last link:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi Donna!

Try to whitelist the email address that is sending the mail from the website along with the IP, if this does not help, then it could be due to the IP reputation. If you think it can be Wordpress then try a separated script, for example through PHPMailer, once you have the library try this:

Just replace domain, credentials and the sender email address.

You should get a log of the telnet session, displaying the authentication process, the sending of the body and the result of the operation.

If it works successfully: it returns ok but you still don't get anything, then it's probably a filter on their side and, maybe, it's better to ask to Office365 support and see if they can add some details or solutions.

cereal 1,524 Nearly a Senior Poster Featured Poster

Davy I don't know why. Can you open the CSS file directly from the browser url bar?

cereal 1,524 Nearly a Senior Poster Featured Poster

Whoops, wait. In my first example I was referring to a link tag, then following you last example I referred to #linkN. But the JQuery must alter a <link> tag not <a>:

<link rel="stylesheet" href="/link/to.css">

Otherwise you end only to link the file... what a word joke o_o'

Example:

<!DOCTYPE html>
<html>
<head>
    <title>Switcher</title>
    <link rel="stylesheet" type="text/css" href="/css/default.css">
</head>
<body>

    <ul>
        <li><a href="/" id="link1">Red</a></li>
        <li><a href="/" id="link2">Purple</a></li>
        <li><a href="/" id="link3">Orange</a></li>
    </ul>

    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
    <script type="text/javascript">
        google.load("jquery", "1.7.1");
        google.setOnLoadCallback(function()
        {
            $('#link1').on('click', function(e){
                e.preventDefault();
                $('link[rel=stylesheet]').attr('href', '/css/red.css');
            });

            $('#link2').on('click', function(e){
                e.preventDefault();
                $('link[rel=stylesheet]').attr('href', '/css/purple.css');
            });

            $('#link3').on('click', function(e){
                e.preventDefault();
                $('link[rel=stylesheet]').attr('href', '/css/orange.css');
            });
        });
    </script>

</body>
</html>

Note: it does not save the preference to the browser, you should set a cookie for that.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, check the documentation:

the latest release of MySQLdb (1.2.5) doesn’t support Python 3. In order to use MySQLdb under Python 3, you’ll have to install mysqlclient instead.

But mysqlclient does not support Python 3.5:

MySQL-3.23 through 5.5 and Python-2.7, 3.3-3.4 are currently supported. PyPy is supported.

So, I think, you have to downgrade to Python 3.4 or try the MySQL Connector/Python which according to documentation:

It may not support the most recent releases of Django.

cereal 1,524 Nearly a Senior Poster Featured Poster

These are always relative paths (relative to the opening page):

$("link1").attr("href", "bootstrap-3.3.5/css/custom.css");

use absolute paths, absolute means slash (/) followed by a relative path:

/bootstrap-3.3.5/css/custom.css

Also use id instead of the class attribute, since id must be unique the search through the document will be faster:

<li><a href="#" id="link1">Brown</a></li>

And if it still does not work add #:

$("#link1").attr("href", "bootstrap-3.3.5/css/custom.css");

Note: always add a dot when searching for a class, just like in CSS.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, enter in Community Center, the parent of this forum, and click on Live Chat:

cereal 1,524 Nearly a Senior Poster Featured Poster

My test code (the insert() function) will not work in yours if there's not a POST request (you have to press the submit button of the form at the bottom of the script), my purpose is to verify that, at basic, unset() does not affects the output of the message() function. If you want to test, then you should run my script without including your code, if it works fine then you have to point your attention to something else: at this point it would be helpful to see also the other code in the add and update functions to see if there is something that can disturb the execution. Otherwise just add the time() function to your messages, like in my example, to see if it updates.

The example is live here: http://code.runnable.com/VgvCvR-X77ddKdH6/testing-sessions-unset-for-php

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

Sorry but on update and add functions you're setting $_SESSION['msg'], on message() instead you're dealing with $_SESSION['message'], is that a mistype?

I built a simple test and works fine:

<?php

    session_start();

    function message()
    {
        if(isset($_SESSION['msg']))
        {
            $output = "<div class=\"msg\">{$_SESSION['msg']}</div>";
            unset($_SESSION['msg']);
            return $output;
        }
    }

    function insert()
    {
        $r = mt_rand(1, 2);

        if($r > 1)
            $_SESSION['msg'] = 'Failed @ '. time();

        else
            $_SESSION['msg'] = 'Success @ '. time();
    }

    if($_SERVER['REQUEST_METHOD'] == 'POST')
        insert();

?>
<!DOCTYPE html>
<html>
<head>
    <title>Test</title>
</head>
<body>

    <?php print message(); ?>

    <hr>

    <form method="post">
        <input type="submit">
    </form>

    <hr>

    <a href=".">refresh</a>

</body>
</html>
cereal 1,524 Nearly a Senior Poster Featured Poster

I'm going for NZ.
France Argentina or Ireland in final

Almost my same choices but, as said by HG, South Africa has good choices too, I would add it in replace of Argentina. Here support is splitted between Ireland and France, but I'm not sure about France preparation, I didn't liked their games, probably because it's not simple to play against teams like Italy and Romania.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi James,

if you want help you must set a proper title, explain us what you want to do and show where you are stuck, this implies that you share the code that gives you the issue.

cereal 1,524 Nearly a Senior Poster Featured Poster

//EDIT

see AndrisP answer.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

with pure PHP you can change the path in which session files are stored, see save_path:

http://php.net/manual/en/session.configuration.php#ini.session.save-path

Create a directory in a parent of public_html, so that is not reachable by a browser and other users in the server. In alternative you can store sessions in database, doing this in pure PHP requires that you write a session handler:

CodeIgniter has is own session handler so that you can save to database easily, look at session drivers:

In addition they support session temp data, so that you can mark a session for a specific expire time:

If you are concerned about database performance, then use the files driver and change the path by using $config['sess_save_path'] in the CI config file and for specific sessions use tempdata (last link). Note you have to set the path from CI because of:

[CodeIgniter] doesn’t support PHP’s directory level and mode formats used in session.save_path, and it has most of the options hard-coded for safety. Instead, only absolute paths are supported for $config['sess_save_path'].

From: https://codeigniter.com/user_guide/libraries/sessions.html#files-driver