PHP 中变量保持空白
我正在开发一个脚本,当给定一些信息时,它将创建 Filezilla Server 用户、我的 HTDocs 文件夹中的一个文件夹以及一个 MySQL 用户和数据库。
由于某种原因,即使我已经确定变量拼写正确,变量 $mysqlpass 仍保持空白。
我正在检查用户是否使用empty() 在输入字段中输入。这是正确的,还是我应该使用 isset() ?
这是来源
http://pastebin.com/reTtME9S
这是“blahhh”作为 Apache 文件夹的输出,没有其他内容已填写(除了 MySQL 管理员信息)。您可以在输出中看到 $mysqluser 工作正常,但密码为空。
http://pastebin.com/Mp2jA5iH
I'm developing a script that when given some information, will create Filezilla Server users, a folder in my HTDocs folder, and a MySQL user and database.
For some reason, a the variable $mysqlpass stays blank even though I've made certain that the variable is spelled correctly.
I'm checking to see if the user entered in an Input field using empty(). Is this correct, or should I be using isset()?
This is the source
http://pastebin.com/reTtME9S
This is the output for "blahhh" as the Apache folder, with nothing else filled in (besides the MySQL Admin information).You can see in the output that $mysqluser works fine but the password is blank.
http://pastebin.com/Mp2jA5iH
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在第二个示例中它是空白的,因为您使用的是 elseif - 这意味着在有机会将密码默认为用户名之前满足另一个条件。将所有这些分解为单独的
if
语句,您应该会做得很好。编辑:抱歉,应该更好地阅读 - 重新检查。但无论如何,它们应该是单独的
if
。It's blank in your 2nd example because you're using
elseif
's - meaning that another condition is satisified before it gets a chance to default the password to the username. Break all of those out into individualif
statements and you should be good.Edit: sorry, should have read better - reexamining. But they should be individual
if
s anyway.首先:您确定通过正确的 POST 键“mysqlpass”传递变量吗?以防万一,您不知道,Firefox 的 firebug 插件对此非常有用(只需打开控制台选项卡)。
其次:您可以使用 PHP 的
var_dump($mysqlpass)
来查看变量到底引用了什么。这至少会提供更多信息以供继续。希望这两种方法之一能帮助您进一步解决此问题。
另外,如上所述,您可能希望将第 32 行的 if/else 梯形图转换为一系列 if 语句,以便将它们全部考虑在内(从而解决您的第二个问题和“blahhh”示例)。
First of all: are you sure that you are passing the variable through the correct POST key "mysqlpass". Just in case, you are not aware, the firebug plugin for Firefox is very good for this (just open up the console tab).
Secondly: you can use PHP's
var_dump($mysqlpass)
to see exactly what the variable referencing. This will at least give some more information to go on.Hopefully one of these two methods will help you further troubleshoot this problem.
Also, as stated, you may wish to turn your if/else ladder on line 32 into a series of if statements so they are all accounted for (thus fixing your second problem and "blahhh" example).