Hello everyone I am pretty new to php. I am trying to create a back up of my sql database and I want the back up to run on php server at the click of a button. I found some templates the issues I am having and it may be due to the wrong templates are: On most of the templates I don't where I should enter the information that is needed to make it work, for ex( host, dbname) etc another issue is I don't know if that's the only part of the code that needs to be changed. If someone could help me find a backup template and tell me step by step how to get my database to export as a file I would greatly appreciate it!sq
Use exec function to call mysqldump, a backup utility program that's bundled with every MySQL database. Pass the folder you would like the file (it will be a .sql file) to be put, and you can simply download or ftp it from there.
A simpler option is to install PHPMyAdmin and you can use it to backup any database and table.
Hope this helps.
Related
hope someone can help me. I made a unity3d game for webplayer. Now i need to store some data e.g. the time how long someone has played the game in a csv file.
Does anyone know how i can test if my php and javascript for writing to this csv file
in my javascript i habe this line
var postDataURL = "myurl/data.php?";
but i don't have a url til now so i need to test this locally and i don't know what to add for the url i always get this error:
Could not resolve host: C; No data record of requested type
thanks
You will need to set up a web server to run locally. At that point you can target your form submission at http:// localhost/data.php and things will work perfectly. Apache is really easy to set up but you might want to look into something like WAMP (Windows Apache MySql PHP.)
http://www.wampserver.com/en/
First of all in order to access your PHP script to either send or retrieve information You need to use the WWW class with your url.
Next is there a reason that you want to write it to a csv file. If your just trying to store information that is pervasive across all session runs you can write data to player prefs.
PlayerPrefs.SetString("KeyName", Value);
Retrieve the data at any time using
PlayerPrefs.GetString("KeyName")
This is good for keeping high scores and such
Finally to directly answer your question my favorite is installing apache because it sets up in minutes with out havnt to know what your doing
http://httpd.apache.org/
after install find your web root and place the file in there. You can access the file using http://localhost/yourPHPfile.php
Make sure you install php on your machine as well.
Is it possible to back up an access database? I have done research on how to backup access database through php but I wasnt able to get a good answer. Most of the result that came out is about backing up MySQL database. Can anyone help me :) thanks
re: actually performing the backup
Backing up a native Access database is simply a matter of copying the entire database file (.mdb for Access_2003 and earlier, .accdb for Access_2007 and later). You could use PHP for that, but any scripting language would work, even a simple Windows batch file that does something like
copy /Y d:\apps\databases\mydatabase.accdb z:\backups\databases\*.*
If you're really set on using PHP then you'll likely end up using the copy() function.
re: automatic scheduling of the backup
The Task Scheduler in Windows could take care of that for you. Once you've created your script to copy the database file(s) you can create a scheduled task to run it periodically. See the MSDN article Using the Task Scheduler (Windows) for more information.
I have a bunch of php pages that run on local host. Its basically a web dashboard for different web apps. I have a config.php file that has all my variables in it. They are mainly urls, password and usernames.. Now I want to remove the config file and replace it with a database. I don't want to set up an entire database though. Is there a way maybe with mysql lite that I can create a datebase file that acts like a database? So if I ever copy all the php files and move them to another computer I can just copy the database file and it will work right away. Is this possible? If yes please explain in detail how I would create, connect, and retrieve variables.
Regards
You want to use SQLite. Check some tutorials and do it how they suggest:
http://souptonuts.sourceforge.net/readme_sqlite_tutorial.html
http://zetcode.com/databases/sqlitetutorial/
http://freshmeat.net/articles/sqlite-tutorial
SQLite will do what you want: http://php.net/manual/en/book.sqlite.php.
The databases are self-contained within a single file. Check their website for more information: http://www.sqlite.org/
SQLite (nothing to do with MySql Lite Administrator) is an SQL database which stores all its data in easily transferable files.
PHP has an extension that supports SQLite.
I accidently deleted the whole database when I should just delete one table in PHPMyAdmin. Is there a way of retrieving the database?
There are two ways:
Have a working backup of the system, and restore the files from it.
An undelete tool might help, if you deleted the db very recently (and ideally, if you unplugged the computer right afterward).
As for doing it with MySQL, though...on all systems i'm aware of, no. MySQL tables are files in the server's data directory, and dropping a table deletes those files. Once they're gone, they're gone, and only the methods above can get them back. A database is a directory of those files, and dropping it deletes the whole directory.
Same thing here :-(
I closed xampp (V3.2.1) found the xampp\mysql\ folder, right-clicked and selected Restore previous version, select recent restore. When this finished I opened xampp and the missing database was back with the information dated as per the restore date. Not ideal but better than no database :-)
Same thing happened with me, found a easy solution. First make a command line access to the database using the mysql.exe file present in xampp/php/bin folder. Delete the phpmyadmin database. Then, just import the create_tables.sql file to the phpmyadmin database. This solved my problem.
Let me know if you face any problem using this.
thanks.
You can retrieve a accidentally deleted database via a file restoration software. Check this free software
http://www.majorgeeks.com/Restoration_d4474.html
More information here -
http://emaillenin.blogspot.com/2010/11/recover-accidentally-deleted-mysql.html
I've been working on a website on my own xampp server on my computer with my own database and everything and so far it's been pretty smooth, surprisingly. Now I want to upload it to a host, and I found a free web host and I was able to upload the site through dreamweaver/ftp. I exported my DB into an SQL query and than ran that query on the live DB so that they would have the same data.
I'm curious, what's the best way to keep these DB's in sync?
1) In my header.php, I specify some connection variables for my local db and I have to make sure to change them when I upload header.php to the site so they have the correct connection variables for the remote db. Maybe if I had a file on my hosting server and a file on my local server that specified the connection information and just never messed with them?
2) If I change something in my local DB, I have to copy the SQL and run it in my remote one as well. Is there a good way to handle this?
Thanks again!
http://www.databasejournal.com/features/mysql/article.php/3355201/Database-Replication-in-MySQL.htm
For #1, you can either do that--the route most people take--or make the config file check the IP before loading server specific configuration. If the IP is 127.0.0.1, you load your development configuration. If it is the IP of the host, it loads a different config.
I personally do not know of a better way to handle #2. So, this answer will have to be incomplete.
1: Yes, create a config.php file with the server-specific information and include it when you need it. This is incredibly common and normal. Ideally, you can keep this file a little separate from your other files so that it's easy to grab all of your application files and copy them to the live server without also copying the config file. Keep a backup of your live config file somewhere, because one day you will overwrite it, and it's much better for your heart if you don't have to scramble to figure out what the live database password was.
2: There are some automated ways of handling this, but they're very complicated. What I usually do is create an empty text file named changes.sql or something. As I make changes to the dev database, I paste the CREATE TABLE and ALTER TABLE, etc. queries into the changes.sql file. This way I have one file with all the changes I need to make to the live server when I'm ready to update the live site. After I do the update, I save the changes.sql file somewhere and create a new empty file for the next changes.
More 2: You can also just do a dump of the whole dev database and copy it live. Most sites, though, have data on the live server that should not be destroyed or copied to dev - user information, orders, login tracking, user comments, whatever. So you generally do no not want to just replace all your live data with dev data.
I usually keep the template stuff separate from the db connection, global variable stuff, and session stuff with an include file like 'init.php' or 'config.php'. When you update your stuff, most likely you won't need to overwrite that file.
I use linux, so I use 'mysqldump' to get a .sql file, upload to server, then just upload 'mysql -u user -p databasename < database.sql'. It would be great if there was a quicker way that I don't know of.