| | |
php mysql help
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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
If nothing else then I guess yes uninstall php completely and reinstall. Php 4 or 5 should work fine with mysql....
Dance
•
•
Join Date: Mar 2005
Posts: 12
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Mar 2005
Posts: 12
Reputation:
Solved Threads: 0
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
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
Try removing the @s from all mysql_ commands. This will allow you to see any mysql or php erros.
Dance
Dance
•
•
Join Date: Mar 2005
Posts: 12
Reputation:
Solved Threads: 0
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
// $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
[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
$RSStudent_query=mysql_query($query,$db);
$RSStudent=mysql_fetch_array($RSStudent_query);[/PHP]
Try that instead. Hopefully I have no typos...
Dance
•
•
Join Date: Mar 2005
Posts: 12
Reputation:
Solved Threads: 0
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 .
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 .
•
•
Join Date: Mar 2005
Posts: 12
Reputation:
Solved Threads: 0
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..
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..
[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
$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
![]() |
Similar Threads
- Looking for PHP / MySQL Developer (Web Development Job Offers)
- Looking for a PHP/MYSQL Programmer (Web Development Job Offers)
- Need Highly Experienced PHP/MySQL Programmer $15-$25/hour (Web Development Job Offers)
- PHP/MySQL Programmer Position (Web Development Job Offers)
Other Threads in the PHP Forum
- Previous Thread: USB device command
- Next Thread: Creating linked pages
| Thread Tools | Search this Thread |
ajax apache api array beginner binary body broken cakephp checkbox class cms code cron curl database date date/time display dynamic echo email error file files folder form forms function functions gc_maxlifetime global google host href htaccess html image include insert integration ip java javascript joomla limit link list login loop mail memmory menu mlm msqli_multi_query multiple mycodeisbad mysql navigation oop parameter parsing paypal pdf php problem query radio random recourse recursion regex registrationform remote script search seo server sessions sms soap source space sql static syntax system table tutorial update upload url validator variable video web webdesign wordpress xml youtube





