ERROR: INSERT command denied to user 'twselect'@'server213-171-218-134.livedns.org.uk' for table 'log'
File: /home/fhlinux134/t/trinitywars.com/user/htdocs/beta/includes/login.inc.php
Line: 76
User: admin
From what the error message is telling me, it should be using the admin user however, the mysql_error() is saying the problem is due to the code using the select user.
Can anyone see where im going wrong here? i've been staring at it for about an hour now and just cant figure it out.
Question
mikeaag
Hey,
Im making a site that has a user login.
To try and make things a bit safer, i have 2 DB users - an admin user that has all privileges and another user that only has select permission.
my script is setup as follows
// Database Connection function connect_to_db($user = "select") { // Create new connection define("HOSTNAME", "***.***.***.***", true); if($user == "admin") { echo "blah<br />"; define("USERNAME","ADMIN USERNAME", true); define("PASSWORD", "****", true); } elseif($user == "select") { define("USERNAME", "twselect", true); define("PASSWORD", "****", true); } else { die("error"); } define("DATABASE", "trinitywars", true); mysql_connect(HOSTNAME, USERNAME, PASSWORD) or die ("<p>There has been a fatal Error! The Monkies will fix this ASAP!</p>"); mysql_select_db(DATABASE) or die ("<p>There has been a fatal Error! The Monkies will fix this ASAP!</p>"); } //Run Query function run_query($query, $file = __FILE__, $line = __LINE__, $user = 'select', $log = 0) { // Open Connection connect_to_db($user); // Run query $run = mysql_query($query) or die(output_db_error(mysql_error(), $query, $file, $line, $user, $log)); // Add to query count //$_SESSION['queries'] = $_SESSION['queries'] + 1; return $run; }The code im getting problems with is as follows
and i get this error message
From what the error message is telling me, it should be using the admin user however, the mysql_error() is saying the problem is due to the code using the select user.
Can anyone see where im going wrong here? i've been staring at it for about an hour now and just cant figure it out.
Thanks in advance :D
Link to comment
Share on other sites
6 answers to this question
Recommended Posts