Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Old 01-21-2005, 11:48 PM   PM User | #1
Taylor_1978
Regular Coder

 
Join Date: Jun 2003
Location: Australia
Posts: 506
Thanks: 6
Thanked 7 Times in 7 Posts
Taylor_1978 is on a distinguished road
INSERT - works on my server but not my domain :-(

Hiya,

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

PHP Code:
$db[name] = "league";
mysql_db_query($db[name], "INSERT INTO orders VALUES ('','$ver','$first_name','$address','$city','$state','$postcode','$country','$phone','$email','$domain1','$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:
PHP Code:
mysql_db_query($db[name], "INSERT INTO $db[name].orders VALUES ('','$ver','$first_name','$address','$city','$state','$postcode','$country','$phone','$email','$domain1','$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?
Taylor_1978 is offline   Reply With Quote
Old 01-22-2005, 04:08 AM   PM User | #2
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 1,890
Thanks: 5
Thanked 22 Times in 18 Posts
chump2877 is on a distinguished road
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:

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

Quote:
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...
__________________
Regards, R.J.

Media Moguls
Cleveland, Ohio Web Site Design and Application Development
chump2877 is offline   Reply With Quote
Old 01-22-2005, 12:45 PM   PM User | #3
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf is on a distinguished road
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...
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Old 01-22-2005, 04:14 PM   PM User | #4
Kurashu
Regular Coder

 
Join Date: Aug 2004
Location: The US of A
Posts: 767
Thanks: 1
Thanked 0 Times in 0 Posts
Kurashu is an unknown quantity at this point
$db['name']

That will also help, otherwise PHP will translate your variable contents into an interger, unless you have name defined as a constant.
Kurashu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:45 PM.

Home - Contact Us - Archives - Link to CF - Resources - Top 

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.