MySQL Query help needed..

admin

Administrator
Staff member
Ok, problem.


Where am I going wrong with these MySQL queries? I get an error with this secion -->while($fa = mysql_fetch_array($result2)){
. What do I need to do to get this to work?

Thanks, the section of code is below.



} elseif($Step=="add"){


$sql = "INSERT INTO students (username,password) VALUES ('$username','$password')";

$result = mysql_query($sql,$db);

$sql2 = "SELECT * FROM students WHERE username='$username' AND password='$password')";

$result2 = mysql_query($sql2,$db);

while($fa = mysql_fetch_array($result2)){

$stdid = $fa["id"];

}


$sql3 = "INSERT INTO access (std_id, level, event) VALUES ('$stdid','300','0')";

$insrt = mysql_query($sql3, $db);

echo " Record Added!";
 
Back
Top