php mysql help

Reply

Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: php mysql help

 
0
  #11
Mar 2nd, 2005
I'm not sure what to do at this point. Have you had a look at the IIs error logs to see if there is more information there?

If nothing else then I guess yes uninstall php completely and reinstall. Php 4 or 5 should work fine with mysql....

Dance
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 12
Reputation: androstendione is an unknown quantity at this point 
Solved Threads: 0
androstendione androstendione is offline Offline
Newbie Poster

Re: php mysql help

 
0
  #12
Mar 3rd, 2005
hi thanks for that
i went to get a drink and watched some tv..i did not touch th e pc at all..when i came back the phpmyadmin was working???? bizzare as before i left it it wasnt...no restart nothing...
anyway my loggin problem still exists
here is the code
<?
session_start();
session_register("StudentID_session");
?>
<? // asp2php (vbscript) converted
?>
<?
if (empty($_POST["EmailAddress"]))
{

//first time entering page

$TheMessage="To sign in fill in your details below and click on the Teacher to enter.";
}
else
{

//check that user exists and login is correct

// $conn is of type "adodb.connection"

$username = "chris";
$password = "astra123";
$hostname = "localhost";
$dbh = @mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
print "Connected to MySQL<br>";
$selected = @mysql_select_db("phptest",$dbh)
or die("Could not select phptest");
// you're going to do lots more here soon
mysql_close($dbh);

$RSStudent=$RSStudent_query=@mysql_query(("SELECT StudentID FROM mmstudents where StudentEmailAddress = '"
.$_POST["EmailAddress"]."' and StudentPassword = '"
.$_POST["Password"]."'"),$conn);
$RSStudent=@mysql_fetch_array($RSStudent_query);
if (($RSStudent==0))
{

//invalid login

$TheMessage="Student not found. Re enter the correct email and password.";
}
else
{

//valid entry

$StudentID_session=$RSStudent["StudentID"];
header("Location: "."student_menu.php");
}

}

?>


when i enter correct login details the page returns with "connected to mysql" in the top left hand corner...however it also returns the message (in bold above) student not found!!! i have tripple checked the details ive entered are correct... yet it says they are not ie student not found.....
the page is acting as it was designed to ie if an incorrect detail is entered then the page returns on itself.. yet i am entering the correct email and password! the database servername password are all correct mysql server is running myphpadmin is working fine..test pages created with phpmyadmin on the database are working fine..i can add delete etc from the browser window...what seems to evade me is to connect to the database from the page code above....even though all the details are correct and working in other php pages..
bizzare
any help would be appreciated cheers
chris
the new and extreemly p/o php student
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: php mysql help

 
0
  #13
Mar 3rd, 2005
Don't call:

[PHP]mysql_close($dbh);[/PHP]

until you have performed your querys.

Dance
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 12
Reputation: androstendione is an unknown quantity at this point 
Solved Threads: 0
androstendione androstendione is offline Offline
Newbie Poster

Re: php mysql help

 
0
  #14
Mar 3rd, 2005
i dont think thats the problem even when i remove that line
the page returns on itself and says user not found..i have an identical site on the same server written in asp it connects to the same database successfully...yet the php site says user not found.. im wondering if it is a location error or permission error ..it has to be something to do with either mysql or php...and the innability of this code to connect to the database...yet this cant be cos it says user not found..when in fact the user is in the database and returns the correct page in the asp site..it is only in the php version that it says user not found...seems illogical to me..
anyway i dont think im going to get to the bottom of it might be quicker to re write it all
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: php mysql help

 
0
  #15
Mar 3rd, 2005
Try removing the @s from all mysql_ commands. This will allow you to see any mysql or php erros.

Dance
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 12
Reputation: androstendione is an unknown quantity at this point 
Solved Threads: 0
androstendione androstendione is offline Offline
Newbie Poster

Re: php mysql help

 
0
  #16
Mar 4th, 2005
lines 38 and 39 are in bold

// $conn is of type "adodb.connection"

$db_host = 'localhost';
$db_name = 'mildmaydemo';
$db_user = 'root';
$db_pass = 'astra123';
$pconn = 'off';

if($pconn == 'off') {
$db = mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());
} else {
$db = mysql_pconnect($db_host, $db_user, $db_pass) or die(mysql_error());
}
mysql_select_db($db_name, $db);


$RSStudent=$RSStudent_query=mysql_query(("SELECT StudentID FROM mmstudents where StudentEmailAddress = '"
.$_POST["EmailAddress"]."' and StudentPassword = '"
.$_POST["Password"]."'"),$conn);
$RSStudent=mysql_fetch_array($RSStudent_query);

if (($RSStudent==0))
{

the error message i get for these lines are :

Notice: Undefined variable: conn in C:\Inetpub\wwwroot\mildmayphp\index.php on line 38

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\Inetpub\wwwroot\mildmayphp\index.php on line 38

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\mildmayphp\index.php on line 39


As you say removing the @ is a way to iron out ugly error messages...
thanks in advance
chris
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: php mysql help

 
0
  #17
Mar 4th, 2005
[PHP]$query = "SELECT Student ID FROM mmstudents where StudentsEmailAddress = {$_POST['EmailAddress']} and StudentPassword = {$_POST['Password']}";
$RSStudent_query=mysql_query($query,$db);
$RSStudent=mysql_fetch_array($RSStudent_query);[/PHP]

Try that instead. Hopefully I have no typos...

Dance
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 12
Reputation: androstendione is an unknown quantity at this point 
Solved Threads: 0
androstendione androstendione is offline Offline
Newbie Poster

Re: php mysql help

 
0
  #18
Mar 4th, 2005
hi pasted the code in and got the same error in return ie:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\mildmayphp\index.php on line 38


line 38 is:

$RSStudent=mysql_fetch_array($RSStudent_query);

as i say i suspect that the problem is a permissions error or something. why i dont know it just seems that php is requiring something from the system that asp doesnt,, extra autentication? files to be in a certain place on the hard drive? there is a maze of info which makes it more confusing ..Im about to yell from the window.."Come Home asp all is forgiven"!
this is what i can do...
i can access the same mysql database from an asp page with the same username and password
i can access the same database from phpmyadmin edit updat delete etc
i can create new php pages from phpmyadmin which can open the database

but from this php page it always says user not found...even though the same validation passwords etc are used in the asp page which does open secessfully.. the php error message is the same
the error is illogical it is saying mysql cant find a user that is clearly there in the databse
why that is i dont know .
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 12
Reputation: androstendione is an unknown quantity at this point 
Solved Threads: 0
androstendione androstendione is offline Offline
Newbie Poster

Re: php mysql help

 
0
  #19
Mar 4th, 2005
just a thought this is what i have

a test database (mysql) called mildmaydemo
the root user
a second user i created called chris
both have full privilages to the mildmaydemo database

iis 6
win 2003 server

php 5

php is woking fine ie myphpadmin etc

other pages i have created work fine on the same database with the same username and password..
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: php mysql help

 
0
  #20
Mar 4th, 2005
[PHP]$query = "SELECT Student ID FROM mmstudents where StudentsEmailAddress = {$_POST['EmailAddress']} and StudentPassword = {$_POST['Password']}";
$RSStudent_query=mysql_query($query,$db);
if (!$RSStudent_query) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
$RSStudent=mysql_fetch_array($RSStudent_query); [/PHP]

Try that and see what it says...

Dance
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC