Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Insert won't insert on all fields
    primarykey
    data
    text
    <p>I have PHP generating an HTML form and I'm trying to write a script that will update the information in the database. For some reason it works on some of the fields and not others.</p> <p>Code which won't work:</p> <p>PHP-Form that users can change details within</p> <pre><code>echo"&lt;form name='details'&gt;"; echo"&lt;p&gt;Surname: &lt;input type='text'id='surname' value='".$row['Surname']."'/&gt;&lt;/p&gt;; &lt;p&gt;Telephone: &lt;input type='text'id='phone' value='".$row['Telephone']."'/&gt;&lt;/p&gt;; &lt;p&gt;Postcode: &lt;input type='text' id='postcode' value='".$row['Postcode']."'/&gt;&lt;/p&gt;; &lt;p&gt;House/Flat Number: &lt;input type='text' id='number' value='".$row['Number']."'/&gt;&lt;/p&gt;"; </code></pre> <p>AJAX - sends changes to server via querystring</p> <pre><code> var sname = document.getElementById('surname').value; var tel = document.getElementById('phone').value; var num = document.getElementById('number').value; var pcode = document.getElementById('postcode').value; var queryString = "?username=" + username +"&amp;email="+email...."; ajaxRequest.open("GET", "url" + queryString, true); ajaxRequest.send(null); </code></pre> <p>PHP - execute update command</p> <pre><code>//connect to server ... //get variables $sname = $_GET['sname']; $pcode = $_GET['pcode']; $tel = $_GET['tel']; $num=$_GET['num']; //process update $update ="UPDATE User SET Surname='$sname',Telephone='$tel',Number='$num', Postcode='$pcode' WHERE Username='$username'"; //if query, display success if(mysqli_query($update)) { echo"success"; } else { echo"error"; } //else display error </code></pre> <p>The query executes fine, but the values aren't displaying within the database. My other variables (username, password etc) all update fine. All database fields are type VARCHAR(80).</p> <p>EDIT: I do have the query being executed. This still results in the surname, postcode, number and telephone field not being updated.</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.
 

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