| | #1 |
| Warrior Member Join Date: 2011
Posts: 24
Thanks: 3
Thanked 0 Times in 0 Posts
|
Greetings all, I am working on a computer based test application, where when the student logs in to test the test, the questions should come from the subjects the student was registered for. I have tried using SESSION variable to hold the registered subjects and pass them to the query that will fetch the questions,but won't work. here is a snippet my php code so far, <?php <?php //confirm session if(isset($_SESSION['user'])){ echo $_SESSION['user'];} else{die("Session not started");} //get student's details using session variables $confirmuser=mysql_query("select * from students where username='$user' ") or die(mysql_error()); while($confirm=mysql_fetch_array($confirmuser)){ec ho"<br/>"; echo $confirm['surname'].'<br/>'; echo $confirm['firstname'].'<br/>';; echo $_SESSION['subject1'] =$confirm['subject1'].'<br/>'; echo $_SESSION['subject2']=$confirm['subject2'].'<br/>'; echo $_SESSION['subject3']=$confirm['subject3'].'<br/>'; echo $_SESSION['subject4'] =$confirm['subject4'].'<br/>'; echo '<br/>'; $fourthsubject=$_SESSION['subject2']; echo $fourthsubject. '<br/>'; function fourth(){ global $fourthsubject; $bend=mysql_query("select * from $subject3 ") or die(mysql_error()); while($rase=mysql_fetch_array($bend)){ echo $rase['question'];} ;} fourth(); } ?> The above code is displaying this error message (You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' ' at line 1) |
| |
| | #2 |
| VIP Warrior War Room Member Join Date: 2006 Location: , , USA.
Posts: 1,795
Thanks: 70
Thanked 287 Times in 259 Posts
| |
| |
| | #3 | |
| VIP Warrior War Room Member Join Date: 2006 Location: , , USA.
Posts: 1,795
Thanks: 70
Thanked 287 Times in 259 Posts
|
| |
| |
| | #4 | |
| Warrior Member Join Date: 2014 Location: Indonesia
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
try this :
| |
| |
|
| Bookmarks |
| Tags |
| display, results, variables |
| |