Jump to content

Archived

This topic is now archived and is closed to further replies.

web2000

Ive got the () and ,, in the wrong places Please Help

Recommended Posts

Hello,

I am trying to create a script that basically looks for a session, if it is there it will write the session value in to a text box, if it isnt it will create one using a mixture of time and ip address.

It doesnt work and im not to sure why, i am not a great PHP developer

Please can someone help me out here

Thank you very much


if (CCGetSession("username");
$shoppingcart->username->SetValue($username);
else;
$stamp = strtotime ("now");
$username = "$stamp$REMOTE_ADDR";
$username = str_replace(".", "", "$username");
$shoppingcart->username->SetValue($username);
CCSetSession("username", $username);

Share this post


Link to post
Share on other sites
[code]<?php
if (CCGetSession("username")) {
    $shoppingcart->username->SetValue($username);
} else {
    $stamp = strtotime("now");
    $username = $stamp.$REMOTE_ADDR;
    $username = str_replace(".", "", "$username");
    $shoppingcart->username->SetValue($username);
    CCSetSession("username", $username);
}
?>[/code]

Share this post


Link to post
Share on other sites
Learn to indent your code and you might actually be able to see whats going on.

Share this post


Link to post
Share on other sites
Sorry,

I am a basic PHP developer.

I have tried the modified code but with no luck.

It doesn’t even give me errors it just display's a blank page

Share this post


Link to post
Share on other sites
Are you experienced in another coding/scripting language then? Because OOP is [i]not[/i] a basic coding practice.

A good idea when troubleshooting is to print selected variables to the screen so that you can see what data is being passed around.

Share this post


Link to post
Share on other sites
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]It doesn’t even give me errors it just display's a blank page[/quote]
Of course it just displays a blank page. There are no echo() statements. What do you expect to see?

Share this post


Link to post
Share on other sites
To help your session debugging, try using this to print all the session variables:

[code]
echo print_r($_SESSION);
[/code]

Share this post


Link to post
Share on other sites

×

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.