1.

Solve : examresult?

Answer»

Hi all..

I am trying to search a data from the database and trying to display( similar to that of displaying exam result, one will enter his registration number, he will be showed his results)

Pls help me how to do this.

I have a Wamp server with database

i have to search using column name called rollno

want to display colums called dob, name , email, phone no . All datas i have in database


Pls help me
Is this homework?
Are you using MySQL ?
Have you used it before?
Have you seen this:
HTTP://www.youtube.com/watch?v=DqEdTWjSnAQ
I have wamp server and database already.

i have used search.php

its code as follows

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

if(isset($_POST['submit'])) {
$srollno = $_POST['srollno'];

$sql1 = mysql_query("SELECT srollno FROM tbl_slamrec WHERE srollno = $srollno");
$row1 = mysql_num_rows($sql1);

if($row1 == 0) {
echo 'Error, ID does not exist';
} ELSE {
header('Location: show_result.php?srollno='.$srollno);
}
}
?>



Search











and show_result.php

its code

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


$srollno = $_GET['srollno'];

$sql1 = mysql_query("SELECT * FROM tbl_slamrec WHERE srollno = $srollno");
$row1 = mysql_fetch_array($sql1);
$rme = $row1['name'];
$mailme = $row1['marks'];
?>



Show Results



echo 'Name = '.$rme.'

Marks = '.$mailme;
?>







but i am getting an error

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\result\search.php on line 8

whatt should I do now?sorry, but I can not help you on this one.
But, I thin k yhou ought to make some comments about whkat the following line means.
Quote

$row1 = mysql_num_rows($sql1);
Placing comment in our code can help both others and yourself. Six months from now you might forget what it means. In particular, what is $sql1 -Is it a string or a scalar or a Boolean? Something else?
You do not use mysql_connect() to connect to a database, so mysql_query() returns false, and that result get's passed into mysql_num_rows which expects a resource rather than a boolean and you get the error you are receiving.



Quote from: Geek-9pm on July 24, 2013, 09:18:33 PM
But, I thin k yhou ought to make some comments about whkat the following line means.
Placing comment in our code can help both others and yourself. Six months from now you might forget what it means. In particular, what is $sql1 -Is it a string or a scalar or a Boolean? Something else?
It's common in the older PHP database functions. the variable is created as the result from mysql_query. This is normally a loosely typed value that is only used as a 'cookie' for other functions, such as mysql_num_rows. In this case mysql_query() is returning FALSE to INDICATE failure because the code hasn't opened a database connection.What should I do now to make the code to work?You need to call mysql_connect() before you start working with the database to connect to the database server. Documentation on this function can be found here: http://php.net/manual/en/function.mysql-connect.php

This function is deprecated so while it will work fine for now, if you plan on building any large applications you should look into using MySQLi as detailed here: http://www.php.net/manual/en/book.mysqli.php

You should ALSO get into the habit of escaping any user provided values (e.g. $_GET, $_POST) before adding them into your queries, otherwise you are WIDE open for SQL InjectionThank you sir,

But I dono exactly how to modify the line.

Can anyone please modify and give me that line?Quote from: Geek-9pm on July 24, 2013, 07:33:42 PM
Is this homework?

I'm thinking the answer to this question is "yes".Dear All Repliers,

I am basically from Electrical Engineering Background. I have interest in webdesigning, so I am learning this,. ,

Who from Electrical Engineering Gives Web designing as a homework? Quote from: gowthamprabhus on July 27, 2013, 07:10:01 PM
Dear All Repliers,

I am basically from Electrical Engineering Background. I have interest in webdesigning, so I am learning this,. ,

Who from Electrical Engineering Gives Web designing as a homework?
I am basically Santa Claus, I have an interesting in Programming and IT, so I often assist in a volunteer fashion on this forum.

Who from the North Pole gives MySQL advice?

Point being, you didn't negate anything that was claimed. You can make any number of wild claims. Replace "Electrical Engineering" with "Oval Office" and you see the problem. Even so, it's quite possible to verify what you are saying, rudimentarily, through a Google search. However, from what I found, you already claim to know PHP, and I find it difficult to imagine a case where somebody could "know" PHP but not know how to use mysql.

We have already provided you the means to help yourself. If you want somebody else to write the code for you, you should hire somebody else to do so; otherwise, you will have to invest in learning what you are doing. You cannot "hire" volunteers and ask for one line of code at a time.

You need to connect to the database. Look up what you are learning and using. Learn how it works. learn WHY you need to use db_connect(), and how you would do so. Otherwise, me, or anybody else telling you what line to write wouldn't help you, because you won't know what you need it. (And I don't know where you database server is, whether it's localhost, how your webhost has it configured, what the database name is, or any of those things, which would be needed to create the appropriate db_connect() call.)

If this is for a Freelance project I worry for the client.Thank you for your Reply @ B C Programmer



Discussion

No Comment Found