So I am new to developing scripts for people, and I have starting something that I'm doing for free just so I can begin to learn more about php. My script that I'm working on deals a fair amount with a mysql database, so I obviously set up the mysql db and all of my queries in my php accordingly. My question is: When I am done programming the script, how do I deal with the client and their database integration. For example, I have a table named "table_name" with fields "1" "2" and "3", and my queries rely on this table and these fields. Would the client have to set up the mysql database to match what I have done, or is there a simple way to copy the database to their server for them? Thanks in advance!
I would export the database in a sql file and include it with the script, then your client can import that sql file. That way all the tables will match
Well, you can create a setup file that just "imports" your MySQL dump. Once the user submitted their database's host/user/pass, you can check whether you can connect. If everything is correct, you can open your dump file (fopen, fread), explode by newlines, remove comments and make an array of queries. Now you can create tables and fill them with your data using mysql_query. It's better to go this way if your script's users are non tech savvy
We have reviewed you query and understand that you only need to setup the database at the client server. Please use the below mentioned process for the same. 1) If you are using the PHPmyadmin for your existing database you can use the 'Export' button for the SQL script (don't forget to save the script on your computer) 2) Open hosting server c-panel or control panel and create a new database with new username and password. 3) Click PHPmyadmin link to import the downloaded script to this new database. Note: Please remember to save Hostname, Database name, Username, Password as these will be used for creating connection on client server in your PHP script.