Note that there are some explanatory texts on larger screens.

plurals
  1. POPeriodic failure when editing or creating in SQL using PHP
    primarykey
    data
    text
    <p>I have a problem which I can't really figure out. I am tranfering information from a form, via JSON, to a PHP file which is handling the database call.<br> When trying it on my apache server it works aprox 75% of the time. The last 25% nothing happens. The form-window will close as ment to, and the page will reload, but the information hasn't been put into the DB. <br> When trying it at my domain, nothing happens at all. Same code though (I have another DB_connection file, with domain info, which works other places).</p> <p>I'd like to have my code reviewed, to see if I have made a major mistake. Would love to have it 100% working. <br> As I said I have both a creation and an edit. I will post the edit form + php content here. If you need to see the creation, please tell me.</p> <p>Javascript function, called when pushing the edit key (a test will be performed on the form fields before):</p> <pre><code>function xmlHTTPEdit() { var product_ID = document.forms["addForm"]["product_ID"].value; var product_Name = document.forms["addForm"]["product_Name"].value; var product_Price = parseInt(document.forms["addForm"]["product_Price"].value); if(window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if(xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) { alert(xmlhttp.responseText); } } xmlhttp.open("POST", "../db/productEdit.php", true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.send("createID=" + product_ID + "&amp;createName=" + product_Name + "&amp;createPrice=" + product_Price); } </code></pre> <p>My php-file, updating DB, using the new data:</p> <pre><code>&lt;?php include('DB_Connect.php'); $product_ID = trim($_POST['createID']); $product_Name = trim($_POST['createName']); $product_Price = trim($_POST['createPrice']); $sql = "UPDATE products SET productName = '$product_Name', productPrice = '$product_Price' WHERE productID = '$product_ID'"; mysql_query($sql); ?&gt; </code></pre> <p>I really hope some of you can help me finding this flaw in my code and maybe help me with an explanation, why it works sometimes at localhost and never at my domain.</p> <p>Thanks. /Pyracell</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