The table is in the SQL statement. "Select * from table_name" If you
really want my code it's very long. I will paste in the stuff that's
relevant. It's at the bottom.
If it's a PHP matter why does the same code connecting to a 3.23 server work
perfectly fine. This same EXACT code works perfectly with the site that is
on server 2 (i.e. connecting via localhost NOT server to server).
My code:
--------------------------
/* This is the code to connect to the database. $dh: host, $du: user, $dp:
password, $db: database. Adding debug code showed all information that I
wanted to pass was correctly passed. */
if ($config['pconn'] == 1) {
$conn = @mysql_pconnect($dh,$du,$dp);
} else {
$conn = @mysql_connect($dh,$du,$dp);
}
if (!$conn) {
echo "FATAL ERROR: No connection to database.<BR>";
$error = "FATAL ERROR: No connection to database.<BR>\nError: " .
mysql_error() . "\nUsed:\n host: " . $dh . "\n user: " . $dp . "\n pass:
" . $dp;
emailadmin($error);
exit;
} else {
$dbs = @mysql_select_db($db, $conn);
if (!$dbs) {
echo "FATAL ERROR: Could not select database.<BR>";
$error = "FATAL ERROR: Could not select database.<BR>\nError: "
. mysql_error() . "\nUsed:\n host: " . $dh . "\n user: " . $du . "\n
pass: " . $dp;
emailadmin($error);
exit;
} else {
return $conn;
}
}
}
/*function for performing the mysql_query() You will notice the commented
out line there, that is the work-around that I employed to force the
database name for all the tables (my application uses the xno_ prefix for
all tables) I should not have to do that. */
function db_query($query, $dconn = false) {
global $conn, $config;
if (!$conn) { // if connection isn't there, connect to db
$conn = db_connect($config);
}
if (!$dconn) $dconn = $conn; //if $dconn is false (not using a
//different connection) then set it.
//$query = str_replace("xno_",$config["dbname"].".xno_",$query);
$ret = @mysql_query($query, $dconn);
echo db_error(0)."<br>"; //my debug code.
return $ret;
}
On 8/18/03 10:34 AM this was written:
> You have selected my_database as database. What about the table? Put some of
> your code to clarify the problem. It's a PHP matter.
>
> Iulian
> ----- Original Message -----
> From: "Thomas Deliduka" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, August 18, 2003 5:14 PM
> Subject: Server to Server Connection
>
>
>> I have written this to the PHP-DB list and couldn't get any answers. I
> have
>> gone through all the documentation I could find. I have been everywhere
> and
>> cannot find an answer to this problem! Perhaps someone on this list can
>> lend me some insight?!
>>
>> I think, at heart, the problem is with MySQL permissions or some way 4.0
>> handles connections across a network, however I just cannot figure it out.
>>
>> I'm using PHP 4.3.2+MySQL 4.0.14 on server 1
>> Server 1, however, is connecting to Server 2 which has MySQL 4.0.12
>>
>> I have permissions on the 4.0.12 server setup like:
>> user:
>> localhost user1 all main privs are 'N' except for "File_priv"
>> 192.168.1.% user1 all main privs are 'N' except for "File_priv"
>> (internal SAN).
>>
>> db:
>> % user11 my_database all main privs set to "Y" (select,
>> insert,update, delete, create, drop, references, index, alter)
>>
>> If I use the command-line interface from server 1 to server 2 it works
>> perfectly fine.
>>
>> I'm using PHP connection to do code like:
>>
>> $conn = mysql_connect("192.168.1.2","user1","pass");
>> mysql_select_db("my_database",$conn);
>>
>> mysql_select_db returns true.
>>
>> My queries are like:
>> mysql_query($sql,$conn);
>> So I'm using the proper connection.
>>
>> The webpage mysql_error outputs "select command denied to user:
>> '[EMAIL PROTECTED]' for table 'table_name'"
>>
>> For every table. And I wonder what the heck is this for because the select
>> priv is on for that table in the 'db' table.
>>
>> So, what I did was change the 'user' table with select_priv to "Y" which
>> basically make this user a super-user for every table. After doing this I
>> get these errors:
>>
>> Table 'another_database.table_name' doesn't exist.
>>
>> I didn't select another_database as my table! I selected my_database as my
>> table! Why the heck is it selecting the wrong table?!
>>
>> So, I added a ton of bebugging code. I confirmed that just before calling
>> mysql_select_db() I had the right table in the variable. I confirmed I'm
>> only making one database connection, not two. I confirmed that this user
>> has no permissions for another_database with that user/pass. I confirmed
>> the same Reference ID for $conn. Is being used in every case.
>>
>> I know the reason I'm getting the initial "select command denied" error is
>> because it's still selecting another_database for the table and I don't
> have
>> permissions for that unless I add it for super-user like I did.
>>
>> A work around (which will not work once I get this site in production) is
> to
>> do a search/replace on the SQL strings and add "my_database." to every
>> database table. Once the SQL command becomes "select xxx from
>> my_database.table_name" it works fine but this is not what I can do in the
>> end. What the heck could be the problem?! Why doesn't PHP select the
> right
>> table?!
>>
>> This problem happens with persistant or non-persistant connections.
>>
>> Oh, and another site using the same code and the same PHP install (same
>> server1) but connecting to a 3.23.xx database works perfectly fine. Just
> to
>> throw a wrench in the works.
>>
>> I've been through all of the mysql docs can't find a thing. Do you guys
>> know where I'm going wrong?
>>
>> --
>>
>> Thomas Deliduka
>> IT Manager
>> -------------------------
>> Xenocast
>> Street Smart Media Solutions
>> http://www.xenocast.com/
>>
>>
>>
>> --
>> MySQL General Mailing List
>> For list archives: http://lists.mysql.com/mysql
>> To unsubscribe:
> http://lists.mysql.com/[EMAIL PROTECTED]
>
>
--
Thomas Deliduka
IT Manager
-------------------------
Xenocast
Street Smart Media Solutions
http://www.xenocast.com/
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]