Using the given php script, I'm connected to the database and insert data into it but the data is in my database table Not being included. It is not throwing any errors Where is my code wrong?
& lt ;? Php $ host = '127.0.0.1'; $ Uname = 'root'; $ Pswd = ''; $ Mydb = 'portal'; If successfully connect to echo 'MySQL server' ($ myConn = new mysqli ($ host, $ uname, $ pswd)) & Lt; / Br & gt; '; Else Echo 'unable to connect to server & lt; / Br & gt; '; $ Database = mysqli_select_db ($ myConn, $ myDB); If the ($ databases) resonate 'connected to database ... & lt; / Br & gt; '; Else Echo 'database was not found! & Lt; / Br & gt; '; $ Var1 = 'string1'; $ Var2 = 'string2'; $ Query = "Include in user values ($ var1, $ var2)"; $ Result = mysqli_query ($ myConn, $ query) or die (mysqli_error ($ myConn)); ? & Gt; You must add single quotes around prices:
Insert $ query = "User values ('$ var1', '$ var2')
Or prepare a better statement, for example.
No comments:
Post a Comment