Well I did as you said:
GRANT SELECT,INSERT on mydatabase.mytable TO username@"hostname where scripts run" IDENTIFIED BY 'password'
then I Flushed privileges;
That is where I entered the information of MY machine(the one that has MySQL). But why am I suppose to give permission to my machine if MySQL is on my machine? I even added the machine that has the PHP script as a user, but it doesn't work.
In the Mysql users database, I can see the username and host that I've entered, but the password is not the same that I have entered. It's all different numbers and letters. Anyway, this must work, because it accepts this line:
$connection=mysql_connect("MyMachine","My_Name","My_Pass") or die('Could not connect to the database server');
But in the next line:
$db = mysql_select_db("userinfo",$connection) or die ("Unable to select database.");
It returns my error message "Unable to select database". But, as I said, when I enter the "root" as username, it works fine. Isn't my machine and "root" the same?
Correct me if I'm wrong, the info in mysql_connect just tells the php script to connect to the MySQL db that is on the machine that I specified right?
I'm sorry for repeating the same stuff, but I want to make sure I explain myself correctly.