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
https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/
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
https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283580
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 '[email protected]'' AND password = '72d5b8ea9d4e8f9af675fa7ef627c13d'' at line 1
Link to comment
https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283581
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
https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283593
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
https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283598
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
https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283602
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.