2011-05-19 55 views
0

这是mysql的查询权吗?请注意该用户是日期使用mysql和php存储日期

 sprintf("INSERT INTO userinfo (username,userbdate,national,email, mobilenum,phonenum, 
         street,city,stateof , postoofice,country,lastcirt,cirt,specailzation,exper, 
         yearsofexper,notes) 
         VALUES ('%s', '%d' , '%s' , '%s' , '%d' , '%d' , 
         '%s','%s','%s','%s','%s','%s','%s','%s','%s', 
         '%d','%s')", 
         $user->getUserName(), 
         $user->getgetBirthDate(), 
         $user->getNational(), 
         $user->getEmail(), 
         $user->getMobilenum(), 
         $user->getPhonenum(), 
         $user->getPhonenum(), 
         $user->getStreet(), 
         $user->getCity(), 
         $user->getStateof(), 
         $user->getPostoffice(), 
         $user->getCountry(), 
         $user->getLastcirifacite(), 
         $user->getCirifacite(), 
         $user->getSpecailaztion(), 
         $user->getExper(), 
         $user->getYearsOfexper(), 
         $user->Notes(), 
         $userModel->getUserId()); 
+0

'postoofice'不知道这是故意还是打字错误 – 2011-05-19 18:35:16

回答

0

getgetBirthDate似乎是错误的(两个得到的)。 你会更好地使用参数,并与任何格式问题完成。除此之外,你将不受SQL注入的影响。

1

你为什么不试试看?我们无法猜测你的所有价值。但我现在可以告诉你,如果任何的这些值在它们中有引号,那么你的SQL查询将被打破。查找SQL注入,访问http://bobby-tables.com,并使您的查询风险较小。

+0

毫米,这是一个主题的最终项目,我会尝试在今年夏天阅读它,但现在我已经完成它 顺便说一句,我尝试,但它没有给我什么! – 2011-05-19 18:37:20

+0

然后采取生成的查询,并在mysql监视器中手动运行它。毫无疑问,您会收到错误消息。 'specailzation'看起来可疑。 – 2011-05-19 18:40:11