Null value problem in MySQL

Source: Internet
Author: User

Today, when writing a question-answering system, write a code like this:

<?PHPSession_Start();$db=Mysqli_connect(' localhost ', ' root ', ' root ', ' QA ');$tname=$_post[' Teacher '];$q= "Select Schedule,place from time where Tname= '$tname' and Sname is null ';$arr=Mysqli_query($db,$q);Echo"You have selected".$tname." Teacher "." <br/> Please continue to select the moment: "." <br/> ";><table border= "1" cellspacing= "0" > <tr> <th> time:</th> <th> location: </th&gt    ; </tr> <?PHP while($result=Mysqli_fetch_assoc($arr)) {        ?> <tr> <td><?phpEcho $result[' Schedule '];?></td> <td><?phpEcho $result[' Place '];?></td> </tr> <?php}?> </table> <form method= "POST" action= "stime1.php" >the time you choose is:<input type= "datetime" name= "Time"/>your question is:<textarea name= "question" ></textarea> <input type= "Submit" name= "sure" value= "OK"/></form>

is to select a teacher has not been selected time period, such a period of time can be displayed on the page for the new students to choose, but the page shows nothing, but the database has a matching condition of the existence of data items, and then I first copy and paste the SQL statement into the database run, showing that the query results are empty, Then I searched the internet and found in MySQL database sometimes is null does not work, the following is Baidu to say:

Finally, the sname is null changed to Sname= ', the successful detection of the required results, although a small knowledge point, but still remember, lest later for this small mistake waste time.


Null value problem in MySQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.