Re: Server to Server Connection
Thomas Deliduka unknowingly asked us: and then it ran the mysql_select_db which selected the wrong table. Please re-read, re-phrase. I have an uncomfortable feeling when people use the wrong function for the wrong purpose. I'm an idiot, I should have looked for this before. Think to think more. I recoded it to use my DB API that I created and it works perfectly now. I wasted 4 hours on that. I kept saying to myself, It's something simple you're not looking at. and there it was. Perfect. You just let me revise a programmer's usual cries. -- Think to think more, work to work more. __ Meet the guy at http://www.meetRajesh.com/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
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: localhostuser1 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]
Re: Server to Server Connection
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: localhostuser1 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] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Server to Server Connection
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: localhostuser1 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
Re: Server to Server Connection
At 10:14 -0400 8/18/03, Thomas Deliduka wrote: 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?! We can't tell. You don't show any of your queries. Also, you use server is ambiguous fashion. It seems to mean web server in some cases, and MySQL server in other cases. So it's not really clear what your setup is. We might guess correctly, but you're more likely to get a better response if you re-read your message from the point of view of someone who knows nothing of your setup to see if such a person would have an idea of what you're trying to say. Where that is not true, please try to add clarifying details. 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: localhostuser1 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/ -- Paul DuBois, Senior Technical Writer Madison, Wisconsin, USA MySQL AB, www.mysql.com Are you MySQL certified? http://www.mysql.com/certification/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Server to Server Connection
Server = physical machine. Every query, it doesn't matter what query I send, it tries to use the wrong database. I thought I put select * from table_name but perhaps I didn't. I have another message just sent with code and perhaps a little additional information. On 8/18/03 10:48 AM this was written: At 10:14 -0400 8/18/03, Thomas Deliduka wrote: 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?! We can't tell. You don't show any of your queries. Also, you use server is ambiguous fashion. It seems to mean web server in some cases, and MySQL server in other cases. So it's not really clear what your setup is. We might guess correctly, but you're more likely to get a better response if you re-read your message from the point of view of someone who knows nothing of your setup to see if such a person would have an idea of what you're trying to say. Where that is not true, please try to add clarifying details. 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: localhostuser1 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/ -- 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]
Re: Server to Server Connection
Sorry, in an attempt to further clarify my server situation. I have Three actual servers, physical computers they are setup with: s1: Apache 1.3.27, PHP 4.3.2, MySQL 4.0.14 s2: Apache 1.3.27, PHP 4.3.2, MySQL 4.0.12 s3: Apache 1.3.27, PHP 4.3.2, MySQL 3.23.54 (I believe 54 is the step value) Problem with PHP not selecting the right database EXISTS when connecting with a webpage to Mysql Server from s1 to s2 Problem does NOT exist when connecting from webpage to Mysql Server from s2 to s2 OR from s1 to s3. (caps for emphasis, not to show anger or attitude.) On 8/18/03 10:48 AM this was written: At 10:14 -0400 8/18/03, Thomas Deliduka wrote: 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?! We can't tell. You don't show any of your queries. Also, you use server is ambiguous fashion. It seems to mean web server in some cases, and MySQL server in other cases. So it's not really clear what your setup is. We might guess correctly, but you're more likely to get a better response if you re-read your message from the point of view of someone who knows nothing of your setup to see if such a person would have an idea of what you're trying to say. Where that is not true, please try to add clarifying details. 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: localhostuser1 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/ -- 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]
Re: Server to Server Connection
Your PHP code for the server 1 is not the same with the code for the server 2 or the names of the tables from MySQL server 1 are not the same with the value of your PHP queries. Put the first PHP not-working query in the command-line for server 1 and see if it works. Put here the PHP code for the first not-working query. Add, also, the real names of the MySQL tables used in your lines. Iulian - Original Message - From: Thomas Deliduka [EMAIL PROTECTED] To: m a b [EMAIL PROTECTED] Sent: Monday, August 18, 2003 5:47 PM Subject: Re: Server to Server Connection 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; file://if $dconn is false (not using a file://different connection) then set it. file://$query = str_replace(xno_,$config[dbname]..xno_,$query); $ret = @mysql_query($query, $dconn); echo db_error(0).br; file://my debug code. return $ret; } -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Server to Server Connection
Oh, I see now! When you gave the command mysql ... my_database, at the moment of the MySQL shell, you have the database my_database already selected. So all of your queries works fine because you are in the right database. In the PHP or other environment, you need to select the database after connecting and before query.So follow the order: 1. connection with $conn = @mysql_connect($dh,$du,$dp); 2. selecting the database with mysql_select_db(my_database,$conn); 3. performing query $result=db_query($sql); If you get an error in this step, it's not a PHP/Web matter. If all works fine, you can use : mysql_select_db($db,$conn); in place of mysql_select_db(my_database,$conn); If you get an error in the last step, the value of $db is wrong, so check the webpage which sends the value to $db. Iulian -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Server to Server Connection
Right, however, I am following the progression of 1,2,3. My code I pasted here showed that the connection function did the connect and select in the same function and in my debugging I did confirm that $db does equal my_database. I have also manually typed it in and it still doesn't work. It's as if the PHP mysql_select_db function simply doesn't want to select the right table. However it does fine when connecting to the Mysql 3.23 server. On 8/18/03 12:03 PM this was written: Oh, I see now! When you gave the command mysql ... my_database, at the moment of the MySQL shell, you have the database my_database already selected. So all of your queries works fine because you are in the right database. In the PHP or other environment, you need to select the database after connecting and before query.So follow the order: 1. connection with $conn = @mysql_connect($dh,$du,$dp); 2. selecting the database with mysql_select_db(my_database,$conn); 3. performing query $result=db_query($sql); If you get an error in this step, it's not a PHP/Web matter. If all works fine, you can use : mysql_select_db($db,$conn); in place of mysql_select_db(my_database,$conn); If you get an error in the last step, the value of $db is wrong, so check the webpage which sends the value to $db. -- 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]
Re: Server to Server Connection
Thomas Deliduka unknowingly asked us: Right, however, I am following the progression of 1,2,3. My code I pasted here showed that the connection function did the connect and select in the same function and in my debugging I did confirm that $db does equal my_database. I have also manually typed it in and it still doesn't work. It's as if the PHP mysql_select_db function simply doesn't want to select the right table. However it does fine when connecting to the Mysql 3.23 server. Firstly, you will have to re-read your message before you press the send button each time. What you are saying is very unclear to the rest of us. Nextly, your statement: It's as if the PHP mysql_select_db function simply doesn't want to select the right table. Note, that PHP's mysql_select_db DOES NOT select a table. It selects a DB. The first thing to do to your script is this: 1. Strip ALL @ symbols before functions. Its a wreckless havoc. 2. Secondly, do not put blame on PHP's mysql_select_db function as there about 5000 people using that function successfully. 3. Thirdly, _completely) clear up your file, and start fresh, with just necessary lines of code. Remove all unnecessary IF conditions, for the time being. Something like this: ?php $host = your_host; $username = your_username; $pass = your_pass; $database = your_database; $connection = mysql_connect ($host,$username,$pass); $select = mysql_select_db ($database); $result = mysql_query(SELECT * FROM table_name); while ($row = mysql_fetch_array($result)) print_r ($row); if (!$connection || !$select || !$result) echo mysql_error(); ? Run, this beautiful code, and see if you get any output at all. If not, check if spellings are correct. If you do not get any error messages, set the error_reporting value to 'all' using PHP's ini_set() or the error_reporting() function. If you still don't get any errors, and if your query doesn't work, take a coffee break, and come back next day. Still doesn't work, punch your monitor hard, because you need HELP. -- Think to think more, work to work more. __ Meet the guy at http://www.meetRajesh.com/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Server to Server Connection
On 8/18/03 3:18 PM this was written: Firstly, you will have to re-read your message before you press the send button each time. What you are saying is very unclear to the rest of us. Sorry Nextly, your statement: It's as if the PHP mysql_select_db function simply doesn't want to select the right table. Note, that PHP's mysql_select_db DOES NOT select a table. It selects a DB. You're right. I mis-typed and didn't re-read. The first thing to do to your script is this: 1. Strip ALL @ symbols before functions. Its a wreckless havoc. My application works locally when going off of the same machine that the server is working on. The @ symbols are there because the application is an in-production application that has been used for over a year. I make sure my clients (about 6 right now) don't get error messages when they're using the site. Instead, I get e-mails when there are errors trapped. Yes, for debugging it's good to remove them and I did. 2. Secondly, do not put blame on PHP's mysql_select_db function as there about 5000 people using that function successfully. I'm not completely blaming it. However, it is working fine when the database and the web server is on the same server but the SAME EXACT CODE is not working when the web server is another server separate from the database. Mysql_select_db is telling me it's choosing the proper database but in the end the query is run and that database isn't the one chosen. I need to find out why. 3. Thirdly, _completely) clear up your file, and start fresh, with just necessary lines of code. Remove all unnecessary IF conditions, for the time being. Something like this: Thank you for the code, when I did that (which I should have done, you're right) it worked fine. So, now I gotta find out where this is going wrong and why the same code is working in one place but not the other. While my connection function is only run once (due to my debug code I know this) however somewhere the mysql_select_db function is being called again so I just gotta find out where. I won't bother you all again. If anyone wants to know how I fix this when I eventually do, write me personally. Thanks for your help and patience. -- 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]
Re: Server to Server Connection
Thomas Deliduka unknowingly asked us: Thank you for the code, when I did that (which I should have done, you're right) it worked fine. So, now I gotta find out where this is going wrong and why the same code is working in one place but not the other. While my connection function is only run once (due to my debug code I know this) however somewhere the mysql_select_db function is being called again so I just gotta find out where. I won't bother you all again. If anyone wants to know how I fix this when I eventually do, write me personally. Thanks for your help and patience. Ok fine. just as I had expected. As you are using functions to do work for you, it is possible that certain functions are not being made available the required variables. Also KIM that the resources returned by mysql_connect() and mysql_select_db() are by default global. (Unless otherwise configured, or older version). Thus the output from these functions don't need to be returned. I wouldn't mind if you would email me personally with your script file. Usually 4 eyes work better than 2 un-trained eyes. If your script includes other files, it will do some good to send those in too. (Preferably with some compression). -- Think to think more, work to work more. __ Meet the guy at http://www.meetRajesh.com/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]