Jump to content

[SOLVED] Php and Mysql


indaleco

Recommended Posts

I have this sniplet here that is not working ...

 

 $login_email = GetSQLValueString($_POST['login_email'], "text");
  $login_pw = md5(GetSQLValueString($_POST['login_pw'], "text"));
  
  
  mysql_select_db($database_oddpawn, $oddpawn);
  $query_login = sprintf("SELECT * FROM `oddpawn_iptoname` WHERE `emailaddy` = $login_email AND `password` = $login_pw ");
  $Result1 = mysql_query($query_login, $oddpawn) or die(mysql_error());
    
  $num_users = mysql_num_rows($Result1);

 

I'm getting this error ...

 

Unknown column '72d5b8ea9d4e8f9af675fa7ef627c13d' in 'where clause'

 

... I don't quite understand how or why ...  I've tried using Single quotes around the variables but it gives me a syntax problem.  I've tried single quotes and brackets as it should be as if it were an array, that failed as well. 

 

Any help is greatly appreciated.

Link to comment
Share on other sites

$query_login = sprintf("SELECT * FROM `oddpawn_iptoname` WHERE `emailaddy` = $login_email AND `password` = $login_pw ");

 

$query_login = "SELECT * FROM `oddpawn_iptoname` WHERE `emailaddy` = $login_email AND `password` = $login_pw ";

Link to comment
Share on other sites

it is becuase your emailaddy and password are strings and they need quotes.

*change password to something else as it is a reserved keyword in mysql

 

my suggestion is to always concatenate ex:

 

"SELECT * FROM oddpawn_iptoname WHERE emailaddy = '". $login_email ."' AND password = '". $login_pw ."'";

 

it makes the code a million times easier to read and you can easily spot your errors

Link to comment
Share on other sites

Ok, but when I tried it with quotes it didn't work...But I will try again.

 

Edit: Tried Emehrkay suggestion ... Following error.

 

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 'storm2804@hotmail.com'' AND password = '72d5b8ea9d4e8f9af675fa7ef627c13d'' at line 1
Link to comment
Share on other sites

add this to your or die

 

die(mysql_error() ."<br />". $query_login);

 

to see the actual query that is being passed

 

and use the one that i posted

 

Adding this, gave me this error...

 

Parse error: syntax error, unexpected T_EXIT in /home/indaleco/public_html/test/intro.php on line 44

 

Further code, all the way down to exit...

 

  $login_email = GetSQLValueString($_POST['login_email'], "text");
  $login_pw = md5(GetSQLValueString($_POST['login_pw'], "text"));
  
  mysql_select_db($database_oddpawn, $oddpawn);
  $query_login = "SELECT * FROM oddpawn_iptoname WHERE emailaddy = '". $login_email ."' AND password = '". $login_pw ."'";

  $Result1 = mysql_query($query_login, $oddpawn) die(mysql_error() ."". $query_login);
  $num_users = mysql_num_rows($Result1);
  
  if ( $num_users !== '1' ) {
    exit('Your email and password were incorrect. Please go back and try again.');
  }

 

Link to comment
Share on other sites

$login_email = $_POST['login_email'];

  $login_pw = md5($_POST['login_pw'];

 

  mysql_select_db($database_oddpawn, $oddpawn);

  $query_login = "SELECT * FROM oddpawn_iptoname WHERE emailaddy = '". $login_email ."' AND password = '". $login_pw ."'";

 

  $Result1 = mysql_query($query_login) die(mysql_error());

  $num_users = mysql_num_rows($Result1);

 

  if ( $num_users != '1' ) {

    exit('Your email and password were incorrect. Please go back and try again.');

  }

 

try this basic first

Link to comment
Share on other sites

sorry, that return is supposed to be a br

 

die(mysql_error() ."<br />". $query_login);

 

try again

 

 

Added this error...

 

Parse error: syntax error, unexpected T_EXIT in /home/indaleco/public_html/test/intro.php on line 43

Link to comment
Share on other sites

Using this code ...

  $login_email = $_POST['login_email'];
  $login_pw = md5($_POST['login_pw']);
  
  mysql_select_db($database_oddpawn, $oddpawn);
  $query_login = "SELECT * FROM oddpawn_iptoname WHERE emailaddy = '". $login_email ."' AND password = '". $login_pw ."'";

  $Result1 = mysql_query($query_login) die(mysql_error());
  $num_users = mysql_num_rows($Result1);
  
  if ( $num_users != '1' ) {
    exit('Your email and password were incorrect. Please go back and try again.');
  }

 

Got this error ...

Parse error: syntax error, unexpected T_EXIT in /home/indaleco/public_html/test/intro.php on line 43
Link to comment
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.