Hello,
I'm new on this forum and i have not seen the rules to post a code, so i will try to explain my best :
I have learned the basics of php during the past few days and i have a php code that is supposed to read parameters in several fields of a Mysql database and to return those parameters as variables in an array. (well that's how i understand it... please correct me if i'm wrong)
So here the code and the part that doesn't seem to work properly (colored in red) :
//I have changed the following values which are confidential...
$DBName = "MyDatabase";
$DBHostName = "MyMysqlServer";
$DBUserName = "MyUsername";
$DBPassword = "MyPassword";
$Table = "MyTable";
//The fields which are in MyTable :
// MemberID SMALLINT
// MemberName VARCHAR(20)
// MemberPassword VARCHAR(20)
// MemberEmailAddress VARCHAR(50)
// MemberDateTimeInscription VARCHAR(19)
//Reading member parameters
echo"<br>Reading the parameters of a member.";
echo"<br>Defining the parameters of the member to read.";
$CurrentName = "Ashley";
$CurrentPassword = "65hl3y";
$CurrentEmailAddress = "
[email protected]";
echo"<br>Trying to start a connection with the Mysql server.";
mysql_connect($DBHostName,$DBUserName,$DBPassword) OR DIE(mysql_error());
echo"<br>Selecting the table.";
mysql_select_db($DBName) OR DIE(mysql_error());
echo"<br>Searching for the fields corresponding to the CurrentName.";
$Query = "SELECT * FROM ".$Table." WHERE MemberName = '".$CurrentName."'";
$Result = mysql_query($Query) or die(mysql_error());
echo"<br>Returning the parameters stored in the fields.";
while($Row = mysql_fetch_array($Result,MYSQL_ASSOC)){
/////This is the start of the part that does not seem to work properly.
$MemberId = $row["MemberId"];
$MemberName = $row["MemberName"];
$MemberPassword = $row["MemberPassword"];
$MemberEmailAddress = $row["MemberEmailAddress"];
$MemberDateTimeInscription = $row["MemberDateTimeInscription"];
echo"<br>MemberId : ".$MemberId;
echo"<br>MemberName : ".$MemberName;
echo"<br>MemberPassword : ".$MemberPassword;
echo"<br>MemberEmailAddress : ".$MemberEmailAddress;
echo"<br>MemberDateTimeInscription : ".$MemberDateTimeInscription;
/////This is the end of the part that does not seem to work properly.
}
echo"<br>Ending the connection with the Mysql server.";
mysql_close();
All of echo are here for debug, i'm a beginner with php.
This is what the php page shows :
Reading the parameters of a member.
Defining the parameters of the member to read.
Trying to start a connection with the Mysql server.
Selecting the table.
Searching for the fields corresponding to the CurrentName.
Returning the parameters stored in the fields.
MemberId :
MemberName :
MemberPassword :
MemberEmailAddress :
MemberDateTimeInscription :
Ending the connection with the Mysql server.
I don't understand why the variables $MemberId, $MemberName, $MemberPassword, $MemberEmailAddress, $MemberDateTimeInscription are empty.
Your advices are welcome,
Thanks,