1st Question:
If you notice, the code is @mysql, not @.
return @mysql($sys_dbname,$qstring);
I understand the error suppression, I'm just not sure what the '@mysql' is. It has to be similar to mysql_query, but I can't find a thing on it. It's kind of hard to search on that term, because I get a lot of general mySQL information.
2nd Problem:
Let me post some more code, and hopefully it will become clear what problem I'm having.
Let me re-iterate the issue I'm having. I get a mysql_connect error, but the query is processed anyway. I need a way to find out what user is being used to connect to the database to complete the query.
On to the code...
I've got a page that has only a textarea & a submit button. This is where the sql will be entered. The submit takes it to a php page that connects to the database, & processes the query.
The first function is the connect function. It takes the host, user, & password & connects to the database. Nothing too out of the norm there.
The second function actually processes the query, in this case, "SELECT * from tablename".
$sys_dbhost = 'localhost';
$sys_dbname = 'db_name';
$sys_dbuser = 'db_user';
$sys_dbpasswd = 'db_password';
function db_connect() {
global $sys_dbhost,$sys_dbuser,$sys_dbpasswd;
$conn = mysql_connect($sys_dbhost,$sys_dbuser,$sys_dbpasswd);
if (!$conn) {
echo mysql_error();
}
return $conn;
}
function db_query($qstring,$print=0) {
global $sys_dbname;
return @mysql($sys_dbname,$qstring);
}
/* Performing SQL query */
$sql_from_form = $_POST["SQL"];
$query = stripslashes($sql_from_form);
$result = db_query($query);
The password in the php page was input INCORRECTLY. The database connection FAILED. I get an error stating this, however, I also get results from the query. Let me show you the results from the page:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user: 'db_user@localhost' (Using password: YES) in c:\program files\apache group\apache\htdocs\poker\includes\do_query.php on line 30
Access denied for user: 'db_user@localhost' (Using password: YES)
user_id user_name ...
1 jawa ...
The fields user_id, user_name, etc is what is being returned from the select statement.
Hopefully this explains it a bit more. I'm getting a db connect error, but also getting results from my query.
I need to find out what user is being used to complete the query, even though the db_connect is erroring out.
Thanks,
-J