php循环mysql数据,循环,php和mysql数据

Greetings all. I am writing a profile creator script where a user gets

a URL invite in their mail in the form of;

http://domain.com/profile-create.php...d98jadf098asdf

Things are working well except for a small annoyance in which someone

might have a solution to.

In the event that someone accesses profile-create.php without an

access_code the script generates a warning. If there is an access_code

that matches the access code entered in the MySQL database then they

are directed to the profile creation page. My problem is;

If someone accesses profile-create.php with an access_code but it

doesn''t match any entries in the database I would like to generate a

warning.

When I try to do this with an else statement it produces an error for

every access code listed in the database which isn''t the correct one,

so I could end up with a successful profile creation page with a bunch

of errors.

I''ve played with break and pattern matching but no results. Here is

the script below.---------------------------------------------------------------<

$access_code = $_GET[''access_code''];

if ($access_code) {

echo db_connect();

$result = mysql_query(''SELECT random_link FROM invites'');

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {

$random_link_db = $row[0];

if ($random_link_db == $access_code) {

echo profile_creator_page();

}

// Would like to insert an error warning here

}

}

else {

echo "Error!"

}

function profile_creator_page() {

echo "All''s well!";

}

?>

---------------------------------------------------------------<

Any ideas?

Regards,

Luc

解决方案

access_code =

_GET[''access_code''];

if (

access_code) {

echo db_connect();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值