Jump to content

Recommended Posts

<?php session_start();

ini_set ("display_errors", "1");
error_reporting(E_ALL);

include 'Functions.php';
include 'Database.php';

$username = Clean($_POST['username']);
$password = Encrypt($_POST['password']);
$token = $_POST['token'];
$POST = count($_POST);
$GET = count($_GET);
$length = strlen($username || $password);

if (!$POST > 3 || $GET > 0) {

print "Submission Error, Too Many Post Values.";

} else {

if ($length > 32) {

print "Submission Error, Post Values Too Long";

} else {

if ($_SESSION['token'] !== $token) {

echo "Invalid submission.";

} else {


if (!isset($username) && !isset($password)) {

print "Error, Please Enter All Field's";

} else {

$sql = "SELECT * FROM `users` WHERE username = '$username' AND password = '$password'";
$results = mysql_query($sql) or die (mysql_error());

if (!mysql_num_rows($results) > 0) {

print "Error, Account Does Not Exist";

} else {

print "HELLO MAYTEE!.";

        }
      }
    }
  }
}
?>

 

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'jamesxg1'' AND password = 'ada9997043dfbe34937130e25489eb203b4f467e'' at line 1

Link to comment
https://forums.phpfreaks.com/topic/161727-solved-mysql-error/
Share on other sites

Echo out $sql and see what the value is.

 

Ok, Doing this.

 

$sql = "SELECT * FROM `users` WHERE username = '$username' AND password = '$password'";

echo "$sql<br>";
$results = mysql_query($sql) or die (mysql_error());

 

Gave me,

 

SELECT * FROM `users` WHERE username = ''jamesxg1'' AND password = 'ada9997043dfbe34937130e25489eb203b4f467e'

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'jamesxg1'' AND password = 'ada9997043dfbe34937130e25489eb203b4f467e'' at line 1

Link to comment
https://forums.phpfreaks.com/topic/161727-solved-mysql-error/#findComment-853316
Share on other sites

Your Clean() function should NOT be doing anything that has to do with sql syntax, such as putting quotes around string data. It should only be cleaning the data. Any sql syntax, such as single quotes around string data, should only be done in the actual query.

Link to comment
https://forums.phpfreaks.com/topic/161727-solved-mysql-error/#findComment-853320
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.