开发者

posting a value and retrieve it in php

I have two fields in a开发者_运维技巧 form category name and id. The id is an auto increment. After posting the category name, I want that posted category id pass to next page.

I think i am doing some mistake in select statement.

http://pastebin.com/3Tu2Hr6g


Instead of

"SELECT ThirdPartyCategoryID,'".$ThirdPartyCategoryName."' FROM  thirdpartycategorymaster"

you probably want something like this:

"SELECT ThirdPartyCategoryID,ThirdPartyCategoryName FROM  thirdpartycategorymaster WHERE ThirdPartyCategoryName='".$ThirdPartyCategoryName."'"

And before I forget: PLEASE check and escape user input from HTTP requests before you insert it into your queries. The code you posted is extremely vulnerable to SQL injection.


Fetch your last inserted id using mysql_insert_id()

Sample...

$res = mysql_query( "SELECT LAST_INSERT_ID()" );

or

$res - mysql_insert_id(); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜