Note that there are some explanatory texts on larger screens.

plurals
  1. POposting from java to php and inserting it into mysql database
    primarykey
    data
    text
    <p>I write a simple post from java to my php backend. After I run the script I am getting the output that I am passing in filename, filesize etc..</p> <pre><code>int filesize=25; String filetype=".txt"; String hash="sdfjksdfhljahe8wr897348957jsdfajlsdhfl48"; String email="sangwan.ritesh@yahoo.in"; String filename="songs.txt"; String urlParameters = "filename="+filename+"&amp;filesize="+filesize+"&amp;filetype="+filetype+"&amp;filehash="+hash+"&amp;email="+email; URL url = new URL("myurl"); HttpURLConnection hp=(HttpURLConnection)url.openConnection(); hp.setDoInput(true); hp.setDoOutput(true); hp.setInstanceFollowRedirects(false); hp.setRequestMethod("POST"); hp.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); hp.setRequestProperty("charset", "utf-8"); hp.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length)); hp.setUseCaches (false); DataOutputStream wr = new DataOutputStream(hp.getOutputStream ()); wr.writeBytes(urlParameters); wr.flush(); String line; BufferedReader reader = new BufferedReader(new InputStreamReader(hp.getInputStream())); line = reader.readLine(); System.out.println(line); wr.close(); reader.close(); hp.disconnect(); </code></pre> <p>The problem is I want to insert these values into my mysql database running on server so I write the following php code.</p> <pre><code>&lt;?php include('dbc.php'); $filename=$_POST['filename']; $filesize=$_POST['filesize']; $filetype=$_POST['filetype']; echo $POST['email']; $filehash=$_POST['filehash']; $email=$_POST['email']; $query = "INSERT INTO files ( `email`, `file_name`, `file_ext`, `file_size`, 'file_hash') VALUES ( '$email', '$filename', '$filetype', '12584', 'filehash')"; $result=mysqli_query($dbc,$query); if(mysqli_affected_rows($dbc) == 1) { // DO Nothing } echo $_POST['filehash']; echo $_POST['email']; echo $_POST['filename']; echo $_POST['filesize']; echo $_POST['filetype']; ?&gt; </code></pre> <p>The data is being is posted and I am getting the same back in my java application but data is not being entered in mysql database. I have a table name files with the same columns described above. I tried to get error from mysql_error but I am not getting any error.</p> <p>UPDATE: Problem solved silly sql syntax mistake using ' instead of ` near file_hash</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload