Jump to content

Recommended Posts

Hi all i bet this is going to be obvious, but I ran out of ideas.

I have the following script but it's not inserting. I gave the user  database specific insert update and select rights but something is not working.

maybe someone could help me out.

 

$dbc = mysqli_connect('localhost','slave','password','mydatabase')
        or die ('error connecting to mysql server');

//display stuff
$query = "SELECT * FROM mydatabase";
$result = mysqli_query($dbc, $query);

while($row =  mysqli_fetch_array($result))
    {
        echo 'id: '.$row['ID'].
    ' and firstname is: '.$row['firstname'].
    ' and lastname is: '.$row['lastname'].'<br />';
    }
//insert stuff

$query = "INSERT INTO `mydatabase`.`users` (`firstname`, `lastname`) VALUES ('john', 'doe')";
$result = mysqli_query($dbc, $query);


mysqli_close($dbc);

 

-edit ok i think i fixed it, i tried the root user and it worked. gave the slave user more rights. apperently besides database specific i ahve to give the slave user global insert update and select rights too. Can someone confirm that?

Link to comment
https://forums.phpfreaks.com/topic/222995-really-noobie-sql-query-problem/
Share on other sites

hi mikosiko, I usually test my query in phpmyadmin and copy it to php that way i know its a good query :) phpmyadmin uses those backticks.

mydatabase is the name of the database. mysqli_connect('host','user','password','database');

 

Do you maybe if i am right with what i found out that i have to give global insert rights besides database specific?

i attached a print of phpmyadmin to make it more clear.

 

Any help and tips are wlecome btw. It was my first test in working with a slave user with limited rights ::)

 

 

_edit, this is just a noobie script anyays just to test, i would never hard copy the variables that would be inserted ofcourse hehe

 

[attachment deleted by admin]

thanks Zurev,

 

If i hover over Grant in the privelidges menu i get the following title

"Allows adding users and privileges without reloading the privilege tables."

I think i don't want to grant a slave user with that ('grant')right

 

just to make it clear, i am able now to insert stuff ith the slave user, so in that wway the problem is fixed, but in addition i was wondering if it is necesary to grant global rights besides database specific, like i just did. If someone know i would love to hear it.

::) I just wanted to make a stupid user that is only able to insert and select and update without dropping my tables. (not that i will not take extra measurements to prevent that)

Ill put this on solved since the initial problem is fixed but if anyone knows if it is necessary to grant global rights besides database specific, like i just did. I would love to hear. And thanks mikosiko and zurev for you help!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.