InterviewSolution
| 1. |
Solve : examresult? |
|
Answer» Hi all.. $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.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 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 |
|