PHP - Need Help Displaying Wrong Answers
Right now my application only displays the answers and problems when the user hits the score button. But when the user hits the score button I want my application to only display the problems that the user got wrong in the test. Here is my code for this applicaiton.. it is small and simple, just not sure how to do this?
Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Lab 5</title> </head> <body> <?php define ('ROWS', 3); define ('COLS', 3); define ('MAX_NUMBER', 12); date_default_timezone_set('America/New_York'); if (isset($_POST['btn_score'])) { //print_r ($_POST); $time1 = $_POST['ts']; $time1_object = new DateTime($time1); $now = new DateTime(); $time_span = $now->diff($time1_object); $minutes = $time_span->format('%i'); $seconds = $time_span->format('%s'); $seconds+= $minutes * 60; echo "It took $seconds seconds to complete the test<hr />"; foreach ($_POST as $problem => $answer) { if ($problem <> "btn_score" && $problem <> "ts") { //echo "$problem -- $answer <br />"; $problem = explode('_', $problem); $num1 = $problem[2]; $num2 = $problem[3]; echo "$num1 * $num2 === $answer <br />"; } } } ?> <h1>Lab 5</h1> <form name="lab5" method="post" action="lab5b.php"> <?php $now = new DateTime(); //echo $now->format('Y-m-d H:i:s'); echo "<input type='hidden' name='ts' value='" . $now->format('Y-m-d H:i:s') . "'>"; ?> <table border="1" cellspacing="5" cellpadding="5"> <?php $no_of_problems = 0; for ($row=0; $row<ROWS; $row++) { echo "<tr>"; for ($col=0; $col<COLS; $col++) { $num1 = mt_rand(1,MAX_NUMBER); $num2 = mt_rand(1,MAX_NUMBER); echo "<td>$num1 * $num2 </td>"; echo "<td><input type='text' size='2' name=${no_of_problems}_mult_${num1}_${num2}></td>"; $no_of_problems++; } echo "</tr>"; } $colspan = 2 * COLS; echo "<tr><td colspan=$colspan align='right'><input type='submit' value='Score' name='btn_score'></td></tr>"; ?> </table> </form> </body> </html> Similar TutorialsCould someone please tell me why this displays 3 columns correct and then all moves over. Here is the page you can see what I am talking about http://www.woodrun.org/includes/news.php I have looked the code over and over and can't see it. Thanks in advance. Code: [Select] <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $maxRows_Recordset1 = 1000000; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; mysql_select_db($database_woodrun, $woodrun); $query_Recordset1 = "SELECT * FROM news ORDER BY id DESC" ; $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $woodrun) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_fwragain, $fwragain); $query_Recordset1 = "SELECT * FROM news ORDER BY id DESC"; $Recordset1 = mysql_query($query_Recordset1, $woodrun) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <table width="100%" border="0" align="center" cellpadding="5" cellspacing="5"> <?php do { ?> <tr> <td colspan="4" align="left" valign="top"><?php echo "<img src=http://woodrun.org/images/".$row_Recordset1['photo'] ."> "; ?></td> <td width="550" align="left" valign="top"><?php echo $row_Recordset1['title']; ?> <hr /> <?php echo $row_Recordset1['article']; ?><br /></td> </tr> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </table> <?php mysql_free_result($Recordset1); ?> Hi everyone. I'm stuck on the following query. I need to display all the fields listed below on a page, but linked via communications.CommID. I'd appreciate any assistance you can provide. thank you. Code: [Select] <?php $result = mysql_query("SELECT records.NameFirst_1, records.NameLast_1, records.CompanyName, records.CompanyBranch, records.CompanyReferenceNumber, records.CaseOwnerSelect, communications.ConversionType, communications.Contact, communications.ContactFrom, communications.CommID, communications.ContactPosition, communications.ContactTelephone, communications.ContactEmail, communications.ContactFax, communications.CallDate, communications.CallTime, communications.ActionTextField FROM records INNER JOIN communications ON records.IDNumber = '$IDNumber'") or die(mysql_error()); $row = mysql_fetch_array($result); ?> <?php include_once("includes/config.php"); if(!$_GET['id'] && $_POST['id']) { $id = mysql_real_escape_string($_POST['id']); } elseif($_GET['id'] && !$_POST['id']) { $id = mysql_real_escape_string($_GET['id']); } else { } if(!$id) { $content = "Sorry, you have not selected a skin to view."; } else { $extract_information = mysql_query("SELECT title,username,downloads,views,id FROM skins WHERE id = '$id' LIMIT 1"); if(mysql_num_rows($extract_information) == 0) { $content = "Sorry, no skin exists with this ID."; } else { $extract = mysql_fetch_assoc($extract_information); function displayBody() { mysql_query("UPDATE skins SET views = views + 1 WHERE id = '$id'"); echo $extract['title']. ", by ". $extract['username'] ."."; } if(!$extract['password']) { $content = displayBody(); } elseif(!$password) { $content = "<br/><br/><div id='header'>Password</div> <form action='view.php' method='POST'><input type='password' name='password'> <input type='submit' value='View'></form>"; } else { if($password != $extract['password']) { $content = "You have entered in an incorrect password. <a href='view.php?id=". $id ."'>Try Again</a> or <a href='index.php'>Home</a>."; } else { $content = displayBody(); } } } } ?> <html> <head> <title><?php $title; ?></title> <link rel="stylesheet" type="text/css" href="theme/style.css" /> </head> <body> <div id="header"> MCSkins </div> <?php echo $content; ?> </table> </center> </body> </html> In the code above, the function does not include the data properly as seen he http://stonedknights.net46.net/view.php?id=2 And, why is the information above the black bar/title? In the code, you can see $content is echo'ed below the div id. So, why does the text appear above it? All I am trying to do is add a record on a page without the page refreshing. For that ajax is used. Here is the code.
It does not add the record to mysql table. Can anyone tell me what I am doing wrong?
record.php
<!DOCTYPE HTML> <html lang="en"> <head> <script type="text/javascript" src="js/jquery-1.11.0.min.js"></script> <script type="text/javascript" > $(function() { $(".submit_button").click(function() { var textcontent = $("#content").val(); var name = $("#name").val(); var dataString = 'content='+ textcontent + '&name='+name; if(textcontent=='') { alert("Enter some text.."); $("#content").focus(); } else { $("#flash").show(); $("#flash").fadeIn(400).html('<span class="load">Loading..</span>'); $.ajax({ type: "POST", url: "action.php", data: dataString, cache: true, success: function(html){ $("#show").after(html); document.getElementById('content').value=''; $("#flash").hide(); $("#content").focus(); } }); } return false; }); }); </script> </head> <body> <?php $record_id = $_GET['id']; // getting ID of current page record ?> <form action="" method="post" enctype="multipart/form-data"> <div class="field"> <label for="title">Name *</label> <input type="text" name="name" id="name" value="" maxlength="20" placeholder="Your name"> </div> <div class="field"> <label for="content">content *</label> <textarea id="content" name="content" maxlength="500" placeholder="Details..."></textarea> </div> <input type="submit" name="submit" value="submit" class="submit_button"> </form> <div id="flash"></div> <div id="show"></div> </body> </html>action.php if(isset($_POST['submit'])) { if(empty($_POST['name']) || empty($_POST['content'])) { $error = 'Please fill in the required fields!'; } else { try { $name = trim($_POST['name']); $content = trim($_POST['content']); $stmt = $db->prepare("INSERT INTO records(record_id, name, content) VALUES(:recordid, :name, :content"); $stmt->execute(array( 'recordid' => $record_id, 'name' => $name, 'content' => $content )); if(!$stmt){ $error = 'Please fill in the required fields.'; } else { $success = 'Your post has been submitted.'; } } catch(Exception $e) { die($e->getMessage()); } } } Hi Everyone, I will have a web application that users fill out and submit. I also have the same form in PDF format. I would like users to be able to click a print preview button, then open up FoxIt or Adobe and display the PDF, with their answers mapped to the correct location. I have no code, just looking for a direction and didn't know what to search for. Thanks. On my application there is 10 math questions. What I want to do when the test is finished is for it to tell the user how many they got right out of 10. Also how to put this into the database. I have everything else working fine on this application, I just would like to further enhance it by doing this. This is the code to my application. It is a small application. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Multiplication Test</title> </head> <body> </body> <?php require_once('database.php'); session_start(); define ('ROWS', 2); define ('COLS', 5); define ('MAX_NUMBER', 12); date_default_timezone_set('America/New_York'); if (isset($_POST['btn_score'])) { $result_name= $_POST['result_name']; $correct = 0; //print_r ($_POST); $time1 = $_POST['ts']; $time1_object = new DateTime($time1); $now = new DateTime(); $time_span = $now->diff($time1_object); $minutes = $time_span->format('%i'); $seconds = $time_span->format('%s'); $seconds+= $minutes * 60; echo "It took $seconds seconds to complete the test<hr />"; foreach ($_POST as $problem => $answer) { if ($problem <> "btn_score" && $problem <> "ts" && $problem <> "result_name") { //echo "$problem -- $answer <br />"; $problem = explode('_', $problem); $num1 = $problem[2]; $num2 = $problem[3]; $right = $num1 * $num2; if ($answer != $right) { echo "$num1 * $num2 = $answer , The right answer is $right<br />"; }else { $correct = $correct + 1; } } } $result_score= 0; $result_score= ($correct / 10) * 100; echo "your score is <br/>$result_score<br/>"; } { $sql = "INSERT INTO results (result_name, result_score, result_date_time) VALUES ('$result_name','$result_score', NOW());"; $db->exec($sql); } $query = "SELECT * FROM results WHERE result_name = :result_name "; $statement = $db->prepare($query); $statement->bindValue (':result_name', $result_name); $statement->execute(); $results = $statement->fetchAll(); $statement->closeCursor(); echo "<h1>Show Grades for $result_name </h1>"; foreach ($results as $result) { echo $result['result_name'] . " " . $result['result_score']. " " . $result['result_date_time']; echo '<br />'; } ?> <h1>Multiplication Test</h1> <form name="lab5" method="post" action="lab5b.php"> <?php $now = new DateTime(); //echo $now->format('Y-m-d H:i:s'); echo "<input type='hidden' name='ts' value='" . $now->format('Y-m-d H:i:s') . "'>"; ?> <table border="1" cellspacing="5" cellpadding="5"> <?php $no_of_problems = 0; for ($row=0; $row<ROWS; $row++) { echo "<tr>"; for ($col=0; $col<COLS; $col++) { $num1 = mt_rand(1,MAX_NUMBER); $num2 = mt_rand(1,MAX_NUMBER); echo "<td>$num1 * $num2 </td>"; echo "<td><input type='text' size='2' name=${no_of_problems}_mult_${num1}_${num2}></td>"; $no_of_problems++; } echo "</tr>"; } $colspan = 2 * COLS; echo "<tr><td colspan=$colspan align='right'><input type='submit' value='Score' name='btn_score'></td></tr>"; ?> </table> <br> <br> <label for="result_name">Student Name:</label> <input type="text" id="result_name" name="result_name" /><br /> </form> <br> <br> </body> </html> Ok here it is, seems like it is an easy problem but my developers are having some issue with this, I hope you guys can help. Basic question and answer problem, where I am developing a website that uses Items and questions like " How many of this Item do you need?" the answer seems to simple. Lets say the answer Is "1". The display is given to the Item list and we move on. Here is the Problem: When selecting Muiltiple Items in the List and they all have the same question associated to each Item: "How Many Items do you need?" the the answer is shared between the Items, Again, sounds simple so far, However, when the USER selects Multiple Items on a list say 30 Items then the Question should only be dispalyed one time, not 30 times, then the answer is shared 30 times. Thats what I have now being displayed on my website, 30 of the same questions over and over again. The USER will get frustrated and leave the site never to return. Question: How can I get the Question to be displayed only once, but shared between several items on a list? This is a very serious problem fo my website because I will have not have just one Item on a list but 300 to 400 items, and if I get the answer to the problem I have just wasted 1 year of my life developing something undevelopable (is that a word?). Any Help you can give me would greatly be appricated. Thank you in advance. What I'm trying to do is have it select the answers that are associated to that poll so that I can make a poll form out of this. Code: [Select] function getpoll($dbc) { $query = " SELECT polls.ID, polls.question, polls.totalVotes, (SELECT pollAnswers.ID, pollAnswers.answer FROM pollAnswers WHERE pollAnswers.pollID = polls.ID) FROM polls INNER JOIN pollAnswers ON polls.ID = pollAnswers.pollID WHERE polls.statusID = '1' ORDER BY polls.ID DESC LIMIT 1"; $result = mysqli_query($dbc, $query); $numrows = mysqli_num_rows($result); if ($numrows > "0") { } else { print "<p class=none>There are currently no open polls."; } } I've just learned the basics of MySQL last night and made a simple app (where a user enters a song name, song title, and rating (out of 5) and it displays the list of songs with the highest rated songs first). So I decided I wanted to make something similar yet slightly more complicated and I'm not sure if I'm on the right track. Basically it's a "flash card" game whe - The user gets to input their own questions and answers into a simple form, which would then go into an MySQL table with 2 columns, questions and answers - A new page where the user see's random question, must input an answer, if the answer matches goes to next question otherwise gives error Now I'm confused as to how to go about making this. I was thinking of making some session variables and then do something along the lines of Code: [Select] $display_query = "SELECT * FROM questions"; $display = mysqli_query($connection, $display_query); while ($row = mysqli_fetch_array($display)) { $_SESSION['question'] = $row[0]; }[/syntax] //and then make some PHP that might do something like this: if ($_SESSION['answer'] != $row[1]) { echo "error, try again" } else { // I would write something here to grab the next question } So am I just completely off the wall with this, how would I make such an app? How would I make it, for example, fetch new questions? Code: [Select] <?php if (!isset($_POST['submit'])) { ?> <h2>Todays Special</h2> <p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <select name="day"> <option value="1">Monday/Wednesday <option value="2">Tuesday/Thursday <option value="3">Friday/Sunday <option value="4">Saturday </select> input type="submit" name="submit" value="Go"> </form> <?php // get form selection $day = $_POST['day']; // check value and select appropriate item switch ($day) { case 1: $special = 'Chicken in oyster sauce'; break; case 2: $special = 'French onion soup'; break; case 3: $special = 'Pork chops with mashed potatoes and green salad'; break; default: $special = 'Fish and chips'; break; } ?> I am querying... $sql = "SELECT `messages_inbox`.`message_id`, `users`.`firstname`, `users`.`lastname`, `users`.`username` AS `from`, '${user_info['username']}' AS `to`, `subject`, LENGTH(`files`) AS `len`, 'inbox' AS `box`, DATE_FORMAT(`messages_inbox`.`time` ,'%T %D-%M-%Y') AS `time` "; $sql .= "FROM `messages_inbox` INNER JOIN `users` ON `messages_inbox`.`from_id` = `users`.`id` WHERE `to_id` = ${user_info['uid']} AND `messages_inbox`.`deleted` = 0 ORDER BY `messages_inbox`.`message_id` DESC"; and I am trying to output $displayName = ucwords("${message['firstname']} ${message['lastname']}"); by using $messages = pm_fetch_all($_GET['box']); I know my fetch works but for some reason firstname and lastname are only returning the logged in users first name and last name, not the person who sent the message. it's supposed to check the file, to see if it's available for download, the code below looks okay to me, what's wrong? if($row[2]==2) // 4shared check { $row[1]="http://www.".$row[1]; $index=getpage($row[1]); preg_match("/Download ([^<]+)<\/div>/",$index,$match); if(strpos($index,"The file is shared for public access and download.")===false || !$match) { mysql_query("UPDATE `v2links` SET `checked`='-1',`lastcheck`=NOW() WHERE `id`=".$row[0]); print "bad link\n"; logstr("log-c.txt","bad link\n"); } else { $words=trim($match[1]); $words=preg_split("/[_\.\-\s]/",$words); $lastword=array_pop($words); $words=implode(" ",$words); $words=preg_replace("/\s{2,}/"," ",$words); $caption=mysql_real_escape_string($words); unset($words); unset($match); preg_match("/<td>Size\:<\/td><td>([^<]+)<\/td>/",$index,$match); $fsize=$match[1]; unset($match); print "$caption :: $fsize\n"; logstr("log-c.txt","$caption :: $fsize\n"); mysql_query("UPDATE `v2links` SET `checked`='1',`lastcheck`=NOW(),`fsize`='$fsize',`caption`='$caption' WHERE `id`=".$row[0]); if(mysql_errno()) print mysql_error()."\n"; } } I'm wondering if the sharing website has changed anything, because for rapidshare it works fine, code: if($row[2]==1) // rapidshare check { $index=getpage($row[1]); if(strpos($index,"<p><script>alert(\"File not found.\")</script>File not found.</p>")===false && strpos($index,"This file has been deleted.")===false) { preg_match("/<form action=\"([^\"]+)\" method=\"post\">/",$index,$match); //print $index; if($match[1]) { $fpath=$match[1]; $index=getpage($fpath,"dl.start=Free",$row[1]); preg_match("/<\/font> \(([^\(]+)\)\.<\/p>/",$index,$match); $fsize=0; if($match[1]) $fsize=mysql_real_escape_string(strip_tags($match[1])); print $fsize."\n"; logstr("log-c.txt",$fsize."\n"); mysql_query("UPDATE `v2links` SET `checked`='1',`fsize`='$fsize',`lastcheck`=NOW() WHERE `id`=".$row[0]); if(mysql_errno()) print mysql_error()."\n"; } else { print "bad link\n"; logstr("log-c.txt","bad link\n"); mysql_query("UPDATE `v2links` SET `checked`='-1',`lastcheck`=NOW() WHERE `id`=".$row[0]); if(mysql_errno()) print mysql_error()."\n"; } } else { print "bad link\n"; logstr("log-c.txt","bad link\n"); mysql_query("UPDATE `v2links` SET `checked`='-1',`lastcheck`=NOW() WHERE `id`=".$row[0]); if(mysql_errno()) print mysql_error()."\n"; } } any help would be appreciated! Ok I have this code.. it logs into my myspace accounts and grabs some info.. it is supposed to log into each account and write the info to a file.. what it does is logs into the first account and writes the info to the file then when it signs into the second account it doesnt write the info on the new line it just overwrites the info from the previous account.. here is some of the code for($i=0; $i!=count($account_data); $i++){ echo "\n::: ".strtoupper($account_data[$i][0])." :::\n"; if($account_data[$i][1] != "" && stristr($account_data[$i][0], "@") && stristr($account_data[$i][0], ".")){ list($place[0],$place[1],$place[2],$place[3]) = authorize($account_data[$i], $game_link); if($place[2] > 1 && strlen($place[3]) == 40){ $filename = 'auth-keys.txt'; $fp = file($filename,'a+'); $data = $place[2]." ".$place[3]."\r\n"; file_put_contents($filename, $data); echo $data;}}} sleep(10000); heres a pic Any help would be greatly appreciated $result3 = mysql_query("SELECT User_ID FROM leaderboards WHERE User_ID = '$user'"); if(mysql_num_rows($result3) == 0){ $query1 = "INSERT INTO leaderboards (User_ID, CollegeFootballPoints) VALUES ('$user','$points')"; $result1 = mysql_query($query1); }else{ $query2 = "UPDATE leaderboards SET CollegeFootballPoints='$points' WHERE User_ID='$user'"; $result2 = mysql_query($query2); } I keep getting this error...' Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in update_collegeFBpoints_points.php on line 40 And the script is not working! (LINE 40 is $result3 = mysql_query("SELECT User_ID FROM leaderboards WHERE User_ID = '$user'"); if(mysql_num_rows($result3) == 0){ specifically mysql_num_rows) I have all error reporting turned on. And no errors are showing. I've been staring at this code for 2 hours and can't find the error. But the form is blank! The form shows up with the radio buttons but is blank! Heres the code... <?php error_reporting(E_ALL); ?> <?php include 'dbc.php'; //----------------------------------------- $result = mysql_query("SELECT * FROM users ORDER BY nc_points DESC"); while ($row = mysql_fetch_object($result)) { $leaderboard[] = $row->user_name; $leaderboardPoints[] = $row->cfb_points; } $result1 = mysql_query("SELECT CollegeFootballGames.ID, CollegeFootballGames.Week, CollegeFootballGames.Away, CollegeFootballGames.Home, CollegeFootballTeams.Team FROM CollegeFootballGames INNER JOIN CollegeFootballTeams ON CollegeFootballGames.Away = CollegeFootballTeams.ID || CollegeFootballGames.Home=CollegeFootballTeams.ID"); while ($row = mysql_fetch_object($result1)) { $GameID[] = $row->ID; $Teams[] = $row->Team; } //---------------------------------------- $date =("now"); if ( strtotime($date) > strtotime('18 July 2010') && strtotime($date) < strtotime('2 September 2010')){$wknum = '1'; $wk = "Week";} elseif ( strtotime($date) > strtotime('6 September 2010') && strtotime($date) < strtotime('11 September 2010')){$wknum = '2'; $wk = "Week";} elseif ( strtotime($date) > strtotime('11 September 2010') && strtotime($date) < strtotime('16 September 2010')){$wknum = '3'; $wk = "Week";} elseif ( strtotime($date) > strtotime('18 September 2010') && strtotime($date) < strtotime('23 September 2010')){$wknum = '4'; $wk = "Week";} elseif ( strtotime($date) > strtotime('25 September 2010') && strtotime($date) < strtotime('2 October 2010')){$wknum = '5'; $wk = "Week";} elseif ( strtotime($date) > strtotime('2 October 2010') && strtotime($date) < strtotime('9 October 2010')){$wknum = '6'; $wk = "Week";} elseif ( strtotime($date) > strtotime('9 October 2010') && strtotime($date) < strtotime('16 October 2010')){$wknum = '7'; $wk = "Week";} elseif ( strtotime($date) > strtotime('16 October 2010') && strtotime($date) < strtotime('23 October 2010')){$wknum = '8'; $wk = "Week";} elseif ( strtotime($date) > strtotime('23 October 2010') && strtotime($date) < strtotime('28 October 2010')){$wknum = '9'; $wk = "Week";} elseif ( strtotime($date) > strtotime('30 October 2010') && strtotime($date) < strtotime('4 November 2010')){$wknum = '10'; $wk = "Week";} elseif ( strtotime($date) > strtotime('6 November 2010') && strtotime($date) < strtotime('13 November 2010')){$wknum = '11'; $wk = "Week";} elseif ( strtotime($date) > strtotime('13 November 2010') && strtotime($date) < strtotime('20 November 2010')){$wknum = '12'; $wk = "Week";} elseif ( strtotime($date) > strtotime('20 November 2010') && strtotime($date) < strtotime('27 November 2010')){$wknum = '13'; $wk = "Week";} else{} //Form 12 $form12 = ('<h3><em style="color: #F00"> <?php echo $wk;?> <?php echo $wknum;?> </em></h3> <form name="Picks" method="post" action="<?php echo $process; ?>"> <p><br> <input name="P0" type="hidden" value="<?php echo ($p[0]); ?>"> <label> <input type="radio" name="game1" value="<?php echo ($away[0]);?>" > <?php echo ($away[0]);?></label> at <label> <input type="radio" name="game1" value="<?php echo ($home[0]);?>" > <?php echo ($home[0]);?></label> <br> <input name="P1" type="hidden" value="<?php echo ($p[1]); ?>"> <label> <input type="radio" name="game2" value="<?php echo ($away[1]);?>" > <?php echo ($away[1]);?></label> at <label> <input type="radio" name="game2" value="<?php echo ($home[1]);?>" > <?php echo ($home[1]);?></label> <br> <input name="P2" type="hidden" value="<?php echo ($p[2]); ?>"> <label> <input type="radio" name="game3" value="<?php echo ($away[2]);?>" > <?php echo ($away[2]);?></label> at <label> <input type="radio" name="game3" value="<?php echo ($home[2]);?>" > <?php echo ($home[2]);?></label> <br> <input name="P3" type="hidden" value="<?php echo ($p[3]); ?>"> <label> <input type="radio" name="game4" value="<?php echo ($away[3]);?>" > <?php echo ($away[3]);?> </label> at <label> <input type="radio" name="game4" value="<?php echo ($home[3]);?>" > <?php echo ($home[3]);?></label> <input name="P4" type="hidden" value="<?php echo ($p[4]); ?>"> <br> <label> <input type="radio" name="game5" value="<?php echo ($away[4]);?>" > <?php echo ($away[4]);?></label> at <label> <input type="radio" name="game5" value="<?php echo ($home[4]);?>" > <?php echo ($home[4]);?></label> <br> <input name="P5" type="hidden" value="<?php echo ($p[5]); ?>"> <label> <input type="radio" name="game6" value="<?php echo ($away[5]);?>" > <?php echo ($away[5]);?></label> at <label> <input type="radio" name="game6" value="<?php echo ($home[5]);?>" > <?php echo ($home[5]);?></label> <br> <input name="P6" type="hidden" value="<?php echo ($p[6]); ?>"> <label> <input type="radio" name="game7" value="<?php echo ($away[6]);?>" > <?php echo ($away[6]);?></label> at <label> <input type="radio" name="game7" value="<?php echo ($home[6]);?>" > <?php echo ($home[6]);?></label> <br> <input name="P7" type="hidden" value="<?php echo ($p[7]); ?>"> <label> <input type="radio" name="game8" value="<?php echo ($away[7]);?>" > <?php echo ($away[7]);?></label> at <label> <input type="radio" name="game8" value="<?php echo ($home[7]);?>" > <?php echo ($home[7]);?></label> <br> <input name="P8" type="hidden" value="<?php echo ($p[8]); ?>"> <label> <input type="radio" name="game9" value="<?php echo ($away[8]);?>" > <?php echo ($away[8]);?> </label> at <label> <input type="radio" name="game9" value="<?php echo ($home[8]);?>" > <?php echo ($home[8]);?></label> <br> <input name="P9" type="hidden" value="<?php echo ($p[9]); ?>"> <label> <input type="radio" name="game10" value="<?php echo ($away[9]);?>" > <?php echo ($away[9]);?> </label> at <label> <input type="radio" name="game10" value="<?php echo ($home[9]);?>" > <?php echo ($home[9]);?></label> <br> <input name="P10" type="hidden" value="<?php echo ($p[10]); ?>"> <label> <input type="radio" name="game11" value="<?php echo ($away[10]);?>" > <?php echo ($away[10]);?></label> at <label> <input type="radio" name="game11" value="<?php echo ($home[10]);?>" > <?php echo ($home[10]);?></label> <br> <input name="P11" type="hidden" value="<?php echo ($p[11]); ?>"> <label> <input type="radio" name="game12" value="<?php echo ($away[11]);?>" > <?php echo ($away[11]);?></label> at <label> <input type="radio" name="game12" value="<?php echo ($home[11]);?>" > <?php echo ($home[11]);?></label> <br> <br> <label> <input type="reset" name="button" id="button" value="Reset"> </label> <label> <input type="submit" name="button2" id="button2" value="Submit"> </label> <br> </p> </form>'); if ( strtotime($date) > strtotime('18 July 2010') && strtotime($date) < strtotime('2 September 2010')){$wknum = '1'; $formDisplay = $form12; $wk = "Week"; $process = 'cfb_picks_process.php'; $away =array("$Teams[0]","$Teams[2]","$Teams[4]","$Teams[6]","$Teams[8]","$Teams[10]","$Teams[12]","$Teams[14]","$Teams[16]","$Teams[18]","$Teams[20]","$Teams[22]"); $home =array("$Teams[1]","$Teams[3]","$Teams[5]","$Teams[7]","$Teams[9]","$Teams[11]","$Teams[13]","$Teams[15]","$Teams[17]","$Teams[19]","$Teams[21]","$Teams[23]"); $p = array ("$GameID[0]","$GameID[2]","$GameID[4]","$GameID[6]","$GameID[8]","$GameID[10]","$GameID[12]","$GameID[14]","$GameID[16]","$GameID[18]","$GameID[20]","$GameID[22]");} elseif ( strtotime($date) > strtotime('6 September 2010') && strtotime($date) < strtotime('11 September 2010')){$wknum = '2';$formDisplay = $form12; $wk = "Week";$process = 'cfb_picks_process.php'; $away =array("$Teams[24]","$Teams[26]","$Teams[28]","$Teams[30]","$Teams[33]","$Teams[34]","$Teams[36]","$Teams[38]","$Teams[40]","$Teams[42]","$Teams[44]","$Teams[46]"); $home =array("$Teams[25]","$Teams[27]","$Teams[29]","$Teams[31]","$Teams[32]","$Teams[35]","$Teams[37]","$Teams[39]","$Teams[41]","$Teams[43]","$Teams[45]","$Teams[47]"); $p = array ("$GameID[24]","$GameID[26]","$GameID[28]","$GameID[30]","$GameID[32]","$GameID[34]","$GameID[36]","$GameID[38]","$GameID[40]","$GameID[42]","$GameID[44]","$GameID[46]"); } elseif ( strtotime($date) > strtotime('11 September 2010') && strtotime($date) < strtotime('16 September 2010')){$wknum = '3';$formDisplay = $form12; $wk = "Week";$process = 'cfb_picks_process.php'; $away =array("$Teams[49]","$Teams[50]","$Teams[52]","$Teams[55]","$Teams[56]","$Teams[58]","$Teams[61]","$Teams[62]","$Teams[64]","$Teams[66]","$Teams[68]","$Teams[70]"); $home =array("$Teams[48]","$Teams[51]","$Teams[53]","$Teams[54]","$Teams[57]","$Teams[59]","$Teams[60]","$Teams[63]","$Teams[65]","$Teams[67]","$Teams[69]","$Teams[71]"); $p = array ("$GameID[48]","$GameID[50]","$GameID[52]","$GameID[54]","$GameID[56]","$GameID[58]","$GameID[60]","$GameID[62]","$GameID[64]","$GameID[66]","$GameID[68]","$GameID[70]"); } elseif ( strtotime($date) > strtotime('18 September 2010') && strtotime($date) < strtotime('23 September 2010')){$wknum = '4';$formDisplay = $form12; $wk = "Week";$process = 'cfb_picks_process.php'; $away =array("$Teams[72]","$Teams[74]","$Teams[76]","$Teams[78]","$Teams[80]","$Teams[83]","$Teams[85]","$Teams[87]","$Teams[88]","$Teams[91]","$Teams[92]","$Teams[94]"); $home =array("$Teams[73]","$Teams[75]","$Teams[77]","$Teams[79]","$Teams[81]","$Teams[82]","$Teams[84]","$Teams[86]","$Teams[89]","$Teams[90]","$Teams[93]","$Teams[95]"); $p = array ("$GameID[72]","$GameID[74]","$GameID[76]","$GameID[78]","$GameID[80]","$GameID[82]","$GameID[84]","$GameID[86]","$GameID[88]","$GameID[90]","$GameID[92]","$GameID[94]"); } elseif ( strtotime($date) > strtotime('25 September 2010') && strtotime($date) < strtotime('2 October 2010')){$wknum = '5';$formDisplay = $form12; $wk = "Week";$process = 'cfb_picks_process.php'; /*$away =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $home =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $p = array ("$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]"); */} elseif ( strtotime($date) > strtotime('2 October 2010') && strtotime($date) < strtotime('9 October 2010')){$wknum = '6';$formDisplay = $form12; $wk = "Week";$process = 'cfb_picks_process.php'; /*$away =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $home =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $p = array ("$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]"); */} elseif ( strtotime($date) > strtotime('9 October 2010') && strtotime($date) < strtotime('16 October 2010')){$wknum = '7';$formDisplay = $form12;$wk = "Week";$process = 'cfb_picks_process.php'; /*$away =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $home =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $p = array ("$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]"); */} elseif ( strtotime($date) > strtotime('16 October 2010') && strtotime($date) < strtotime('23 October 2010')){$wknum = '8';$formDisplay = $form12;$wk = "Week";$process = 'cfb_picks_process.php'; /*$away =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $home =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $p = array ("$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]"); */} elseif ( strtotime($date) > strtotime('23 October 2010') && strtotime($date) < strtotime('28 October 2010')){$wknum = '9';$formDisplay = $form12;$wk = "Week";$process = 'cfb_picks_process.php'; /*$away =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $home =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $p = array ("$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]"); */} elseif ( strtotime($date) > strtotime('30 October 2010') && strtotime($date) < strtotime('4 November 2010')){$wknum = '10';$formDisplay = $form12;$wk = "Week";$process = 'cfb_picks_process.php'; /*$away =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $home =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $p = array ("$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]"); */} elseif ( strtotime($date) > strtotime('6 November 2010') && strtotime($date) < strtotime('13 November 2010')){$wknum = '11';$formDisplay = $form12;$wk = "Week";$process = 'cfb_picks_process.php'; /*$away =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $home =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $p = array ("$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]"); */} elseif ( strtotime($date) > strtotime('13 November 2010') && strtotime($date) < strtotime('20 November 2010')){$wknum = '12';$formDisplay = $form12;$wk = "Week";$process = 'cfb_picks_process.php'; /*$away =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $home =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $p = array ("$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]"); */} elseif ( strtotime($date) > strtotime('20 November 2010') && strtotime($date) < strtotime('27 November 2010')){$wknum = '13';$formDisplay = $form12;$wk = "Week";$process = 'cfb_picks_process.php'; /*$away =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $home =array("$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]","$Teams[]"); $p = array ("$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]","$GameID[]"); */} else{$formDisplay = $wk = " "; $formDisplay = ("<br><br><h2>Picks For this week are final!</h2> <br><br><br> Check Back Later To Make Your Picks For Next Week");} $result = mysql_query("SELECT * FROM users ORDER BY nc_points DESC"); while ($row = mysql_fetch_object($result)) { $leaderboard[] = $row->user_name; $leaderboardPoints[] = $row->cfb_points; } $result1 = mysql_query("SELECT CollegeFootballGames.ID, CollegeFootballGames.Week, CollegeFootballGames.Away, CollegeFootballGames.Home, CollegeFootballTeams.Team FROM CollegeFootballGames INNER JOIN CollegeFootballTeams ON CollegeFootballGames.Away = CollegeFootballTeams.ID || CollegeFootballGames.Home=CollegeFootballTeams.ID"); while ($row = mysql_fetch_object($result1)) { $GameID[] = $row->ID; $Teams[] = $row->Team; } ?> <? echo $formDisplay; ?> If you see what is wrong please tell me. When the webpage loads it inserts all its information via xml into the database. This all works fine and perfect untill i reload the page again then it starts screwing up all the data im not sure what im doing wrong i know this isnt much info but is there a common mistake im making? So this appears when I try and go on my index.php...
Warning: require_once(/TZ/v3/includes/db.php) [function.require-once]: failed to open stream: No such file or directory in /home/*REMOVED*/public_html/TZ/v3/index.php on line 5 Fatal error: require_once() [function.require]: Failed opening required '/TZ/v3/includes/db.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/*REMOVED*/public_html/TZ/v3/index.php on line 5It's saying there's no file there but there is! Thanks Edited by rizmah, 14 September 2014 - 08:20 AM. I am trying to create a log in page but all that comes up is Please enter a username and password
<?php session_start () ; $username = $_POST ['username'] ; $password = $_POST ['passowrd'] ; if ($username&&$password) { define ('DB_HOST' , 'localhost') ; define ('DB_USER' , 'root') or die ("Could not connect!") ; define ('DB_PASSWORD', "") or die ("Could not find DB!") ; define ('DB_DATABASE', 'joke') ; } else die ("Please enter a username and password") ; $query = mysql_query ("SELECT * FROM Joke WHERE username = '$username'") ; $numrow = mysql_num_rows ($query) ; if ($numrows!=0) { //code to login While ($row= mysql_fetch_assoc($query)) { $dbusername = $row ['username'] ; $dbusername = $row ['password'] ; } //check if they match if ($username==$dbusername&&$password==$dbpassword) { echo "You're inn! <a href=member.php> Click here to enter member page" ; $_SESSION['username']=$dbusername ; } else echo "incorrect password!" ; } else die("That user does'nt exist") ; echo $numrows; ?> Hey, did something happen with the Facebook login for the phpFreaks forum recently? Been trying to log in for some time now but I kept receiving errors. Glad it's back working now!
|