Advertisement

09.19.2008 at 01:25PM PDT, ID: 23747280 | Points: 500
[x]
Attachment Details

Very strange issue connecting to a mysql database.  Works from my test server but not from live..???

Asked by angelleye in PHP Scripting Language

Tags:

I've got a test server here that is using a remote mysql database.  i've got a simple add product form that works on both my test server and the live server this app is hosted on.  so far so good.

There's another script that simply updates a single field in a table and then inserts a new record into another table.  This works perfectly on my test server but NOT on the live server.  For some reason on the live server I'm getting back an error from mysql that there is no database selected.  I'm connecting to the same DB, though, using the same code from both servers.  Why would it work on one and not the other?  

I've attached what I'm working with.  Any information as to why this would be happening would be greatly appreciated.  Thanks!Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
<?php
$hostname_connShower = "domain.com";
$database_connShower = "database_name";
$username_connShower = "username";
$password_connShower = "password";
$connShower = mysql_pconnect($hostname_connShower, $username_connShower, $password_connShower) or trigger_error(mysql_error(),E_USER_ERROR); 
 
$SQL = "UPDATE products SET ClaimedQty = ClaimedQty + 1 WHERE ID = " . $ProductID;
 
mysql_select_db('products', $connShower);
if(!mysql_query($SQL))
{
	$mail -> Subject  =  'Baby Shower MySQL Error Updating Products Table';
	$mail -> Body =  $SQL . '<br /><br />' . mysql_errno() . ' - ' . mysql_error();
	$mail -> AddAddress('andrew@domain.com', 'Andrew Angell');
	$mail -> Send();
	$mail -> ClearAddresses();
}
 
$SQL = "INSERT INTO guests (GuestName, ClaimedProductID, GuestEmail, GuestPhone, GuestStreetAddress1, GuestStreetAddress2, GuestCity, GuestState, GuestZip) 
		VALUES ('" . $GuestName . "', " . $ProductID . ", '" . $GuestEmail . "', '" . $GuestPhone . "', '" . $GuestStreet1 . "', '" . $GuestStreet2 . "', '" . $GuestCity . "', '" . $GuestState . "', '" . $GuestZip . "')";
 
mysql_select_db('guests', $connShower);
if(!mysql_query($SQL))
{
	$mail -> Subject  =  'Baby Shower MySQL Error Updating Products Table';
	$mail -> Body =  $SQL . '<br /><br />' . mysql_errno() . ' - ' . mysql_error();
	$mail -> AddAddress('andrew@domain.com', 'Andrew Angell');
	$mail -> Send();
	$mail -> ClearAddresses();
}
 
?>
[+][-]09.19.2008 at 01:30PM PDT, ID: 22525241

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.19.2008 at 01:33PM PDT, ID: 22525266

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.19.2008 at 03:08PM PDT, ID: 22526040

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628