how to go from localhost to live database

flash/php/mysql problem connecting to live database

Page 1 of 1

7 Replies - 7493 Views - Last Post: 18 March 2010 - 06:38 AM

#1 Guest_copenhagen*


Reputation:

how to go from localhost to live database

Posted 14 March 2010 - 01:36 PM

Hi

I have a problem which are killing me, cause the solution should be so simple but I can`t seem to find it.

My problem is that I have done my database locally and everything works perfectly. However now I want to make it work live, but how in the world do I do that? mysql comes with the webhosting i got, so I exported my local database(which by the way ofcourse is mysql too) to the live server database with success, however I have some code in my flash and in my php, which I suspect mess everything up from working.
This is the flash code:
loginDets.sendAndLoad("http://localhost/phpflash/ch09/process_login.php?ck="+new Date().getTime(), loginResponse);



Obviously the path are incorrect when I try to connect to a live server, but if I change 'localhost' to 'myDomainname' and provide the path to the uploaded file called 'process_login.php', then I get the same result as if I used the code above.

My php script look like this with the right values on the respective places:
$db = new Database('Host','user','password','databaseName');



but I still get the same result. Which are access denied.

Anybody who can tell me what I do wrong?

Is This A Good Question/Topic? 0

Replies To: how to go from localhost to live database

#2 Chopster   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 134
  • Joined: 29-March 08

Re: how to go from localhost to live database

Posted 15 March 2010 - 06:40 AM

Hi Guest_copenhagen,

It would seem asthough your logic is correct, i too used to build the database locally and then port it online. But, i always found something would not work quite the same. Back in my uni days when i created a rather large website using php and mysql i set this locally, and come demostration day i ported it live and too my horror many of the functions such as redirects, sessions, cookies etc... would just not work (atleast correctly) whereas the same functions worked perfectly on my test system at home (local).

I am not sure if webhosts allow certain scripts or commands to run (maybe as i was using a cheap webhost with a free monthly bill)

I have no real solution, but to comment out the lines of code you think are causing the problems. Once you have found these issue then you can be sure its say the flash link, then you can dedicate your time to it.

As i mentioned before, your logic in changing the path to a correct path seems good, thats all i ever used to do. But there are many steps that could go wrong. I know this will sound demeaning, i don't mean it to be, but double check that the connection propeties are correct throughout the site, and the folder structures are exactly the same as localhost.

Sorry i couldn't be anymore help than the obvious,

If you post more i will do my best.

(I do all my scripts and sites online these days, just dar easier setting up a test environment online!)
Was This Post Helpful? 0
  • +
  • -

#3 Guest_copenhagen*


Reputation:

Re: how to go from localhost to live database

Posted 15 March 2010 - 11:25 AM

Thanks for your reply chopster and I could imagine it must have been a nightmare! I wished I had learned by your mistake before I started making my site, but well atleast I learned now.
I tried to locate the error and I think it could be two places based on this:
When I run the flash movie with f12 (in a browser) it works and when I run the file as a swf it works. However when I want to run it from my domain live, it doesn`t work???

This is the code I use within flash to get in contact with my php script which are located on the live server:
loginDets.sendAndLoad("http://www.myDomain.com/process_login.php?ck="+new Date().getTime(), loginResponse);



the script process_login is in a map called public_html, but eventhough I include this too, it doesn`t help.

The php code is still:
$db = new Database('mysql7.unoeuro.com','myDomain_com','password','myDomain_com_db');




where 'mysql7.unoeuro.com' is the host name.

'myDomain_com' is the username

password is the password

and 'myDomain_com_db' is the database

I really don`t see any other places where it can be wrong!
Was This Post Helpful? 0

#4 Guest_copenhagen*


Reputation:

Re: how to go from localhost to live database

Posted 16 March 2010 - 09:26 AM

Okay the weirdest thing happen.
When I see my movie using f12, then I can register a new user and see the record on my live mysql database, but when I try to log in, then it tells me it can`t find the record???????
Was This Post Helpful? 0

#5 Guest_copenhagen*


Reputation:

Re: how to go from localhost to live database

Posted 16 March 2010 - 09:47 AM

I forgot to menchen that if I log inn with a user which were registered before I took the database online, then I can log inn, I just can`t log inn with users which are registered after I took the databse live???how weird is that???
Was This Post Helpful? 0

#6 Paul-   User is offline

  • D.I.C Regular
  • member icon

Reputation: 61
  • View blog
  • Posts: 260
  • Joined: 11-December 09

Re: how to go from localhost to live database

Posted 16 March 2010 - 11:49 AM

View Postcopenhagen, on 16 March 2010 - 08:47 AM, said:

I forgot to menchen that if I log inn with a user which were registered before I took the database online, then I can log inn, I just can`t log inn with users which are registered after I took the databse live???how weird is that???


This can happen if the new and old users are created with different host login privileges. You can check this as follows:
mysql> select host, user, password from mysql.user;
+-----------+-----------+-------------------------------------------+
| host      | user      | password                                  |
+-----------+-----------+-------------------------------------------+
| localhost | root      | *839A06041F00092D99313C48B5D093E46287B2B5 |
| %         | socuser   | *21A44C0F2CD7098930850BB232B0DDBFFE9AD716 |
| %         | socadmin  | *E2351830732972C6A9D18A2C3817CFAD19446297 |


In this example users "socuser" and "socadmin" can log in from any host, while user "root" can log in only locally.

This post has been edited by Paul-: 16 March 2010 - 11:51 AM

Was This Post Helpful? 0
  • +
  • -

#7 Guest_copenhagen*


Reputation:

Re: how to go from localhost to live database

Posted 17 March 2010 - 11:45 AM

Thanks for the replies! I checked the possiblity and some more things, and found out that it give me this error message when I try to write the url to the file in the browser:
Warning: require_once() [function.require-once]: Unable to access ../classes/database.php in /var/www/mydomain.com/public_html/register_cms.php on line 7

Warning: require_once(../classes/database.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/mydomain.com/public_html/register_cms.php on line 7

Fatal error: require_once() [function.require]: Failed opening required '../classes/database.php' (include_path='.:/usr/local/lib/php') in /var/www/mydomain.com/public_html/register_cms.php on line 7



does this happen cause ../classes/database.php is the relative path on the local computer, while database.php have a different url on the server????
Was This Post Helpful? 0

#8 Paul-   User is offline

  • D.I.C Regular
  • member icon

Reputation: 61
  • View blog
  • Posts: 260
  • Joined: 11-December 09

Re: how to go from localhost to live database

Posted 18 March 2010 - 06:38 AM

View Postcopenhagen, on 17 March 2010 - 10:45 AM, said:

does this happen cause ../classes/database.php is the relative path on the local computer, while database.php have a different url on the server????


It is a possibility. If you use relative file paths throughout your code, and preserve the directory structure when you move the files to the server, then all the files should be found correctly.

Another possibility is that ../classes/database.php does not have read permissions for the user under which the web application runs. This user is likely different from your login user name. Check that all your files are readable, and directories are readable and executable by all users.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1