USE SELECT...WHERE FOR TEXT FIELDS IMPOSSIBLE

   I use SELECT search with WHERE fieldsname by VARCHAR imposible. But good use with INT fields.
   Why's that. Please tell me about it . My code as :
<?php     
         mysqli_select_db($connect ,'simple_login');

$sql = 'SELECT * FROM table where username= hai ' ;

$retval = mysqli_query($connect,$sql);
.....
?>

Not display error. But it's not connect and use with INT fields be good everything (as id=152)

Recommended Answers

All 3 Replies

Username is a text field so the comparison value must be quoted. Compare

SELECT * FROM table where username= hai

with

SELECT * FROM table where username= 'hai'

Thank you ! But i did it and result same with above error. It's unable get data from the table. I using Xampp

Who can help me. I get this problem a few days ago. Thanks very much!

Use to search in sql be normal. But if i use the code with text field to connect impossible. Use with int fields be ok but it must a number and unabe use for a number variable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.