PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php//Short tags should be avoided if possiable
include("dbinfo.inc.php");
$username=$_POST['username'];
$password=$_POST['password'];//also another security thing... i wouldnt pass your database usernae and password through the post variable..... not too hard to find out what it is, and i'd hate to see someone eff up ur database. If your intent was to define the persons username and password who was logging in you should change the names of these variables because your mysql_connect call is using this username and pass instead of the ones included in you dbinfo.inc.php file.
$login=0;
mysql_connect($hostname,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM gmpets_accounts"; //missing a double quote and semi-colon.
$result=mysql_query($query);
$num=mysql_num_rows($result);//added a underscore to your function call, mysql_numrows does not exist.
$i=0;
while ($i<$num){
$dusername=mysql_result($result,$i,"username");//missing semi-colon;
$dpassword=mysql_result($result,$i,"password");//missing semi-colon;
if ($username==$dusername){
if ($password==$dpassword){
$stats[0]=mysql_result($result,$i,"strength");
$stats[1]=mysql_result($result,$i,"intelligence");
$stats[2]=mysql_result($result,$i,"agility");
$stats[3]=mysql_result($result,$i,"speed");
$stats[4]=mysql_result($result,$i,"defence");
$stats[5]=mysql_result($result,$i,"hp");
$pet=mysql_result($result,$i,"pet");
$login=1;}}
$i++}
if login=1{
echo "Strength: $stats[0]<br>";
echo "Intelligence: $stats[1]<br>";
echo "Agility: $stats[2]<br>";
echo "Speed: $stats[3]<br>";
echo "Defence: $stats[4]<br>";
echo "HP: $stats[5]<br>"
echo "Pet type: $pet";}
mysql_close();
?>
<?php//Short tags should be avoided if possiable
include("dbinfo.inc.php");
$username=$_POST['username'];
$password=$_POST['password'];//also another security thing... i wouldnt pass your database usernae and password through the post variable..... not too hard to find out what it is, and i'd hate to see someone eff up ur database. If your intent was to define the persons username and password who was logging in you should change the names of these variables because your mysql_connect call is using this username and pass instead of the ones included in you dbinfo.inc.php file.
$login=0;
mysql_connect($hostname,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM gmpets_accounts"; //missing a double quote and semi-colon.
$result=mysql_query($query);
$num=mysql_num_rows($result);//added a underscore to your function call, mysql_numrows does not exist.
$i=0;
while ($i<$num){
$dusername=mysql_result($result,$i,"username");//missing semi-colon;
$dpassword=mysql_result($result,$i,"password");//missing semi-colon;
if ($username==$dusername){
if ($password==$dpassword){
$stats[0]=mysql_result($result,$i,"strength");
$stats[1]=mysql_result($result,$i,"intelligence");
$stats[2]=mysql_result($result,$i,"agility");
$stats[3]=mysql_result($result,$i,"speed");
$stats[4]=mysql_result($result,$i,"defence");
$stats[5]=mysql_result($result,$i,"hp");
$pet=mysql_result($result,$i,"pet");
$login=1;}}
$i++}
if login=1{
echo "Strength: $stats[0]<br>";
echo "Intelligence: $stats[1]<br>";
echo "Agility: $stats[2]<br>";
echo "Speed: $stats[3]<br>";
echo "Defence: $stats[4]<br>";
echo "HP: $stats[5]<br>"
echo "Pet type: $pet";}
mysql_close();
?>
<?php
include("dbinfo.inc.php");
$un=$_POST['username'];
$pw=$_POST['password'];//also another security thing... i wouldnt pass your database usernae and password ////through the post variable..... not too hard to find out what it is,
///and i'd hate to see someone eff up ur database. If your intent was to define the persons username and ///password who was logging in you should change the names of these
///variables because your mysql_connect call is using this username and pass instead of the ones included in you ///dbinfo.inc.php file.
$login=0;
mysql_connect($hostname,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM gmpets_accounts"; //missing a double quote and semi-colon.
$result=mysql_query($query);
$num=mysql_num_rows($result);//added a underscore to your function call, mysql_numrows does not exist.
$i=0;
while ($i<$num){
$dusername=mysql_result($result,$i,"username");//missing semi-colon;
$dpassword=mysql_result($result,$i,"password");//missing semi-colon;
if ($un==$dusername && $pw==$dpassword){
$stats[0]=mysql_result($result,$i,"strength");
$stats[1]=mysql_result($result,$i,"intelligence");
$stats[2]=mysql_result($result,$i,"agility");
$stats[3]=mysql_result($result,$i,"speed");
$stats[4]=mysql_result($result,$i,"defence");
$stats[5]=mysql_result($result,$i,"hp");
$pet=mysql_result($result,$i,"pet");
$login=1;}}
$i++}
if login=1{
echo "Strength: $stats[0]<br>";
echo "Intelligence: $stats[1]<br>";
echo "Agility: $stats[2]<br>";
echo "Speed: $stats[3]<br>";
echo "Defence: $stats[4]<br>";
echo "HP: $stats[5]<br>"
echo "Pet type: $pet";}
mysql_close();
?>