Mysql Querying Wrong Database

liunx

Guest
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$MYSQLDB = mysql_connect("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error());<br />  mysql_select_db("SLVProspectsTest");<br />  <br />  $inEmail = trim($_POST["EmailAddress"]);<br />  $query = "SELECT EmailAddress, UsrHash, AddressID FROM tblAddresses WHERE EmailAddress = '$inEmail'";<br />  // run the query<br />  $qryResult = mysql_query($query);<br />  $qryNumRows = mysql_num_rows($qryResult);<br />  // Add Auditing information to DB<br />  $query = "INSERT INTO tblWebLogons (EmailAddress,DateLogon,Action) VALUES('$inEmail','$dtStamp','Successful Logon')";<br />  // run the query<br />  $qryResult = mysql_query($query);<br />  mysql_close($MYSQLDB);<!--c2--></div><!--ec2--><br /><br />The situation is that I have two databases on the account:<br />SLVProspectsTest<br />SLVProspects<br /><br />Test being naturally my test data set and the other being the live data. So while I'm typing away today I see that the listed code is SELECTing from SLVProspects and INSERTing into SLVProspectsTest, not a good thing! <br /><br />Key Info: The two databases have the same username and password.<br /><br />Naturally my goal is to have PHP and MySQL use the database in the mysql_select_db() call and only that database. Any help and insight is greatly appreciated.<!--content-->
Never mind, thanks to a handy grouping feature I missed the second record that was making it appear data was coming from the wrong database (when it was actually coming from the correct DB).<!--content-->
Glad you have it sorted out.<!--content-->
 
Back
Top