PHP aargh (1 Viewer)

Super Dexta

New Member
Joined
Aug 15, 2002
Messages
7,841
here
is there some clever person out there that I could email a PHP file to and could tell me what very basic thing I'm doing wrong? I can't even get echo to work. cry x 1 million.
 
sin e:
not even the test or the hi will work :(

<html>
<head>
<title>Login2</title>
</head>
<body>
<p>Test</p>
<?php

echo "hi!<br/>"

//do db connection stuff
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
echo "instance created<br/>";

$connStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Inetpub\wwwroot\mbsebus07\LODriscoll\Databases\employees.mdb";
echo "connection thing defined"<br/>;

$conn->open($connStr);
echo "Connection open<br/>";


$rS = $conn->execute("SELECT role FROM employees where username='".$_POST["username"]."' and password='".$_POST["password"]."'");
$f1 = $rS->Fields(0);
$f2 = $rS->Fields(1);
$f3 = $rS->Fields(2);
while(!$rS->EOF)
{
print "$f1->value." ".$f2->value." ".$f3->value."<br />\n";
$rS->MoveNext();
}
$rS->Close();
$conn->Close();

?>

</body>

</html>
 
For starters, you are missing a semi-colon after the first line:
echo "hi!<br/>";
 
For starters, you are missing a semi-colon after the first line:
echo "hi!<br/>";
ta. still doesn't work when i fix that though :(
there isn't actually a gap in the word Databases either.

i have a feeling i'm putting stuff in the wrong folders or something. curse you corvus3 :(
 
PROVIDER=Microsoft.Jet.OLEDB.4.0

theres your problem right there.

Microsoft.Jet.OLEDB?
Fuck sake lads.


edit,
just pull it to pieces, test each one.
do you have a db connect?
can you ping the db?
blah blah
 
PROVIDER=Microsoft.Jet.OLEDB.4.0

theres your problem right there.

Microsoft.Jet.OLEDB?
Fuck sake lads.


edit,
just pull it to pieces, test each one.
do you have a db connect?
can you ping the db?
blah blah
it's for students, it's allowed be shit.

boo hoo hoo

edit for your edit:
i have tested each one, and still nothing works. i get a blank screen no matter what i do.
 
are you allowed execute php scripts in that directory?
yeah that was my problem for a while, but I started using a different directory that I could execute other scripts out of.
I have it working up as far as "instance created" now. after that it's the blank screen of death again.
 
yeah that was my problem for a while, but I started using a different directory that I could execute other scripts out of.
I have it working up as far as "instance created" now. after that it's the blank screen of death again.

I'll take a look at it for you Dexta.
 
There were a few syntax errors in the script. Here's a fixed version.

<html>
<head>
<title>Login2</title>
</head>
<body>
<p>Test</p>
<?php

echo "hi!<br/>";

//do db connection stuff
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
echo "instance created<br/>";

$connStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Inetpub\wwwroot\mbsebus07\LODriscoll\Dat abases\employees.mdb";
echo "connection thing defined<br/>";

$conn->open($connStr);
echo "Connection open<br/>";


$rS = $conn->execute("SELECT role FROM employees where username='".$_POST["username"]."' and password='".$_POST["password"]."'");
$f1 = $rS->Fields(0);
$f2 = $rS->Fields(1);
$f3 = $rS->Fields(2);
while(!$rS->EOF)
{
print $f1->value." ".$f2->value." ".$f3->value."<br />\n";
$rS->MoveNext();
}
$rS->Close();
$conn->Close();

?>

</body>

</html>
 
Best set the "display_errors" setting in your PHP ini file to "on" in order to get errors outputted to the browser. If the errors aren't being displayed its going to be really difficult to debug.
 
my tutor came in and made the db connection work for me yay.

now i just need to make it say 'click here' where here links to different pages depending on the value of the role field in the db. my tutor got sick of it and went home in the middle of trying to figure out how to do this.

this is what it looks like now, it just prints 'Connection open' and 'Staff' and the commented-out bit is where I'm trying to get it to check the value of one string against another and print out a link if they're the same.

<html>
<head>
<title>Login2</title>
</head>
<body>

<?php



//do db connection stuff
//create an instance of the ADO connection object
$conn = new COM ("ADODB.Connection") or die("Cannot start ADO");

//define connection string, specify database driver
$connStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Inetpub\wwwroot\MBSEBUS07\lodriscoll\Databases\employees.mdb";


$conn->open($connStr);
echo "Connection open<br/>";


$rS = $conn->execute("SELECT role FROM employees where username='".$_POST["username"]."' and pass='".$_POST["password"]."'");
$f1 = $rS->Fields(0);

$role = $f1->value;
while (!$rS->EOF)
{
print $role."<br/>";
$rS->MoveNext();
}

/*
int $role1 (string value, string Staff)
if ($role1==0)
{
echo "Click <a href="staff1.html">here</a><br/>";
}
*/
$rS->Close();
$conn->Close();

?>

</body>

</html>
 
Best set the "display_errors" setting in your PHP ini file to "on" in order to get errors outputted to the browser. If the errors aren't being displayed its going to be really difficult to debug.

tru dat.

look in your server logs too, see if there is anything interesant in there.
I'd say type
tail -f serverlog
and then hit up your server again, and watch the errors trailing through the shell,

if you werent using loadashite edition windows, but you are. Sorry.
 
Best set the "display_errors" setting in your PHP ini file to "on" in order to get errors outputted to the browser. If the errors aren't being displayed its going to be really difficult to debug.
how do i do that? :eek:
thanks for the syntax correction too :)

a guy from my class just handed me a piece of paper saying "A spoonful of sugar helps the PHP go down".
 
Go to the PHP installation directory (probably in C:\Program Files\PHP) and you'll find a file called PHP.ini. If you search in here for a setting called display_errors and change the value of this from off to on and then restart your web server it should then start outputting errors.

Maybe this script is sort of what you are looking for to print the link. It assumes that a user just has one role.

<html>
<head>
<title>Login2</title>
</head>
<body>
<?php

//do db connection stuff
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");

$connStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Inetpub\wwwroot\mbsebus07\LODriscoll\Dat abases\employees.mdb";

$conn->Open($connStr);

$rS = $conn->execute("SELECT role FROM employees where username='".$_POST["username"]."' and password='".$_POST["password"]."'");

if (!$rS->EOF)
{
$role = $rs->Fields[0]->Value;

if ($role == 'Staff')
{
echo '<a href="staff.html">Staff</a>';
}
else if ($role == 'Student')
{
echo '<a href="student.html">Student</a>';
}
}

$rs->Close();
$conn->Close();

?>

</body>

</html>
 
blank screen of death time for me again with that.

can't find the PHP installation directory, it's not in C:\Program Files anyway.
 

Users who are viewing this thread

Activity
So far there's no one here
Old Thread: Hello . There have been no replies in this thread for 365 days.
Content in this thread may no longer be relevant.
Perhaps it would be better to start a new thread instead.

21 Day Calendar

Mohammad Syfkhan 'I Am Kurdish' Dublin Album Launch
Bello Bar
1 Portobello Harbour, Saint Kevin's, Dublin, Ireland
Mohammad Syfkhan 'I Am Kurdish' Dublin Album Launch
Bello Bar
1 Portobello Harbour, Saint Kevin's, Dublin, Ireland
Bloody Head, Hubert Selby Jr Infants, Creepy Future - Dublin
Anseo
18 Camden Street Lower, Saint Kevin's, Dublin, Ireland

Support thumped.com

Support thumped.com and upgrade your account

Upgrade your account now to disable all ads... If we had any... Which we don't right now.

Upgrade now

Latest threads

Latest Activity

Loading…
Back
Top