Hello All,
First, thanks for all the help I've received so far from StackOverflow. I've learned much.
Once again, I'm posing a rudimentary question that I've searched on, but cannot find the exact answer to. Here or on PHP.net.
It's sort of like what this guy asked, but not exactly: http://stackoverflow.com/questions/288603/mysql-throwing-query-error-yet-finishing-query-just-fine-why
So, I saw my errorlog ballooning up when I checked my site directory and opened to notice that a bunch of errors have been recorded since I wrote this new Admin area. I know something is obviously awry with my scripting for the error to be thrown, but the weird thing is, the script actually runs through and pulls all the data I need without breaking.
The log contains:
PHP Warning: mysql_query() [function.mysql-query]: Access denied for user 'someuser'@'localhost' (using password: NO) in /home/mysite/adminconsole.php on line 15
I don't get that because that very line is where I setup my connection... the exact same way I do it everywhere else on the site with no problem.
After that error, I have these thrown at the same time
[09-Apr-2010 08:44:18] PHP Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/mysite/adminconsole.php on line 15
[09-Apr-2010 08:44:18] PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mysite/adminconsole.php on line 16
From what I read in the other guys thread, the problem is the contents of the query maybe? Maybe my query is malformed?
Thanks so much for any guidance you can provide.
-Rob
ADD: To Dominic
Dominic
session_start();
if (isset($adminusr))
{
mysql_connect("localhost","user","pw") or die(mysql_error());
mysql_select_db("my_db") or die(mysql_error());
}
else {
header("location:admin.php");
}
LINE 14 #SETUP THE QUERIES HERE FROM SESSION INFO
LINE 15 $sql1=mysql_query("SELECT * FROM admins WHERE username='$adminusr'"); ///connecting to the admin DB
LINE 16 $result1=mysql_fetch_array($sql1);
### OLD BAR INFO QUERY
$sql2=mysql_query("SELECT * FROM bars WHERE bar_id='$result1[bar_id]'"); ///connecting to the old bars DB
$result2=mysql_fetch_array($sql2);
###LIQUOR QUERIES
$sql3=mysql_query("SELECT * FROM inv_beer WHERE bar_id='$result1[bar_id]'"); ///connecting to the BEER INVENTORY DB
$beer_results=mysql_fetch_array($sql3);