ankur0101 Posted December 7, 2008 Share Posted December 7, 2008 Hi friends, I am new in PHP MySQL. I am making one script of php exam results. I have following pages register.php search.php showresult.php Register.php - > A form where marks will be entered in database. I have done that. Search.php -> A search box with "Search" button where students will enter their roll number. showresult.php - > A page where results will be displayed according to the roll number entered in search.php page. The page showresult.php should work as follows ..... showresult.php?id=56 That means this will show the result of that student who's roll number is 56 ,, How can i do that ? Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/ Share on other sites More sharing options...
Mchl Posted December 7, 2008 Share Posted December 7, 2008 Use $id = $_GET['id']; in showresults.php Then use $id to get results from database Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708463 Share on other sites More sharing options...
john-formby Posted December 7, 2008 Share Posted December 7, 2008 Hi Ankur0101, Something like: search.php <?php $dbHost = "localhost"; $dbUser = "USERNAME"; $dbPass = "PASSWORD"; $dbname = "DBNAME"; $db = mysql_connect($dbHost,$dbUser,$dbPass); mysql_select_db($dbname,$db); if(isset($_POST['submit'])) { $rID = $_POST['rID']; $sql1 = mysql_query("SELECT rID FROM tblresults WHERE rID = $rID"); $row1 = mysql_num_rows($sql1); if($row1 == 0) { echo 'Error, ID does not exist'; } else { header('Location: showresult.php?rID='.$rID); } } ?> <html> <head> <title>Search</title> </head> <body> <form action="search.php" method="post"> <input type="text" name="rID" /> <input type="submit" name="submit" value="search" /> </form> </body> </html> showresult.php <?php $dbHost = "localhost"; $dbUser = "USERNAME"; $dbPass = "PASSWORD"; $dbname = "DBNAME"; $db = mysql_connect($dbHost,$dbUser,$dbPass); mysql_select_db($dbname,$db); $rID = $_GET['rID']; $sql1 = mysql_query("SELECT * FROM tblresults WHERE rID = $rID"); $row1 = mysql_fetch_array($sql1); $exam1 = $row1['exam1']; $exam2 = $row1['exam2']; ?> <html> <head> <title>Show Results</title> </head> <body> <?php echo 'Exam 1 = '.$exam1.'<br /> Exam 2 = '.$exam2; ?> </body> </html> Hope this helps, John Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708465 Share on other sites More sharing options...
ankur0101 Posted December 7, 2008 Author Share Posted December 7, 2008 thank you sir i will tell you after i make it Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708466 Share on other sites More sharing options...
ankur0101 Posted December 7, 2008 Author Share Posted December 7, 2008 Hello John Sir, Its working fine but 1 error Error in search.php I am using Dreamweaver 8 Warning: Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\phpresult\search.php:2) in D:\xampp\htdocs\phpresult\search.php on line 19 I am using show_result.php instead of showresult.php So i modified my code if(isset($_POST['submit'])) { $roll_no = $_POST['roll_no']; $sql1 = mysql_query("SELECT roll_no FROM result_table WHERE roll_no = $roll_no"); $row1 = mysql_num_rows($sql1); if($row1 == 0) { echo 'Error, ID does not exist'; } else { header('Location: show_result.php?roll_no='.$roll_no); But show_result.php is working fine. Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708477 Share on other sites More sharing options...
john-formby Posted December 7, 2008 Share Posted December 7, 2008 Hi Ankur0101, Please can you post all the code for that page? I am guessing you have something before the PHP script? This will be what is causing the error. Cheers, John Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708481 Share on other sites More sharing options...
ankur0101 Posted December 7, 2008 Author Share Posted December 7, 2008 Code of search.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php $hostname_php_result_conn = "localhost"; $database_php_result_conn = "phpresult"; $username_php_result_conn = "root"; $password_php_result_conn = "demoxampp"; $php_result_conn = mysql_connect($hostname_php_result_conn, $username_php_result_conn, $password_php_result_conn); mysql_select_db($database_php_result_conn,$php_result_conn); if(isset($_POST['submit'])) { $roll_no = $_POST['roll_no']; $sql1 = mysql_query("SELECT roll_no FROM result_table WHERE roll_no = $roll_no"); $row1 = mysql_num_rows($sql1); if($row1 == 0) { echo 'Error, ID does not exist'; } else { header('Location: show_result.php?roll_no='.$roll_no); } } ?> <html> <head> <title>Search</title> </head> <body> <form action="search.php" method="post"> <input name="roll_no" type="text" id="roll_no" /> <input type="submit" name="submit" value="search" /> </form> </body> </html> Code of show_result.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php $hostname_php_result_conn = "localhost"; $database_php_result_conn = "phpresult"; $username_php_result_conn = "root"; $password_php_result_conn = "demoxampp"; $php_result_conn = mysql_connect($hostname_php_result_conn, $username_php_result_conn, $password_php_result_conn); mysql_select_db($database_php_result_conn,$php_result_conn); $roll_no = $_GET['roll_no']; $sql1 = mysql_query("SELECT * FROM result_table WHERE roll_no = $roll_no"); $row1 = mysql_fetch_array($sql1); $name = $row1['name']; $marks = $row1['marks']; ?> <html> <head> <title>Show Results</title> </head> <body> <?php echo 'Name = '.$name.'<br /> Marks = '.$marks; ?> </body> </html> That's it... Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708505 Share on other sites More sharing options...
.josh Posted December 7, 2008 Share Posted December 7, 2008 you have that doctype line at the top of your script but later on in your script you call header() based on some condition. Well if condition evaluates true, you get the error, because any output causes headers to be sent. I suggest you move the doctype tag down to where the rest of your html is. And make sure you remove the line completely, not just the code. No output can be sent, not even whitespace, before header(); Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708512 Share on other sites More sharing options...
ankur0101 Posted December 7, 2008 Author Share Posted December 7, 2008 Yes Sir , Now its working fine.... Thank you very much :) Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708514 Share on other sites More sharing options...
ankur0101 Posted December 7, 2008 Author Share Posted December 7, 2008 Yes and 1 more question, Suppose i have only 5 students data that means 1,2,3,4,5 roll no.s are only stored in database. When i type show_result?roll_no=8 ( Roll No. 8 doesn't exist in database ) Its shows me page with only Name = Marks = I want to do it as there should an error with text "Invalid Roll No." What i have to do for that ? Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708515 Share on other sites More sharing options...
jnerotrix Posted December 7, 2008 Share Posted December 7, 2008 Try this <?php $filename = "/show_result.php?roll_no=' . $roll_no . '"; if (file_exists($filename)) { echo 'Name = '.$name.'<br /> Marks = '.$marks; } else { echo "Invalid Roll No."; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708521 Share on other sites More sharing options...
.josh Posted December 7, 2008 Share Posted December 7, 2008 Your search.php already does that. If no rows are returned, you have echo 'Error, ID does not exist'; Otherwise, it sends you to show_result.php. Since your show_result.php just takes the GET var and does a query based on that value, there's nothing to stop someont from directly going to show_result.php. So you have a couple of options. You can... a) Do the same thing in show_result.php as you did in search.php (run the query and if num_rows == 0, give error message). This isn't really that great of an option, as it's in essence duplicating code. That is, why bother with search.php at all, if you're just going to turn around and do the same thing again, in show_result.php? b) Put a condition in show_result.php to kick the user back to search.php if the referring page is not search.php <?php if ($_SERVER['HTTP_REFERER'] != 'search.php') { header("Location: search.php"); exit; } // rest of code here ?> Slightly better option, but personally, I'd go for option c. c) Combine search.php and show_result.php into a single script. Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708522 Share on other sites More sharing options...
jnerotrix Posted December 7, 2008 Share Posted December 7, 2008 If you want single page try this <?php $hostname_php_result_conn = "localhost"; $database_php_result_conn = "phpresult"; $username_php_result_conn = "root"; $password_php_result_conn = "demoxampp"; $php_result_conn = mysql_connect($hostname_php_result_conn, $username_php_result_conn, $password_php_result_conn); mysql_select_db($database_php_result_conn,$php_result_conn); if(isset($_POST['submit'])) { $roll_no = $_POST['roll_no']; $sql1 = mysql_query("SELECT roll_no FROM result_table WHERE roll_no = $roll_no"); $row1 = mysql_num_rows($sql1); if($row1 == 0) { echo 'Error, ID does not exist'; } else { $sql1 = mysql_query("SELECT * FROM result_table WHERE roll_no = $roll_no"); $row1 = mysql_fetch_array($sql1); $name = $row1['name']; $marks = $row1['marks']; echo 'Name = '.$name.'<br /> Marks = '.$marks; } } else { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Search</title> </head> <body> <form action="search.php" method="post"> <input name="roll_no" type="text" id="roll_no" /> <input type="submit" name="submit" value="search" /> </form> </body> </html> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708526 Share on other sites More sharing options...
ankur0101 Posted December 7, 2008 Author Share Posted December 7, 2008 Well, How can i combine them in 1 page ? Like at the top, there is a Search box with Submit button after that there will be a result. How to do that ? In 1 page ? Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708539 Share on other sites More sharing options...
jnerotrix Posted December 7, 2008 Share Posted December 7, 2008 Here you go Use This Code for The Page search.php (This Is Made to Be its own Page) Here is a working example http://1800sexnow.com/demos/search/search.php <?php error_reporting(E_ALL); $hostname_php_result_conn = "localhost"; $database_php_result_conn = "sex1800_phpresults"; $username_php_result_conn = "sex1800_demo"; $password_php_result_conn = "demotable"; $php_result_conn = mysql_connect($hostname_php_result_conn, $username_php_result_conn, $password_php_result_conn); mysql_select_db($database_php_result_conn,$php_result_conn); if(isset($_POST['submit'])) { $roll_no = $_POST['roll_no']; $sql = mysql_query("SELECT * FROM result_table WHERE roll_no = $roll_no") or die (mysql_error()); $row1 = mysql_fetch_array($sql); $name = $row1['name']; $marks = $row1['marks']; if($row1 == 0) { echo 'Error, ID does not exist'; } else { echo 'Name = '.$name.'<br /> Marks = '.$marks; } } else { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <script type="text/javascript"> function validate_required(field,alerttxt) { with (field) { if (value==null||value=="") {alert(alerttxt);return false;} else {return true} } } function validate_form(thisform) { with (thisform) { if (validate_required(roll_no,"You Must type In a Role Number")==false) {roll_no.focus();return false;} } } </script> <style type="text/css"> #header { width:100%; background:lightblue; margin:0px; padding:0px; } #leftbar { float:left; width:40%; height:30px; background:lightblue; text-align:right; } #rightbar { float:left; width:60%; height:30px; background:lightblue; text-align:center; } #bar { width:100%; background:lightblue; } #center {float:center; width:60%; height:10px; background:lightblue; align:center; } a { font-family:Arial; font-size:16px; background-color:aqua; color:blue; font-weight:bold; vertical-align:text-bottom; } a:hover { font-family:Lucida Calligraphy; font-size:ahoversize1; background-color:yellow; color:darkblue; } </style> <script type="text/javascript"> function numbersonly(myfield, e, dec) { var key; var keychar; if (window.event) key = window.event.keyCode; else if (e) key = e.which; else return true; keychar = String.fromCharCode(key); // control keys if ((key==null) || (key==0) || (key== || (key==9) || (key==13) || (key==27) ) return true; // numbers else if ((("0123456789").indexOf(keychar) > -1)) return true; // decimal point jump else if (dec && (keychar == ".")) { myfield.form.elements[dec].focus(); return false; } else return false; } </script> </head> <center> <body> <br><Br><Br> <h1> Search Roll Number </h1> <Br><br> <div id="header"> <div id="center"> <table> <form action="search.php" method="post" onsubmit="return validate_form(this)"> <tr> <td>Roll Number:</td><td><input name="roll_no" type="text" id="roll_no" onkeypress="return numbersonly(this, event)" /></td> </tr> <tr> <td align="center"><input type="submit" name="submit" value="search" /></td> </tr> </form> </table> </div> <div id="leftbar"> </div> <div id="rightbar"> </div> </div> <div id="bar"> </div> <div id="header"> <div id="leftbar"> </div> <div id="rightbar"> </div> </div> </body> </html> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708597 Share on other sites More sharing options...
.josh Posted December 7, 2008 Share Posted December 7, 2008 I guess no one told you js form validation is a bad idea. I can turn off my js and sql inject your working example all day long. Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708613 Share on other sites More sharing options...
jnerotrix Posted December 7, 2008 Share Posted December 7, 2008 There Problem Solved No More Javascript All Written in PHP Use This for Search.php <?php $hostname_php_result_conn = "localhost"; $database_php_result_conn = "sex1800_phpresults"; $username_php_result_conn = "sex1800_demo"; $password_php_result_conn = "demotable"; $php_result_conn = mysql_connect($hostname_php_result_conn, $username_php_result_conn, $password_php_result_conn); mysql_select_db($database_php_result_conn,$php_result_conn); if(isset($_POST['submit'])) { $roll_no = isset($_POST['roll_no'])?trim($_POST['roll_no']):null; if (!is_null($roll_no) && !empty($roll_no)) { $string = $roll_no; $replace = "0"; $result = preg_replace("/[^0-9]/","$replace", $string); $roll_no = $result; $sql = mysql_query("SELECT * FROM result_table WHERE roll_no = $roll_no") or die (mysql_error()); $row1 = mysql_fetch_array($sql); $name = $row1['name']; $marks = $row1['marks']; } if($row1 == 0) { echo 'Error, ID does not exist'; } else { echo 'Name = '.$name.'<br /> Marks = '.$marks; } } else { ?> <html> <head> <style type="text/css"> #header { width:100%; background:lightblue; margin:0px; padding:0px; } #leftbar { float:left; width:40%; height:30px; background:lightblue; text-align:right; } #rightbar { float:left; width:60%; height:30px; background:lightblue; text-align:center; } #bar { width:100%; background:lightblue; } #center {float:center; width:60%; height:10px; background:lightblue; align:center; } a { font-family:Arial; font-size:16px; background-color:aqua; color:blue; font-weight:bold; vertical-align:text-bottom; } a:hover { font-family:Lucida Calligraphy; font-size:ahoversize1; background-color:yellow; color:darkblue; } </style> </head> <center> <body> <br><Br><Br> <h1> Search Roll Number </h1> <Br><br> <div id="header"> <div id="center"> <table> <form action="search.php" method="post"> <tr> <td>Roll Number:</td><td><input name="roll_no" type="text" id="roll_no" /></td> </tr> <tr> <td align="center"><input type="submit" name="submit" value="search" /></td> </tr> </form> </table> </div> <div id="leftbar"> </div> <div id="rightbar"> </div> </div> <div id="bar"> </div> <div id="header"> <div id="leftbar"> </div> <div id="rightbar"> </div> </div> </body> </html> <?php } ?> Demo Here http://1800sexnow.com/demos/search/search.php *If user Types Nothing Displays "Error, ID does not exist" *If User types Anything other than a number displays "Error, ID does not exist" *Displays "Error, ID does not exist" if roll_no does not exist Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708670 Share on other sites More sharing options...
jnerotrix Posted December 7, 2008 Share Posted December 7, 2008 Updated Code: Added Better Display of ID & If ID Does Not Exist Demo Here: http://1800sexnow.com/demos/search/search.php <?php $hostname_php_result_conn = "localhost"; $database_php_result_conn = "sex1800_phpresults"; $username_php_result_conn = "sex1800_demo"; $password_php_result_conn = "demotable"; $php_result_conn = mysql_connect($hostname_php_result_conn, $username_php_result_conn, $password_php_result_conn); mysql_select_db($database_php_result_conn,$php_result_conn); if(isset($_POST['submit'])) { $roll_no = isset($_POST['roll_no'])?trim($_POST['roll_no']):null; if (!is_null($roll_no) && !empty($roll_no)) { $string = $roll_no; $replace = "0"; $result = preg_replace("/[^0-9]/","$replace", $string); $roll_no = $result; $sql = mysql_query("SELECT * FROM result_table WHERE roll_no = $roll_no") or die (mysql_error()); $row1 = mysql_fetch_array($sql); $name = $row1['name']; $marks = $row1['marks']; if($row1 == 0) { ?> <!-- Role Number Does Not Exist --!> <head> <style type="text/css"> #header { width:100%; background:lightblue; margin:0px; padding:0px; } #leftbar { float:left; width:40%; height:30px; background:lightblue; text-align:right; } #rightbar { float:left; width:60%; height:30px; background:lightblue; text-align:center; } #bar { width:100%; background:lightblue; } #center {float:center; width:60%; height:10px; background:lightblue; align:center; } a { font-family:Arial; font-size:16px; background-color:lightblue; color:blue; font-weight:bold; vertical-align:text-bottom; } a:hover { font-family:arial; font-size:ahoversize1; background-color:black; color:darkblue; } </style> </head> <center> <br><Br><Br> <h1> Error </h1><br> <div id="header"> <div id="center"> <table> <tr> <td><b><?php echo 'Error, ID does not exist'; ?></b></td> </tr> <tr> <td><a href="./search.php">Search Again</a></td> </tr> </table> </div> <div id="leftbar"> </div> <div id="rightbar"> </div> </div> <div id="bar"> </div> <div id="header"> <div id="leftbar"> </div> <div id="rightbar"> </div> </div> <!-- Role Number Does Not Exist --!> <?php } else { ?> <!-- Start of After Submitted Contet --!> <head> <style type="text/css"> #header { width:100%; background:lightblue; margin:0px; padding:0px; } #leftbar { float:left; width:40%; height:30px; background:lightblue; text-align:right; } #rightbar { float:left; width:60%; height:30px; background:lightblue; text-align:center; } #bar { width:100%; background:lightblue; } #center {float:center; width:60%; height:10px; background:lightblue; align:center; } a { font-family:Arial; font-size:16px; background-color:aqua; color:blue; font-weight:bold; vertical-align:text-bottom; } a:hover { font-family:Lucida Calligraphy; font-size:ahoversize1; background-color:yellow; color:darkblue; } </style> </head> <center> <br><Br><Br> <h1> Name <?php echo "$name"; ?> </h1><br> <div id="header"> <div id="center"> <table> <tr> <td><b>Marks:</b></td> </tr> <tr> <td><?php echo "$marks"; ?></td> </tr> </table> </div> <div id="leftbar"> </div> <div id="rightbar"> </div> </div> <div id="bar"> </div> <div id="header"> <div id="leftbar"> </div> <div id="rightbar"> </div> </div> <!-- End of Role Number Display --!> <?php } } } else { ?> <html> <head> <style type="text/css"> #header { width:100%; background:lightblue; margin:0px; padding:0px; } #leftbar { float:left; width:40%; height:30px; background:lightblue; text-align:right; } #rightbar { float:left; width:60%; height:30px; background:lightblue; text-align:center; } #bar { width:100%; background:lightblue; } #center {float:center; width:60%; height:10px; background:lightblue; align:center; } a { font-family:Arial; font-size:16px; background-color:aqua; color:blue; font-weight:bold; vertical-align:text-bottom; } a:hover { font-family:Lucida Calligraphy; font-size:ahoversize1; background-color:yellow; color:darkblue; } </style> </head> <center> <body> <br><Br><Br> <h1> Search Roll Number </h1> <Br><br> <div id="header"> <div id="center"> <table> <form action="search.php" method="post"> <tr> <td>Roll Number:</td><td><input name="roll_no" type="text" id="roll_no" /></td> </tr> <tr> <td align="center"><input type="submit" name="submit" value="search" /></td> </tr> </form> </table> </div> <div id="leftbar"> </div> <div id="rightbar"> </div> </div> <div id="bar"> </div> <div id="header"> <div id="leftbar"> </div> <div id="rightbar"> </div> </div> </body> </html> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-708695 Share on other sites More sharing options...
ankur0101 Posted April 18, 2009 Author Share Posted April 18, 2009 Hi friends, So finally I am again here, after so many months I was out of town and I am back on my project of phpresult Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-813107 Share on other sites More sharing options...
ankur0101 Posted April 18, 2009 Author Share Posted April 18, 2009 I have re-written the whole code index.php - The page where student will search for his result by entering roll number in text box <?php // Connection to database //require_once ("includes/settings.php") $hostname = "localhost"; $database = "phpresult"; $username = "root"; $password = "demojoomla"; $conn = mysql_connect($hostname, $username, $password); mysql_select_db($database,$conn); if(isset($_POST['submit'])) { $roll_number = $_POST['roll_no_textbox']; $sql1 = mysql_query("SELECT roll_no FROM result-table WHERE roll_no = $roll_number"); $row1 = mysql_num_rows($sql1); if($row1 == 0) { echo 'Error, ID does not exist'; } else { header('Location: result.php?roll_no='.$roll_number); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> </head> <body> <table width="664" height="260" border="0"> <tr> <td height="88"> </td> </tr> <tr> <td><p> </p> <form id="form1" name="form1" method="post" action="result.php"> <div align="center"> <label>Roll Number : <input type="text" name="roll_no_textbox" id="roll_no_textbox" /> </label> <label> <input type="submit" name="button" id="button" value="search" /> </label> </div> </form> <p align="center"> </p> <p> </p></td> </tr> <tr> <td> </td> </tr> </table> </body> </html> result.php - The page of result <?php $hostname = "localhost"; $database = "phpresult"; $username = "root"; $password = "demojoomla"; $conn = mysql_connect($hostname, $username, $password); mysql_select_db($database,$conn); $roll_number = $_GET['roll_no_textbox']; $sql1 = mysql_query("SELECT * FROM result_table WHERE roll_no = $roll_number"); $row1 = mysql_fetch_array($sql1); //$exam1 = $row1['exam1']; //$exam2 = $row1['exam2']; $result_name = $row1['name']; $result_roll_number = $row1['roll_no']; $result_accounts_l = $row1['accounts-l']; $result_accounts_ll = $row1['accounts-ll']; $result_accounts_lll = $row1['accounts-lll']; $result_mpp = $row1['mpp']; $result_economy = $row1['economy']; $result_taxation = $row1['taxation']; $result_computer = $row1['computer']; ?> <!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>Untitled Document</title> </head> <body> <table width="664" height="260" border="0"> <tr> <td height="88"> </td> </tr> <tr> <td><p align="center">Your Result is here ...</p> <table width="649" height="189" border="0"> <tr> <td colspan="4">Name : <?php echo $result_name ?></td> </tr> <tr> <td colspan="2">Roll Number : <?php echo $result_roll_number ?></td> <td colspan="2"> </td> </tr> <tr> <td width="156"><div align="right">Accounts I : </div></td> <td width="160"><?php echo $result_accounts_l ?></td> <td width="160"><div align="right">Economics : </div></td> <td width="155"><?php echo $result_economics ?></td> </tr> <tr> <td><div align="right">Accounts II : </div></td> <td><?php echo $result_accounts_ll ?></td> <td><div align="right">MPP : </div></td> <td><?php echo $result_mpp ?></td> </tr> <tr> <td><div align="right">Accounts III : </div></td> <td><?php echo $result_accounts_lll ?></td> <td><div align="right">Taxation : </div></td> <td><?php echo $result_taxation ?></td> </tr> <tr> <td colspan="2"> </td> <td colspan="2"> </td> </tr> </table> <div align="center"></div> <p align="center"> </p> <p align="center"> </p> <p> </p></td> </tr> <tr> <td> </td> </tr> </table> </body> </html> When I search for roll number 1 , its giving error on top of result.php Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\PHPresult\result.php on line 11 Whats the problem ? I think its there in $row1 = mysql_fetch_array($sql1); I am confused .. :-[ Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-813113 Share on other sites More sharing options...
Mchl Posted April 18, 2009 Share Posted April 18, 2009 This indicates that the query $sql1 = mysql_query("SELECT * FROM result_table WHERE roll_no = $roll_number"); failed. Try displaying mysql_error Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-813117 Share on other sites More sharing options...
ankur0101 Posted April 18, 2009 Author Share Posted April 18, 2009 Ok but in which page should i replace it ? in index.php or result.php ? or in both ? Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-813123 Share on other sites More sharing options...
Mchl Posted April 18, 2009 Share Posted April 18, 2009 What does the error message tell you? Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-813125 Share on other sites More sharing options...
ankur0101 Posted April 18, 2009 Author Share Posted April 18, 2009 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\PHPresult\result.php on line 11 Thats in result.php that means something is messing in result.php on line 11 Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-813133 Share on other sites More sharing options...
Mchl Posted April 18, 2009 Share Posted April 18, 2009 Yes. The query ran in line 10 of result.php fails. That's why you should try to see what error it produces. Change line 10 to $sql1 = mysql_query("SELECT * FROM result_table WHERE roll_no = $roll_number") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/135906-solved-exam-results-script-please-help-me/#findComment-813152 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.