Wednesday, 15 August 2012

html - PHP and MySQL query based on user input not working -


I am creating a user database where there are 4 fields: IDs, usernames, passwords and business. This is a test database. I tried to ask a question from the DB table and it worked, but I have a problem with having a user input and a MySQL query. I run an Apache server (Debian, Ubuntu) in Linux.

I have 2 pages. First of all there is a bare-bone test index page. This is the place where people have text boxes to give easy information to enter their information in DB. The code for this is:

After clicking the Submit button. This goes to the reg.php file. This is where it becomes complicated Page becomes empty !!! Nothing has been displayed or inputted in DB. FAQs work well, but when user interaction is added, then something is wrong. Here is the code for Reg.php:

< Pre class = "snippet-code-html lang-html prettyprint-override"> & lt ;? Php $ un = $ _POST ["u"] $ pk = $ _POST ["p"] $ fine = $ _POST ["O"] $ u = mysql_real_escape_string ($ combined); $ P = mysql_real_escape_string ($ pk); $ O = mysql_real_escape_string ($ OK); $ Link = mysql_connect ('localhost', 'root', 'randompassword'); If (! $ Link) {Dead ('Oh. We have a problem here:' Mysql_error ()); } If ($ link) {echo 'Successfully linked'; } Mysql_select_db ("Forums") or Die ('Oh. We have a problem here:' Mysql_error ()); $ Data = mysql_query ("Username (username, password, business) values ​​('{$ u}', '{$ p}', '{$ o}')"); ? & Gt;

Can I work to do this to correct this code? Thank you so much for your time. much appreciated.

EDIT: I saw that I did not add semicolon to the first 3 lines. After doing this, I found this error: "There is an error in your SQL syntax; use '{' '' '' '' '' '' '' '' '' '' on Line 1 To get the correct syntax, check out the manual related to your Mysore server version. "Why can anyone explain?

Edit: The website is just on my local machine ... on an Apache server at Linux

mysql_real_escape_string () requires a DB connection, try it ....

   

No comments:

Post a Comment