problem with using define() in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
insight
Forum Commoner
Posts: 52
Joined: Tue Jul 07, 2009 9:12 am

problem with using define() in php

Post by insight »

I have the following code:

Code: Select all

define("TBL_USERS", "insight_users");
define("TBL_ACTIVE_USERS",  "insight_active_users");
define("TBL_ACTIVE_GUESTS", "insight_active_guests");
define("TBL_BANNED_USERS",  "insight_banned_users");
And in my database I have the following tables:

insight_user
insight_active_users
insight_active_guests
insight_banned_users

I am creating a login script (well I got one online and am simply modifying to suit my website) and when I register I get a Registration Failed which can be seen in this line of code here:

Code: Select all

else if(isset($_SESSION['regsuccess'])){
   /* Registration was successful */
   if($_SESSION['regsuccess']){
      echo "<h1>Registered!</h1>";
      echo "<p>Thank you <b>".$_SESSION['reguname']."</b>, your information has been added to the database, "
          ."you may now <a href=\"main.php\">log in</a>.</p>";
   }
   /* Registration failed */
   else{
      echo "<h1>Registration Failed</h1>";
      echo "<p>We're sorry, but an error has occurred and your registration for the username <b>".$_SESSION['reguname']."</b>, "
          ."could not be completed.<br>Please try again at a later time.</p>";
   }
   unset($_SESSION['regsuccess']);
   unset($_SESSION['reguname']);
}
Problem is is that the original code works perfectly fine and I don't know why my modified code isn't working. The only difference is the below code here:

Code: Select all

define("TBL_USERS", "users");
define("TBL_ACTIVE_USERS",  "active_users");
define("TBL_ACTIVE_GUESTS", "active_guests");
define("TBL_BANNED_USERS",  "banned_users");
and the database tables are:

users
active_users
active_guests
banned_users

As you can see I've changed very little of the code. Can someone be kind enough to help me. For more information on the login script I'm using you can find it here: http://www.evolt.org/node/60384
insight
Forum Commoner
Posts: 52
Joined: Tue Jul 07, 2009 9:12 am

Re: problem with using define() in php

Post by insight »

Nobody has an answer :?: :(
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: problem with using define() in php

Post by Mark Baker »

Start diagnosing this by echoing the sql query that you're running, to see if it really is what you expect
Post Reply