Jump to content


Photo

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


  • Please log in to reply
6 replies to this topic

#1 web2000

web2000
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 15 May 2006 - 03:02 PM

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);

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 15 May 2006 - 03:18 PM

<?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);
}
?>


#3 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 15 May 2006 - 03:23 PM

Learn to indent your code and you might actually be able to see whats going on.

#4 web2000

web2000
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 15 May 2006 - 03:31 PM

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


#5 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 15 May 2006 - 04:07 PM

Are you experienced in another coding/scripting language then? Because OOP is not 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.

#6 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 15 May 2006 - 04:47 PM

[!--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?

#7 _will

_will
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 15 May 2006 - 04:58 PM

To help your session debugging, try using this to print all the session variables:

echo print_r($_SESSION);





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users