Re: Whats wrong with this query?
| From: | Chris Shiflett | Date: | Mon, 10 Nov 2003 17:04:02 +0000 |
| Subject: | Re: Whats wrong with this query? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-169056@lists.php.net to get a copy of this message | ||
--- Dave Carrera <dave@ephgroup.com> wrote:
> $addamysqluser = mysql_query("grant
> select,insert,drop,update,delete,create,index,alter on $_POST[f2] to
> $_POST[f2]@10.0.0.13 IDENTIFIED by $_POST[f3]");
>
> What is wrong with the above php based mysql_query?
I'm not sure about the query itself, but it seems to me your problem is
more about using strings with PHP.
$foo = "grant select,insert,drop,update,delete,create,index,alter on
$_POST[f2] to $_POST[f2]@10.0.0.13 IDENTIFIED by $_POST[f3]";
echo $foo;
Try that, and I think the output will show you the problem. The solution
is to use curly braces around $_POST['f2'], in addition to properly
quoting the key as I just did.
In order to more easily identify problems like this, you can:
1. Store the query in a variable, and use that variable in mysql_query().
This will allow you to echo it to the screen or something during
debugging, so that you can identify anything obvious, such as this.
2. Output mysql_error() if mysql_query() does not return true. This will
show you what MySQL thinks the error is, which is very helpful.
Hope that helps.
Chris
=====
My Blog
http://shiflett.org/
HTTP Developer's Handbook
http://httphandbook.org/
RAMP Training Courses
http://www.nyphp.org/ramp