Wednesday 15 January 2014

Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use -



Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use -

okay im having annying error when im trying typing in username , password know problem ?

the error : http://gyazo.com/9ee7a24d164be385c499a2bf82022720 database: http://gyazo.com/4524567fd304d4181ce0c82f8e715ea8

<!doctype html> <html> <head> </head> <body> <h1>login</h1> <p> <?php if (strtoupper($_server['request_method']) == 'post') { $link = mysql_connect('localhost', 'databasename', 'password'); if (!$link) { die('not connected : ' . mysql_error()); } $db_selected = mysql_select_db('databasename', $link); if (!$db_selected) { die ('can\'t utilize foo : ' . mysql_error()); } $query = "select username, pass hejsan ='".$_post['username'] ."' , pass ='".$_post['pass']."' limit 0, 30 "; echo $query; echo "<br><br>"; $result = mysql_query($query); if (!$result) { $message = 'invalid query: ' . mysql_error() . "\n"; $message .= 'whole query: ' . $query; die($message); } echo "<ul>"; while ($row = mysql_fetch_assoc($result)) { echo "<li>"; echo "inloggad som:". $row['username']." med lösen:".$row['pass']; echo "</li>"; } echo "</ul>"; mysql_free_result($result); } ?> <form method="post"> username:<input type="text" name="username"><br> password:<input type="text" name="pass"><br> <input type="submit"> </form> </p> </body> </html>

you didn't specify field in query.

it should be

"select username, pass hejsan ***username*** ='".$_post['username'] ."' , pass ='".$_post['pass']."'

limit 0, 30 ";

where username field usernames stored.

mysql

No comments:

Post a Comment