PDA

View Full Version : MAMP php blank page




andy5000
Mar 6, 2008, 10:26 AM
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



jordanste
Mar 6, 2008, 12:17 PM
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.

andy5000
Mar 6, 2008, 12:46 PM
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.

angelwatt
Mar 6, 2008, 01:01 PM
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.');
}

I'm still none the wiser.

It's that </body> that is messing you up. Delete it.

andy5000
Mar 6, 2008, 01:29 PM
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.

angelwatt
Mar 6, 2008, 01:44 PM
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.

andy5000
Mar 6, 2008, 02:04 PM
ok so there isnt a db.php file on the tutorial site (http://www.free2code.net/tutorials/view/creating_a_php_login_script-5/page1.html)
so im going try another one (http://www.roscripts.com/PHP_login_script-143.html)
Unless anyone has any better solutions.
thanks guys

jordanste
Mar 7, 2008, 03:21 PM
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 // 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;
}
?>

andy5000
Mar 9, 2008, 12:16 PM
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

angelwatt
Mar 9, 2008, 02:54 PM
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.

andy5000
Mar 10, 2008, 06:15 AM
moved the dp.php file to that location and its still coming up with the same error.arggggh

andy5000
Mar 13, 2008, 11:10 AM
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.