Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP MySQL Column invalid
    text
    copied!<p>I have been trying for the past four days to get this working. It's just a simple logon page, where no sensitive information is stored, but I'm having problems with the PHP.</p> <pre><code>if ($_SERVER['REQUEST_METHOD'] == 'POST') { $uname = $_POST["login"]; $pword = $_POST["pass"]; $uname = htmlspecialchars($uname); $pword = htmlspecialchars($pword); $user_name = "bradf294_access"; $password = "********"; $database = "bradf294_clients"; $server = "localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); print(mysql_errno()); print($db_found); if(isset($db_found)){ print($db_found."Success"); $SQL = "SELECT * FROM basicinfo WHERE ref = $uname AND pass = $pword"; $result = mysql_query($SQL); print("Query made"); print(mysql_errno()); if ($result) { print("result:".$result); } else { print("Incorrect Login Details"); } if ($result &gt; 0) { print("found user"); $errorMessage= "logged on "; session_start(); $_SESSION['login'] = "1"; header ("Location: progressuser.php"); } else { print("Invalid Logon"); } } else { print("Database not found. The Webmaster has been notified. Please try again later"); $subject = "Automated login error" ; $message = "An error occured whilst trying to connect to the MySQL database, to login to the progress checker" ; mail("a-bradfield@bradfieldandbentley.co.uk", $subject, $message); } </code></pre> <p>From the output on the page which I've been using to debug, it appears to be the lines which don't seem to be working, which are giving a 1054 error - "Unknown column '%s' in '%s'"</p> <pre><code>$SQL = "SELECT * FROM basicinfo WHERE ref = $uname AND pass = $pword"; $result = mysql_query($SQL) </code></pre> <p>even though I copied and pasted the <code>$SQL</code> string into phpMyAdmin and it worked perfectly? </p> <p>Is there anything blatantly obvious I'm doing wrong? Go to <a href="http://www.bradfieldandbentley.co.uk/test/progress.php" rel="nofollow">http://www.bradfieldandbentley.co.uk/test/progress.php</a> and enter the details Reference: <code>TST001</code> and pass: <code>dnatbtr121</code> to see the output for yourselves.</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