Jump to content

GFOnyX

Members
  • Posts

    20
  • Joined

  • Last visited

GFOnyX's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. And that was the miracle line that was missing! I for sure will study the link though. I can not thank you enough for taking the time and helping me out. All of you guys, thank you very much!!!
  2. First of all,thank you all for helping me. I replaced the code as Josh said but now i get no output at all at the page. I went to firefox and checked the JS under console and shows these two things. I don't know if these are what you mean... [18:57:32.342] Use of getUserData() or setUserData() is deprecated. Use WeakMap or element.dataset instead. @ resource://gre/modules/XPIProvider.jsm -> jar:file:///C:/Users/Alexander/AppData/Roaming/Mozilla/Firefox/Profiles/m5buocf4.default/extensions/%7Bd10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d%7D.xpi!/bootstrap.js -> jar:file:///C:/Users/Alexander/AppData/Roaming/Mozilla/Firefox/Profiles/m5buocf4.default/extensions/%7Bd10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d%7D.xpi!/lib/requestNotifier.js:64[18:57:32.497] Use of getPreventDefault() is deprecated. Use defaultPrevented instead. @ chrome://flashblock/content/flashblock.xml:119 Yes the swf file is located in the same dir as the script which is the root of the site.
  3. Yes i see that. I mention it at post #9
  4. These are the errors i am getting.I should say that one the same site on a different page i can display swf files just fine but they are not stored in the DB.I call them manually. It is when i try to call them from the DB that they do not display. HTML1502: Unexpected DOCTYPE. Only one DOCTYPE is allowed and it must occur before any elements. index.php, line 64 character 1 HTML1503: Unexpected start tag. index.php, line 65 character 1 HTML1512: Unmatched end tag. index.php, line 70 character 1 HTML1514: Extra "<body>" tag found. Only one "<body>" tag should exist per document. index.php, line 72 character 1 HTML1521: Unexpected "</body>" or end of file. All open elements should be closed before the end of the document. index.php, line 81 character 1 FB.getLoginStatus() called before calling FB.init().
  5. Sorry Ch0cu3r i am stupid. When i was executing your requests i was hiting the link as http://localhost/project/game2.php which of course would return an error since i am calling every page from index.php which contains the dbconnect file. When i saw the image i had the link as http://localhost/project/index.php?page=game2.php which is correct. Sorry for the trouble. The problem however remains. No error messages but still can not see the swf file... Here is my latest code <?php error_reporting(E_ALL); ini_set('display_errors', true); require_once('config.php'); if (!session_id()) session_start(); ?> <!DOCTYPE html> <html> <head> <meta content="text/html; charset=UTF-8" http-equiv="content-type"> <meta name="author" content="Onyx"> <link rel="stylesheet" type="text/css" href="<?php echo HTTP_STYLE;?>layout.css" /> <link href="<?php echo HTTP_IMAGES;?>favicon.ico" rel="icon" type="image/x-icon" /> </head> <body> <div id="wrapper2"> <div id="container"> <?php $path=""; $id=""; $width=""; $height=""; $version=""; $image=""; $result = mysql_query("SELECT * FROM games") or die('Query Error: '. mysql_error()); while ($row = mysql_fetch_assoc($result)) { $path = $row['path']; $id = $row['id']; $width = "546"; $height = "431"; $version = "9.0.0"; $image = $row['image']; } echo "<script src='swfobject.js'></script>"; echo "swfobject.embedSWF(" . $path . ", " . $id . ", " . $width . ", " . $height . ", " . $version . ")"; echo "<img src=$image>"; ?> </div> </div> </body> </html> The above outputs: swfobject.embedSWF(Start_Quiz_App.swf, 1, 546, 431, 9.0.0) and the image i have.
  6. I am getting Parse error: syntax error, unexpected ',' in C:\xampp\htdocs\kinderlearn\game2.php on line 27 something wrong with the syntax of the above line. The query runs fine if i execute it on MySQL via PHPmyadmin. It returns the correct results. I don't see how it can be wrong.It is like the simplest query
  7. I changed mysql_fetch_array to mysql_fetch_assoc in case it makes a difference but nothing changed.The error is as following Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in the line that has while($row = mysql_fetch_assoc($result)) Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in the line that has while($row = mysql_fetch_array($result))
  8. The page does not output anything currently besides some css styling (footer,header etc) I created another column called image and i can properly echo out the image so i am connected to the DB and the path to the swf file is correct. I have checked many times in case it was that.
  9. Hi. I am having trouble embedding a swf file from a database on a php page. I know how to embed a swf file using just php with the help of swfobject.js but I am having trouble being able to actually show the file from a db. I am not storing the actual file on the database but the path to the flash file (eg games/flashgame1.swf) I am properly connected to the db so there is no problem there. The table is called games and has two columns for now: id | path Here is my code: <?php require_once('config.php'); if (!session_id()) session_start(); ?> <!DOCTYPE html> <html> <head> <meta content="text/html; charset=UTF-8" http-equiv="content-type"> <meta name="author" content="Onyx"> <link rel="stylesheet" type="text/css" href="<?php echo HTTP_STYLE;?>layout.css" /> <link href="<?php echo HTTP_IMAGES;?>favicon.ico" rel="icon" type="image/x-icon" /> </head> <body> <div id="wrapper2"> <div id="container"> <?php $result = mysql_query("SELECT * FROM games"); while($row = mysql_fetch_array($result)) { $path = $row['1']; $id = $row['0']; $width = "546"; $height = "431"; $version = "9.0.0"; } echo "<script type=text/javascript src=swfobject.js></script>"; echo "<script type=text/javascript>"; echo "swfobject.embedSWF('$path','$id', '$width', '$height', '$version')";echo "</script>"; ?> </div> </div> </body> </html> Any ideas what i am doing wrong?
  10. I have the following php code that produces some multiple choice questions with each answer per question giving different points. <?php $done = $_POST['done']; if ($done < '1' ) { ?> <form action="quiz.php" method="post" /> How many domains do you own? </BR> <input type="radio" name="op1" value="0"> I don't <BR/><input type="radio" name="op1" value="5"> 1 <BR/><input type="radio" name="op1" value="10"> 2 <BR/><input type="radio" name="op1" value="15"> 3 <BR/><input type="radio" name="op1" value="20"> 4 <BR/><input type="radio" name="op1" value="30"> 5 or more <BR><BR> Do you use skype? </BR> <input type="radio" name="op2" value="1"> Yes <BR/><input type="radio" name="op2" value="0"> No </BR></BR> How many people are currently in your Skype contact list? </BR> <input type="radio" name="op3" value="1"> less than 5 <BR/><input type="radio" name="op3" value="2"> 5 to 10 <BR/><input type="radio" name="op3" value="3"> 11 to 15 <BR/><input type="radio" name="op3" value="4"> 15 to 30 <BR/><input type="radio" name="op3" value="5"> more than 30 <BR><BR> <input type="hidden" name="done" value="1"/> <input type="submit" value="Submit...."/> </form> <?php } else { $score1=$_POST['op1']; $score2=$_POST['op2']; $score3=$_POST['op3']; $total = $score1 + $score2+ $score3; print "Your score Is " . $total . "!"; } ?> </div> I am trying to modify the code so i can make it work with a database i have.This is the structure of the table question which also includes the answers and the points of each answer. que_id | test_id | que_desc | ans1 | ans2 | ans3 | ans4 | true_ans | type | points1 | points2 | points3 | points4 | And this is what i have done so far: <?php session_start(); require_once('config.php'); include 'dbconnect.php'; include 'functions.php'; extract($_POST); extract($_GET); extract($_SESSION); if(isset($subid) && isset($testid)) { $_SESSION[sid]=$subid; $_SESSION[tid]=$testid; header("location:$self_page?page=kinder.php"); } ?> <?php $rs=mysql_query("select * from question where test_id=20",$conn) or die(mysql_error()); $i=0; while($row = mysql_fetch_array($rs)) { $i++; $id = $row["id"]; $question = $row["que_desc"]; $opt1 = $row["ans1"]; $opt2 = $row["ans2"]; $opt3 = $row["ans3"]; $opt4 = $row["ans4"]; $score1= $row['points1']; $score2= $row['points2']; $score3= $row['points3']; $score4= $row['points4']; $answer = $row["true_ans"]; echo "$question<br>"; echo "<input type='radio' id='radio1' name='$i' value='$opt1'/><label for='radio1'>$opt1</label><br>"; echo "<input type='radio' id='radio1' name='$i' value='$opt2'/><label for='radio1'>$opt2</label><br>"; echo "<input type='radio' id='radio1' name='$i' value='$opt3'/><label for='radio1'>$opt3</label><br>"; echo "<input type='radio' id='radio1' name='$i' value='$opt4'/><label for='radio1'>$opt4</label><br>"; echo "<br>"; } ?> <center> <input type="hidden" name="done" value="1"/> <input type="submit" value="Submit...."/> </center> </form> <?php } else { $total = ........... } ?> </div> </body> My question is how to pass each answer points using the While loop i have above and how to calculate the total score.
  11. .josh it seems to be working.Thank you very much. I had the code written in wrong position inside the php file. It has many lines of code already in it and i got a little lost. I tried an IF condition using the $scoremax variable and i got the results i wanted. Thanks again! BTW This site is amazing!
  12. Yes i am propelry connected to the DB since i can already pass scores to the DB and read data from it. Sorry about the username,it was a mistake from my end.It was supposed to be $username. The result however is still that is not working. By applying the code you wrote i get this: Array( [0] => )
  13. I did but it still doesnt seem to work. Its like the sum is not being stored in the $scoremax variable.
  14. I have the following query that gives me the result i want. In a nutshell it searches two columns to find the max value in each of these two columns and returns the sum of these two values. When i try to pass it to a variable in php it doesn't seem to work. I want to be able to pass the sum in a variable so i can use the variable later into an IF Condition. For example: if ($scoremax >= '160') { code here } Here is my query: select (max(scoreioa) + max(scoreioa2)) from result where username='username' and here is the php code: $maxscore = mysql_query("select (max(scoreioa) + max(scoreioa2)) from result where username='username'"); mysql_data_seek($maxscore, $scoremax); $row = mysql_fetch_row($maxscore); $scoremax = $row[0];
  15. I modified the code to execute something that shoud be more simple but still doesnt work the way it was supposed to. I am currently trying to display in random order ONLY the questions and NOT the answers. The questions do display randomly but the results even though they are now fixed they are not passing correctly. By looking at another table at my DB which temporarily stores the results i found out that this is happening because it passes a different question to the DB than the one the user sees while taking the quiz. I have no idea why this is happening now. How is it possible to show me a specific question and at the same time passing a different question to the DB? It is like they pass to the DB in a specific order and if that order matches the order the user sees than the score is ok. This is very weird. Here is my modified code: <?php session_start(); include("database.php"); extract($_POST); extract($_GET); extract($_SESSION); if(isset($subid) && isset($testid)) { $_SESSION[sid]=$subid; $_SESSION[tid]=$testid; header("location:quiz.php"); } if(!isset($_SESSION[sid]) || !isset($_SESSION[tid])) { header("location: index.php"); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Online Quiz</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="quiz.css" rel="stylesheet" type="text/css"> </head> <body> <?php include("header.php"); $rs=mysql_query("SELECT * FROM mst_question WHERE test_id=$tid",$cn) or die(mysql_error()); if(!isset($_SESSION[qn])) { $_SESSION[qn]=0; mysql_query("delete from mst_useranswer where sess_id='" . session_id() ."'") or die(mysql_error()); $_SESSION[trueans]=0; } else { if($submit=='Next Question' && isset($answ)) { mysql_data_seek($rs,$_SESSION[qn]); $row= mysql_fetch_row($rs); mysql_query("insert into mst_useranswer(sess_id, test_id, que_des, ans1,ans2,ans3,ans4,true_ans,your_ans) values ('".session_id()."', $tid,'$row[2]','$row[3]','$row[4]','$row[5]', '$row[6]','$row[7]','$answ')") or die(mysql_error()); if($answ==$row[7]) { $_SESSION[trueans]=$_SESSION[trueans]+1; } $_SESSION[qn]=$_SESSION[qn]+1; } else if($submit=='Get Result' && isset($answ)) { mysql_data_seek($rs,$_SESSION[qn]); $row= mysql_fetch_row($rs); mysql_query("insert into mst_useranswer(sess_id, test_id, que_des, ans1,ans2,ans3,ans4,true_ans,your_ans) values ('".session_id()."', $tid,'$row[2]','$row[3]','$row[4]','$row[5]', '$row[6]','$row[7]','$answ')") or die(mysql_error()); if($answ==$row[7]) { $_SESSION[trueans]=$_SESSION[trueans]+1; } echo "<h1 class=head1> Result</h1>"; $_SESSION[qn]=$_SESSION[qn]+1; echo "<Table align=center><tr class=tot><td>Total Question<td> $_SESSION[qn]"; echo "<tr class=tans><td>True Answer<td>".$_SESSION[trueans]; $w=$_SESSION[qn]-$_SESSION[trueans]; echo "<tr class=fans><td>Wrong Answer<td> ". $w; echo "</table>"; mysql_query("insert into mst_result(login,test_id,test_date,score) values('$login',$tid,'".date("d/m/Y")."',$_SESSION[trueans])") or die(mysql_error()); echo "<h1 align=center><a href=review.php> Review Question</a> </h1>"; unset($_SESSION[qn]); unset($_SESSION[sid]); unset($_SESSION[tid]); unset($_SESSION[trueans]); exit; } } $questions = array(); $number_value = 0; while($row = mysql_fetch_assoc($rs)) { $answers = array($row['ans1'], $row['ans2'], $row['ans3'], $row['ans4']); //shuffle($answers); $questions[] = array( 'que_id' => $row['ques_id'], 'q' => $row['que_desc'], 'answers' => $answers ); } shuffle($questions); $output = "<ol>\n"; foreach($questions as $ques) {} //$output .= "<li>\n"; $output .= "{$ques['q']}<br>\n"; foreach($ques['answers'] as $ans => $answ) { $number_value = $number_value + 1; $output .= "<input type='radio' name='answ' value='$number_value'> $answ<br>\n"; } //$output .= "</li><br>\n"; echo "<form name=myfm method=post action=quiz.php>"; echo "<table width=100%> <tr> <td width=30> <td> <table border=0>"; echo $output; if($_SESSION[qn]<mysql_num_rows($rs)-1) echo "<tr><td><input type=submit name=submit value='Next Question'></form>"; else echo "<tr><td><input type=submit name=submit value='Get Result'></form>"; echo "</table></table>"; ?> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.