php - mysql error in my page -
I need help with a problem that I'm connecting to my database and what I want I have already programmed in PHP and have never run into this problem. I'm getting this error message.
There is an error in your SQL syntax;
& lt ;? Php $ con = mysqli_connect ("localhost", "root", "", "the specialist"); $ Username = $ _GET ['Username']; $ Query = "SELECT * FROM` character 'WHERE' username '= $ user name'; $ Data = mysqli_query ($ con, $ query) or die (mysqli_error ($ con)); ? & Gt; Using a PDO, this is a port of your code, maybe it will be of interest, connect to the database using don 'A' PDO {$ db = new PDO ('mysql: host = localhost; dbname = thespianassistant', Use 'old mysql_ * functions.
& quot; route', 'you_should_set_a_password'); $ Db- & gt; Set attribute (PDO :: ATTRRAMOD, PDO :: ERRMODE_EXCEPTION); $ Db- & gt; Set attribute (PDO :: ATTR_EMULATE_PREPARES, incorrect); // DB & amp; Get the result $ sql = "SELECT * FROM` character 'WHERE user name =: username'; $ Query = $ db- & gt; ready ($ sql); $ query- & gt; Execute (array: User name '= & gt; $ _GET [' username '])); $ result = $ query- & gt; get all (PDO :: FETCH_ASSOC);} hold (PDOException $ e) {dead ($ e- & gt; getMessage ()); / / something with the result if (empty ($ result)) echo '
Comments
Post a Comment