Php is failing on MySQL command without any Error messages!

Hello,

I am having a strangest Php failure, I say failure since it is not even giving me an Error message.

1st some background, we have 2 DB connections, one is $dbcon_anx which is a connection to a MySQL DB on another server.

Here is the code snippet:

			echo 'Hello World 1 <p>';

			if (!isset($dbcon_anx)) {

				echo 'Hello World 3 <p>';
			}

			$sql_chk_dup = "SELECT user_id FROM people_news.users WHERE nick_name = '$nick'";
			$query_chk_dup = mysql_query($sql_chk_dup, $dbcon_anx) or die(mysql_error());

			echo 'Hello World 2 <p>'

			if (mysql_num_rows($query_chk_dup) > 0) {

				echo 'Hello World 3 <p>';

				$error = 'The Username of: <font color="green">' . $nick .  '</font> is already taken. Please enter a different Username.';

			$_SESSION['nick'] = null;

			}
		}

Of course echo ‘Hello World X <p>’ are for debugging purposes.

So
Hello World 1
displays OK.

Hello World 3
does not display indicating that the DB connection is made OK.

So the strange failure is that when this line is executed:
$query_chk_dup = mysql_query($sql_chk_dup, $dbcon_anx) or die(mysql_error());

THEN the Web browser produces NO other Error message and nothing else.
So there is just an empty browser page after this point.

And I also checked the MySQL SELECT:
SELECT user_id FROM people_news.users WHERE nick_name = '$nick
on MySQL and it works just fine.

So what the HEK is going on that all of a sudden Php is failing at that line without any Error messages!

ThanX

You should instead make nick_name unique, enforce that at the database level.

When you try and insert a new row and it fails with the error number 1062, so detect that error and respond accordingly MySQL :: MySQL 5.5 Reference Manual :: C.3 Server Error Codes and Messages

Good advice.

And my guess is that select doesn’t return any rows because $nick doesn’t contain the value you think it contains. Do an echo of $sql_chk_dup and see what it contains.

Hi,

1st, the issue is not as simple as making nick_name unique on the Table.
Because I have 2 users Tables on 2 different servers, and I need to make sure that the nick_name is unique on (the Old legacy) Table, which is the Table on the remote server, before inserting it into the Table in the Local server.

So the problem is that as per above code, when I try checking to make sure that the new nick_name is not already in use in the Remote server before inserting it into the Local server, that the Remote server MySQL code fails and fails without any ERROR messages telling why!

And again when I take the SELECT command and copy & paste it into the Remote server MySQL, it returns result just fine.

So what the HEK?

Hi,

1st thanks for your suggestion/idea too.

So I do not get any ERROR messages back from PhP.
Once it hits that line where the SELECT is from the Remote server MySQL, then nothing happens! The web page is then completely blank after that point! No ERROR messages, such as this error number 1062 mentioned. Nothing! It is just a blank page after that SELECT is from the Remote server MySQL and again the SELECT command works just fine on the Local server or when manually entered into the Remote server.

ThanX.