PDA

View Full Version : INSERT - works on my server but not my domain :-(


Taylor_1978
01-21-2005, 11:48 PM
Hiya,

This is a snippet of code I have on my site:


$db[name] = "league";
mysql_db_query($db[name], "INSERT INTO orders VALUES ('','$ver','$first_name','$address','$city','$state','$postcode','$country','$phone','$email','$doma in1','$ext1','$domain2','$ext2','$domain3','$ext3','$domain4','$ext4','$domain5','$ext5','$payment', '0')");


Works fine, and its MySQL 4.0.1-alpha

But when I uploaded my files to my domain, it only works like this:

mysql_db_query($db[name], "INSERT INTO $db[name].orders VALUES ('','$ver','$first_name','$address','$city','$state','$postcode','$country','$phone','$email','$doma in1','$ext1','$domain2','$ext2','$domain3','$ext3','$domain4','$ext4','$domain5','$ext5','$payment', '0')");


For some reason I have to mention the $db[name] twice in the sports I've shown. - its MySQL 4.0.22-standard

I have about 20 pages of database activity - I really do not want to have to go through every single page and find every single connect. Anyone know why this would be occouring or somehow I can fix this?

chump2877
01-22-2005, 04:08 AM
I don't have a clue why it's doing that, but with a simple script editor you can execute a "find, replace all" macro and change:

$db[name] = "league";
mysql_db_query($db[name], "INSERT INTO orders

to

mysql_db_query($db[name], "INSERT INTO $db[name].orders

You could change all the instances on all 20 of your pages in about 5-10 minutes, probably.

Maybe you already thought of this, but I thought I'd throw it out there... :cool:

raf
01-22-2005, 12:45 PM
you should put your connectionstring (including the mysql_select_db() inside a seperate file that you then include in each page that requires a db-connection).

so if you need to change your code, you might as well fix it proberly...

Kurashu
01-22-2005, 04:14 PM
$db['name']

That will also help, otherwise PHP will translate your variable contents into an interger, unless you have name defined as a constant.