Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP/MySql Update Will Not Work
    text
    copied!<p>i have created 2 pages</p> <pre><code>update.php edit.php </code></pre> <p>we start on edit.php so here is edit.php's script</p> <pre><code>&lt;?php $id = $_SESSION["id"]; $username = $_POST["username"]; $fname = $_POST["fname"]; $password = $_POST["password"]; $email = $_POST["email"]; mysql_connect('mysql13.000webhost.com', 'a2670376_Users', 'Password') or die(mysql_error()); echo "MySQL Connection Established! &lt;br&gt;"; mysql_select_db("a2670376_Pass") or die(mysql_error()); echo "Database Found! &lt;br&gt;"; $query = "UPDATE members SET username = '$username', fname = '$fname', password = '$password' WHERE id = '$id'"; $res = mysql_query($query); if ($res) echo "&lt;p&gt;Record Updated&lt;p&gt;"; else echo "Problem updating record. MySQL Error: " . mysql_error(); ?&gt; &lt;form action="update.php" method="post"&gt; &lt;input type="hidden" name="id" value="&lt;?=$id;?&gt;"&gt; ScreenName:&lt;br&gt; &lt;input type='text' name='username' id='username' maxlength='25' style='width:247px' name="username" value="&lt;?=$username;?&gt;"/&gt;&lt;br&gt; FullName:&lt;br&gt; &lt;input type='text' name='fname' id='fname' maxlength='20' style='width:248px' name="ud_img" value="&lt;?=$fname;?&gt;"/&gt;&lt;br&gt; Email:&lt;br&gt; &lt;input type='text' name='email' id='email' maxlength='50' style='width:250px' name="ud_img" value="&lt;?=$email;?&gt;"/&gt;&lt;br&gt; Password:&lt;br&gt; &lt;input type='text' name='password' id='password' maxlength='25' style='width:251px' value="&lt;?=$password;?&gt;"/&gt;&lt;br&gt; &lt;input type="Submit"&gt; &lt;/form&gt; </code></pre> <p>now here is the update.php page where i am having the MAJOR problem</p> <pre><code>&lt;?php session_start(); mysql_connect('mysql13.000webhost.com', 'a2670376_Users', 'Password') or die(mysql_error()); mysql_select_db("a2670376_Pass") or die(mysql_error()); $id = (int)$_SESSION["id"]; $username = mysql_real_escape_string($_POST["username"]); $fname = mysql_real_escape_string($_POST["fname"]); $email = mysql_real_escape_string($_POST["email"]); $password = mysql_real_escape_string($_POST["password"]); $query="UPDATE members SET username = '$username', fname = '$fname', email = '$email', password = '$password' WHERE id='$id'"; mysql_query($query)or die(mysql_error()); if(mysql_affected_rows()&gt;=1){ echo "&lt;p&gt;($id) Record Updated&lt;p&gt;"; }else{ echo "&lt;p&gt;($id) Not Updated&lt;p&gt;"; } ?&gt; </code></pre> <p>now on edit.php i fill out the form to edit the account "test" while i am logged into it now once the form if filled out i click on |Submit!| button and it takes me to update.php and it returns this</p> <pre><code>(0) Not Updated (0) &lt;= id of user logged in Not Updated &lt;= MySql Error from mysql_query($query)or die(mysql_error()); if(mysql_affected_rows()&gt;=1){ </code></pre> <p>i want it to update the user logged in and if i am not mistaken in this script it says </p> <pre><code> $id = (int)$_SESSION["id"]; </code></pre> <p>witch updates the user with the id of the person who is logged in</p> <p>but it isnt updating its saying that no tables were effected </p> <p>if it helps heres my MySql Database picture just click here <a href="http://i50.tinypic.com/21juqfq.png" rel="nofollow">http://i50.tinypic.com/21juqfq.png</a></p> <p>even with </p> <pre><code>session_start(); </code></pre> <p>it wont work returns the same thinf as before</p>
 

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