查询帮助! [英] query help!

查看:70
本文介绍了查询帮助!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我是perl的新手 - 几周前才开始学习它。基本上,我想要做的是注册用户。使用mySQL数据库的脚本。


我设法做了插入查询(见下文)。但我的问题如下:


用户表包含正确的顺序:

- 电子邮件(主键)

- 密码

- 名字

- 姓氏

- 科学家

- 观察员

因此,当脚本运行时,它首先需要检查没有用户已注册使用该电子邮件地址(我知道如果查询存在但查询将不会被执行,但我希望将页面重定向到 login.html"带有GET参数,这样我就可以让用户知道它为什么不起作用了。


我在选择查询时遇到问题......


有人能告诉我使用perl中的fetch方法吗?


另外,如果你能解释一下,我会很感激我能理解我做错了什么。这是我为注册过程工作的原始代码。


谢谢,


olo

展开 | 选择 | Wrap | 行号

解决方案

欢迎来到TSDN olobraecky !!!


这是一些应该有用的评论代码你在正确的方向。语句中的?称为占位符的。当使用占位符时,DBI将转义数据。


未经测试的代码

展开 | 选择 | 换行 | 行号


< blockquote>嗨eWish,


我刚试过你的实现。但我得到相同的问题500内部服务器错误这一直让我疯狂。


我知道我必须验证数据,但我想让检查用户功能先行。


这里是我的文件的确切代码:

展开 | 选择 | Wrap | 行号


发布时代码请使用[code] [/ code]标签。我在帖子中添加了代码标记。请将它们与以后的所有帖子一起使用。谢谢。


用以下内容替换代码的第一部分。

展开 | < span class =codeLinkonclick =selectAll(this);>选择 | Wrap | 行号


Hi all,

I am new to perl - just started to learn it a few weeks ago. Basically, what I am trying to do is a "register user" script using a mySQL database.

I have managed to do the insert query (see below). But my problem is the following:

user table contains in the right order:
- email (primary key)
- password
- first name
- last name
- scientist
- observer

so when the script is run, it first needs to check that no user already registered is using that email address (i know the query will not be done if it exists but i want the page to be redirected to "login.html" with a GET parameter so that I can let the user know why it did not work).

I am having problems getting the select query working...

Could anybody show me a way to do it using the fetch method in perl?

Also, i would appreciate if you could explain so i can understand what I was doing wrong. Here is the original code I have working for the registering process.

Thanks,

olo

Expand|Select|Wrap|Line Numbers

解决方案

Welcome to TSDN olobraecky!!!

Here is some commented code that should help you in the right direction. The ''?'' in the statements are called placeholders. The DBI will escape the data when placeholders are used.

Untested Code

Expand|Select|Wrap|Line Numbers


hi eWish,

I''ve just tried your implementation. But i get the same problem "500 Internal Server Error" which has been driving me mad all day.

I knew that I would have to validate data but i wanted to get the checking users feature to work first.

here is the exact code of my file:

Expand|Select|Wrap|Line Numbers


When posting code please use the [code][/code] tags. I have added the code tags in your posts. Please use this them with all future posts. Thank You.

Replace the first part of your code with the following.

Expand|Select|Wrap|Line Numbers


这篇关于查询帮助!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆