Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP - Update and Set aren't updating the database?
    primarykey
    data
    text
    <p><strong>SOLVED</strong></p> <p>I had searched before asking this but found nothing, so I'll write here for anyone in the future. But to fix it all I had to do was make sure the $username was pointing to something, I had declared it in the login.php script but for some reason this wasn't finding it so setting $username=$_SESSION['myusername']; solved the problem.</p> <hr> <p>In short I have a column called "Status" which is text, 140 characters. It's just a test to mess around with php so I can get used to it. Now at first it was updating the database but to null, I realized I hadn't set the post data to $status and after I did it was working, I updated the database twice and then it just stopped working... The page shows no errors but the value is stuck at the same thing it was the last time I changed it (uuu).</p> <p>I have a form:</p> <pre><code> &lt;form action="status-update.php" method="post"&gt; &lt;p&gt; &lt;input name="status" type="text" id="status" value="&lt;?PHP echo $query_row[status]; ?&gt;"&gt; &lt;input type="submit" name="submit" value="Update"&gt; &lt;/p&gt; &lt;/form&gt; </code></pre> <p>Then when the button is pressed it takes you to this script:</p> <pre><code>&lt;?php SESSION_START(); //WAMP Login Details $host = "localhost"; $username="root"; $password=""; $db_name="database"; $tbl_name="members"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("Database doesn't exist."); //Set $status to the post $status=$_POST['status']; //This grabs the data from the form on the settings page and updates $sql="UPDATE $tbl_name SET status='$status' WHERE username='$username'"; $result=mysql_query($sql); //if true then redirect else echo error if($result){ header("location:me.php"); } else { echo "ERROR"; } ?&gt; </code></pre> <p>I tried to make it so it sets the value to null again but I can't even do that anymore which is strange, since I'm a noob I'm at a loss.</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