mysql server is reading wrong database !!

This is a really strange one.

I have been trying for a couple of hours to get a certain script running
and it seems that the msql server is looking at the wrong data base.

This is my script:

<?php ini_set ("display_errors", "1"); error_reporting(E_ALL); /*Database info*/ $username="eaaagt"; $password="password"; $database="gggwnet7y"; $host="localhost"; $fm_email = ""; $fm_name = "Paymaster"; Mysql_close(); $today = date("U"); $connection = mysql_connect($host,$username,$password) or die ("Couldn't connect to server.". mysql_error()); $db = mysql_select_db($database, $connection) or die ("Couldn't select the database.". mysql_error()); $err = "error test $item_name"; $det = "error test detail: $mc_gross"; // Inform admin $to = ""; $contact = "David"; $subject = "1 PRODUCT ERROR: Modus:$modus"; $message_html = "Hi Dave
NO errors. Method: $modus
Database:$database "; require('send_email.php'); // Record the Error $err_str = "INSERT into data (method, req, response) VALUES ('$modus','$err','$det' )"; $result = mysql_query($err_str) or die("could not INSERT data.". mysql_error()); ?>

Now you can see that I actually email myself the database variable
and this is what is emailed:

Hi Dave
NO errors. Method:


OK that is what we expect.

But the error I get from running this script is:

Warning: mysql_close(): no MySQL-Link resource supplied in /home/ew78gt/public_html/sys/ipn_test.php on line 31

could not INSERT data.Table ‘’ doesn’t exist

Now the warning is OK - I put that “close” there just to close any open connection.

Now when I get the mysql_error()); as part of the “die” because it is failing,
Notice that the database is “guru777”

That database is not even used by this server - it is a database used by

The user , password and database that I specify at the top of the script are
for There should be no relationship at all.

So how is it failing to look at the database that I gave it ?
The email proves what $database is set to ( ie gggwnet7y )

Any ideas how this can happen, and more importantly
how I can fix it ?


Well, computers generally do what they’re told – so more than likely, there’s a reference to that database hiding somewhere.

I’d grep through the code to find it – perhaps something like:

find /home/ew78gt/ | xargs grep guru777

And hopefully that’ll help rat out the culprit :wink:

Thanks for restoring my faith in logic !

That command helped me see where
the culprit lay.

That innocent looking email script was set up to run
on the .com server - so it looks up the user and password
and the old database as well just for good measure.

Funny, because the email worked fine, I didn’t think to
look for the problem in there.

Thanks again.