简体   繁体   English

匹配 mysql (php) 中的 email 地址不起作用 - 来自 paypal ipn

[英]Matching an email address in mysql (php) not working - from paypal ipn

Having a noob day.有一个菜鸟的一天。

For some reason this works:出于某种原因,这有效:

// check for user in db
$result = $connector->query('SELECT username FROM wallart_users 
                             WHERE username ="test@testmail.com");

if (mysql_num_rows($result) == 0) {
  ////// ADD NEW USER

But this doesn't:但这不会:

$payer_email = mysql_real_escape_string($payer_email);
// check for user in db
$result = $connector->query('SELECT username FROM wallart_users 
  WHERE username ='.$payer_email);

if (mysql_num_rows($result) == 0) {
  ////// NEW USER

The first one matches and sends me further down the page.第一个匹配并将我发送到页面下方。
The second one doesn't match (with or without the escape) and tries to create a new user with the same credentials (then fails as the user already exists).第二个不匹配(有或没有转义)并尝试使用相同的凭据创建一个新用户(然后由于用户已经存在而失败)。
The email address PayPal is sending is always the same, and the database contains the right address. email 地址 PayPal 发送始终相同,并且数据库包含正确的地址。
I have written both addresses to a log file during the process and they look identical.在此过程中,我已将两个地址写入日志文件,它们看起来相同。

'SELECT username FROM wallart_users WHERE username ="'.$payer_email.'"';

This code这段代码

$result = $connector->query('SELECT username FROM wallart_users 
WHERE username ='.$payer_email);

Should be应该

$result = $connector->query("SELECT username FROM wallart_users 
WHERE username ='$payer_email' ");

Do you not think that you are doing some thing wrong with your second query?你不认为你的第二个查询做错了吗? you should change your query like this你应该像这样改变你的查询

$result = $connector->query('SELECT username FROM wallart_users WHERE username ="'.$payer_email.'"');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM