Note that there are some explanatory texts on larger screens.

plurals
  1. POphp/sql query is returning the wrong response
    text
    copied!<p>ok so i am running a reset password script, its supposed to replace the password with the sha1 hashed version of <code>password01</code> if successful it should return the success message if not then the failed message, but its returning the failure message weather it works or not which it always does! any ideas? i have inserted the code below:</p> <pre><code>&lt;?php session_start(); $host= $_SESSION["dbhost"]; $username= $_SESSION["dbuser"]; $password= $_SESSION["dbpass"]; $db_name= $_SESSION["dbname"]; $tbl_name="users"; // Table name mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $userid = $_POST['id']; $password = 'password01'; $hashpass = sha1($password); //$result = mysql_query("SELECT password FROM $tbl_name WHERE id='$userid'"); $sql=mysql_query("UPDATE $tbl_name SET password='$hashpass' where id='$userid'"); if (mysql_query($sql)) { echo "&lt;ul id='breadcrumbs-one'&gt;"; echo "&lt;li&gt;&lt;a href=''&gt;Users&lt;/a&gt;&lt;/li&gt;"; echo "&lt;li&gt;&lt;a href='' class='current'&gt;Reset&lt;/a&gt;&lt;/li&gt;"; echo "&lt;/ul&gt;"; echo "&lt;div class='tn-box tn-box-color-3 mcenterlow'&gt;"; echo "&lt;p&gt;The Opperation was Sucessful!&lt;br&gt;&lt;a href='?users'&gt;Add Another?&lt;/a&gt;&lt;/p&gt;"; echo "&lt;div class='tn-progress'&gt;&lt;/div&gt;"; echo "&lt;/div&gt;"; } else { echo "&lt;ul id='breadcrumbs-one'&gt;"; echo "&lt;li&gt;&lt;a href=''&gt;Users&lt;/a&gt;&lt;/li&gt;"; echo "&lt;li&gt;&lt;a href='' class='current'&gt;Reset&lt;/a&gt;&lt;/li&gt;"; echo "&lt;/ul&gt;"; echo "&lt;div class='tn-box tn-box-color-1 mcenterlow'&gt;"; echo "&lt;p&gt;The Opperation was Not Sucessful!&lt;br&gt;&lt;a href='?users'&gt;Try Again?&lt;/a&gt;&lt;/p&gt;"; echo "&lt;div class='tn-progress'&gt;&lt;/div&gt;"; echo "&lt;/div&gt;"; } ?&gt; </code></pre>
 

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