MAMP php blank page

Discussion in 'Web Design and Development' started by andy5000, Mar 6, 2008.

  1. andy5000 macrumors regular

    Joined:
    Sep 17, 2006
    #1
    Hi, i am having quite a lot of problems with php at the moment, i am new to php. followed a tutorial for a login page, from this site http://www.free2code.net/tutorials/view/creating_a_php_login_script-5/page1.html

    i have followed it to the dot.
    i have MAMP installed and website in correct folder.

    when i try to open the login page all i get is a blank page.
    anyone got any ideas?
    Thanks

    Using tiger-mamp1.7.1
     
  2. jordanste macrumors member

    Joined:
    Feb 25, 2006
    #2
    go to your php.ini file and change "display_errors = Off"

    to

    "display_errors = On"

    if you are using mamp then the php.ini file is in MAMP/conf/

    there is a big chance that there are some errors in your code but i believe mamp turns display_errors = off by default, which is really where it should be online, but since this is just for testing. leave it on locally. if display_errors is set to off then you will just get a blank screen... no fun.
     
  3. andy5000 thread starter macrumors regular

    Joined:
    Sep 17, 2006
    #3
    This is the error i get:

    Parse error: syntax error, unexpected '<' in /Applications/MAMP/htdocs/login.php on line 67

    And here are lines 66-72:

    $_POST['passwd'] = stripslashes($_POST['passwd']);
    $info['password'] = stripslashes($info['password']);</body>
    $_POST['passwd'] = md5($_POST['passwd']);

    if ($_POST['passwd'] != $info['password']) {
    die('Incorrect password, please try again.');
    }

    Im still non the wiser.
     
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    It's that </body> that is messing you up. Delete it.
     
  5. andy5000 thread starter macrumors regular

    Joined:
    Sep 17, 2006
    #5
    ok this is what i have now
    the error

    Warning: require_once(DB.php) [function.require-once]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/db_connect.php on line 5

    Fatal error: require_once() [function.require]: Failed opening required 'DB.php' (include_path='.:/Applications/MAMP/bin/php5/lib/php') in /Applications/MAMP/htdocs/db_connect.php on line 5

    the code(lines 1-12)
    <?php

    // database connect script.

    require 'db_connect.php';

    if($logged_in == 1) {
    die('You are already logged in, '.$_SESSION['username'].'.');

    }

    ?>

    does anybody know of a better tutorial, this one seems to be causing lots of problems.
     
  6. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #6
    Is DB.php in the same folder as db_connect.php? With your current include path settings that is the way it would need to be.
     
  7. andy5000 thread starter macrumors regular

    Joined:
    Sep 17, 2006
    #7
  8. jordanste macrumors member

    Joined:
    Feb 25, 2006
    #8
    just make a new db.php then, its just a file with your database connection info. if its a mysql database itll be something like this:

    PHP:
    <?php // db.php

    $dbhost 'localhost';
    $dbuser 'user';
    $dbpass 'password';

    function 
    dbConnect($db='mysite') {
        global 
    $dbhost$dbuser$dbpass;
        
        
    $dbcnx = @mysql_connect($dbhost$dbuser$dbpass)
            or die(
    'The site database appears to be down.');

        if (
    $db!='' and !@mysql_select_db($db))
            die(
    'The site database is unavailable.');
        
        return 
    $dbcnx;
    }
    ?>
     
  9. andy5000 thread starter macrumors regular

    Joined:
    Sep 17, 2006
    #9
    Ok this is the error i am getting now

    Fatal error: Class 'DB' not found in /Applications/MAMP/htdocs/db_connect.php on line 19

    This is the code i have in the db_connect.php


    <?php

    //require the PEAR::DB classes.

    require_once 'db.php';

    $db_engine = 'mysql';
    $db_user = 'root';
    $db_pass = 'root';
    $db_host = 'localhost';
    $db_name = 'sunflower';

    $datasource = $db_engine.'://'.
    $db_user.':'.
    $db_pass.'@'.
    $db_host.'/'.
    $db_name;

    $db_object = DB::connect($datasource, TRUE);

    /* assign database object in $db_object,

    if the connection fails $db_object will contain

    the error message. */

    // If $db_object contains an error:

    // error and exit.

    if(DB::isError($db_object)) {
    die($db_object->getMessage());
    }

    $db_object->setFetchMode(DB_FETCHMODE_ASSOC);

    // we write this later on, ignore for now.

    include('check_login.php');

    ?>

    sorry for all the problems this is causing, i am learning from it though so the help is appreciated
     
  10. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #10
    Check if you have the DB file, it'll be located at /Applications/MAMP/bin/php5/lib/php/PEAR/DB.php

    My Mamp install doesn't have it. I've noticed Mamp is missing some of the PEAR library files. I've located some of them from a XAMP install.
     
  11. andy5000 thread starter macrumors regular

    Joined:
    Sep 17, 2006
    #11
    moved the dp.php file to that location and its still coming up with the same error.arggggh
     
  12. andy5000 thread starter macrumors regular

    Joined:
    Sep 17, 2006
    #12
    Hi everyone,
    This is the error i am getting at the moment.

    Warning: include(functions.php) [function.include]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/login.php on line 3

    Warning: include() [function.include]: Failed opening 'functions.php' for inclusion (include_path='.:/Applications/MAMP/bin/php5/lib/php') in /Applications/MAMP/htdocs/login.php on line 3

    i presume MAMP is missing files. anyone know where to get the missing files such as functions.php etc or am i totally missing the point.
     

Share This Page