views:

59

answers:

3
+1  A: 

Try

$notes_result = $conn->query($notes_sql) or die(mysqli_error($conn)); 

To get an updated error.

If the echoed SQL works fine you have to guess it's a connection or permissions issue. Are you doing an insert anywhere else?

Edit: So it's a permissions issue, run this:

GRANT INSERT PRIVILEGES ON *.* TO 'ideapale_amquery'@'localhost' 

However, if you don't believe you need to, try this first:

SHOW GRANTS FOR 'ideapale_amquery'@'localhost'
Graphain
This is the updated error I am receiving: INSERT command denied to user 'ideapale_amquery'@'localhost' for table 'notes'
zeckdude
Haha timing or what - I just updated my answer to guess as much.
Graphain
Put simply, you need to grant INSERT permissions to that user. See my updated answer (one moment).
Graphain
So I guess I only have query priveleges on the user I selected, but I selected the admin user who has all priveleges for the whole DB.
zeckdude
I find that strange since I have been using the admin user everywhere on my site as well as here and it has full privileges, including SELECT, INSERT, DELETE, and UPDATE.
zeckdude
See my update, it lets you check the grants.
Graphain
It doesn't really make sense for me to check the privileges on the user 'amquery' since that is not the user I am trying to connect to the DB with. For some reason, it is making me use that user. Please see my update so you can see what I mean.
zeckdude
Try echoing $user before your query. If it is amquery, try echoing type in dbConnect. If it is admin, try replacing your == with ===.
Graphain
I checked the privileges and 'ideapale_amadmin' has SELECT, INSERT, DELETE, and UPDATE and 'ideapale_amquery' has just SELECT. But that is how I want it to be. That is why I chose to use the admin user in this case, but is selecting the query user for some reason
zeckdude
@zeckdude, please read my latest comment where I ask you to echo out at what stage it seelcts amquery.
Graphain
I tried echoing out $user and nothing shows up.
zeckdude
I tried it again and the variable $user is not set for some reason. Also, when I added the additional '=', it didn't change anything.
zeckdude
I figured out the problem. I was adding another dbConnect function call on an included file. Sorry for wasting your time. Thanks for the help!
zeckdude
+1  A: 

You should check and see what the error being returned is.

Change: die(mysqli_error())
To: die(mysqli_error($conn))

Trevor Johns
+2  A: 

You claim to be connecting with the ideapale_amadmin user, but the error message INSERT command denied to user 'ideapale_amquery'@'localhost' for table 'notes' clearly shows that you are not. You are using the wrong MySQLi object (i.e. a connection you created earlier on in the script) or are passing the wrong parameter to dbConnect().

Lee