Confuse taking data form 2 tables in database

I want to create a online toefl test . Now I want to calculate the final score of the user. I want to take the data from the two tables of the database, that is table score_structure and table score_listening .

I would like to take the column score in the table score_structure and table score_listening and then count them. but when i run it, score from table score_Sturcute and table score_listening did not get in. please help mee

<? php

              $email = $_SESSION['email'];

              $final="SELECT score_listening.score_list,score_structure.score_struct FROM score_listening, score_structure     WHERE =
                      AND = $email";
                $SkorAkhir = (($ScoreListening+ $ScoreStructure+ $score)/3) * 10; 

              $simpan = "INSERT INTO score_reading VALUES ('$email', '$score')";
              $NA = "INSERT INTO final_score VALUES ('$email', '$ScoreListening', '$ScoreStructure', '$score', '$FinalScore')";
              if(mysql_query($simpan) && mysql_query($NA)){
              }else {
                    echo mysql_error();


When you jumble PHP field names inside of SQL queries you need them in quotes. = '$email'"

Better is to use prepare statements to keep the data separated from the code.

ok, thank you

Also what @felgall forgot to mention as well as using prepared statements is that the mysql_* extension that you’ve used (which doesn’t support prepared statements) was removed from version 7 of PHP

I have lost count of how many times I’ve mentioned that in the last six months.

1 Like

And me - I was just replying to the other post from this user and decided not to turn yet another thread off its original topic.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.