success OR DIE is there an alternate solution to dying?

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

User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Simplified, but maybe something like:

Code: Select all

$content = '';
     $link = mysql_connect( $host, $user, $pass );
     mysql_select_db( $dbname );
     if( $errmsg = mysql_error($link)){
          $content .= error("Could not connect to database. ($errmsg)");
     } else {
         $username = trim($_POST['username']);
         $userpass =  trim($_POST['userpass']);
         $query = "SELECT * FROM $table WHERE username = '$username' AND userpass = '$userpass'";
         $result = mysql_query( $query );
         if( !$result ){
               $content .= error('You are not registered.');
         } else{
               $content .= Success();
         }
         mysql_free_result( $result );
         mysql_close( $link );
     }

     include 'mypagetemplate.php';
mypagetemplate.php:

Code: Select all

<html>
<head>
.....
</head>
<body>
- header here

-- left nav bar here

<?php echo $content; ?>

-- footer here
</body>
</html>
(#10850)
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

Sorry, I didn't read any of the code. Usually when I am using error surpression, it is for one reason:

Code: Select all

if (@include() == 0)
{
    echo $error_message;
}
If the @ is ommited the default error message still pops through and that is unhappy for me.
Post Reply