Jump to content

matd

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling
  • Location
    UK

matd's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi cougarhockey, Thanks for the reply. Can you give me an example of how you\'d implement this, but sorting using the cat_code from items and using it to sort by cat_desc in categories. cat_code being the relative field in both items and categories. Heres the structure of the 2 tables :- categories table : cat_code cat_desc autog Autographs co Covers ab Albums test Test Description items table : ID cat_code caption price 13 autog A Smith 4.00 14 autog B Jones 2.00 15 co J Smith 1.00 16 ab Test Album 4.00 I\'d like to sort items by using the cat_code value and using it to sort by the cat_desc field in categories. If you could give me an example that\'d be great
  2. Hi, I have one table called \'items\'. Now i\'m storing a category code for all the different items called \'cat_code\'. I have another table called \'categories\'. one of the fields in this table is \'cat_code\' and the other is \'cat_desc\'. cat_desc is obviously the description which relates to the cat_code :wink: What i\'d like to do is SORT items by cat_desc So somehow how i need to lookup \'cat_desc\' using the \'cat_code\' in the items table and then sort by \'cat_desc\'. Anybody know how to do this? Any help, as always, greatly appreciated
  3. Open up httpd.conf which is under the conf directory of your Apache installation. Look for the following line :- DirectoryIndex index.html index.html.var Simply add your index.php to this line. For example :- DirectoryIndex index.html index.php index.html.var In fact you can add any file here which will make apache use it as an index.page Hope this helps :-)
  4. You wouldnt happen to know how i can terminate output to the header i\'ve set that allows me to save the dump to file would you? I have an index.php which has a button for backup. When backup is clicked it forwards the browser to backup.php where i set the header information for file saving and then echo the file. The only thing is, after the file has been saved i\'d like to put a link on that page to direct them back to another page, but as the header has been set it just gets put in with the file being saved. Is there someway of doing :- header(\'Content-Disposition: attachment; filename=\"\'. $saveas_filename . \'\"\'); header(\'Cache-Control: must-revalidate, post-check=0, pre-check=0\'); header(\'Pragma: public\'); echo $dump_buffer; <terminate output to file> <continue with php and html for page content displayed to browser> Help as always, is very much appreciated
  5. mysqldump --opt -c -hlocalhost -u$user -p$password $database | unix2dos | gzip > \" . $backup_dir . \'/\' . $backup_file By piping to unix2dos before gzip it converts all unix chars to dos / windows ones :-)
  6. i was just using Notepad which i thought would show the bare file and ignore any formatting chars. I\'ll try and look at it in textpad... Still leaves the problem that i can backup and restore a mysql database in windows but can\'t backup a mysql database in Linux and restore it on a Windows platform. Will i need to convert the line endings or somthing?
  7. Whoa! that was quick! :-) Well, heres a sample of the dump :- `nALTER TABLE admin DISABLE KEYS */; -- -- Dumping data for table \'admin\'; -- -- thats the first line of the code, it does seem to be a carriage return problem as when i pasted that line above it appeared as:- `nALTER TABLE admin DISABLE KEYS */; -- -- Dumping data for table \'admin\' -- Wonder why it would be different or changes characters when the same script running locally here works perfectly. Would it be a case of converting some characters after the dump has run then?
  8. Hi, I\'ve written a backup script which saves the output from a mysqldump and then prompts the uers to save the file. I have this working perfectly on my test server which is running apache on windows xp. But on the live server which is linux based the contents of the saved mysqldump are different. I get these characters in the file :- The mysqldump i run here is fine and formatted correctly when i look at it in notepad and i can import it into mysql using phpmyadmin with no problems. But when i look at the version i download from the live server it has in it and the formatting is all over the place and i get errors if i try and import it in phpmyadmin. I\'m sure i have set the correct mime-type and the headers are correct too. Any ideas why? Any help would be grealty appreciated
  9. Hi effigy :-) I don\'t get any errors and the system, exec or passthru don\'t seem to execute any of the commands i try and run... What is the difference between using passthru, exec and system and which of them should be used when trying to do a mysqldump or mysqlhotcopy? By the way, i can do a simple command like system(\'ls\'); and that retuns a dir listing but i just can\'t get a dump or hotcopy to work.. This is the script i am trying to run which will prompt the user to save a gzip backup of the database :- <?php include(\"../../config/config_sql.php\"); $export_filename = \"backup.gz\"; $export_dir = \"/home/matd/public_html/admin/backup\"; $filename = \"$export_dir/$export_filename\"; $passthru_output = system(\"mysqldump --opt -h$server -u$user -p$password $database | gzip >$filename\"); $mime_type = \'application/x-gzip\'; $now = gmdate(\'D, d M Y H:i:s\') . \' GMT\'; // finally send the headers and the file header(\'Content-Type: \' . $mime_type); header(\'Expires: \' . $now); header(\'Content-Disposition: inline; filename=\"\'. $export_filename . \'\"\'); header(\'Cache-Control: must-revalidate, post-check=0, pre-check=0\'); header(\'Pragma: public\'); $dump_buffer = ($filename); echo $dump_buffer; ?> I get prompted to save the right file and file type but its always empty :-(
  10. Hi, I\'m trying to execute a mysqlhotcopy or mysqldump from a php backup script that i\'m trying to put toghether... Rather than complicating things as i\'m struggling with this, i have simplified the one command that i am trying to perform :- <? passthru(\"mysqlhotcopy -u user -p password -s localhost:/var/run/mysqld/mysqld.sock mydatabase /home/matd/public_html/mysite/backup\"); ?> This does nothing at all, so what i\'d like to know is how do i run commands like mysqldump or msqlhotcopy from a php script. I have tried system and exec instead of passthru but none of them work. The user, password and socket are all correctly set in my script as i use those successfully in other scripts for database queries and updates. I just don\'t understand how to run more powerfull queries like those needed to back a mysql database up. Do i need to connect to the database first or does a passthru command just run by itself. Would you expect passthru(\"mysqlhotcopy -u user -p password -s localhost:/var/run/mysqld/mysqld.sock reepower /home/matd/public_html/mysite/backup\"); to do exactly that or have i missed somthing out? Please help, i really need to get a backup working for my site and yes i have seen http://www.phpfreaks.com/script/view/11.php but if i can\'t get any passthru, system or exec commands to run then i\'m stuck.. :roll:
  11. hi phpfreak, I\'m trying out a custom version of that script as i want the user to be prompted to save the file when they click a link rather than display, e-mail or ftp the backup to them.. I\'ve seen some other articles on this so i\'ve tried to tack it all together and this is what i have come up with so far :- <?php include(\"../../config/config_sql.php\"); $export_filename = \"mybackup.gz\"; $export_dir = \"/home/matd/public_html/backup\"; $filename = \"$export_dir/$export_filename\"; $dump_buffer = ($filename); passthru(\"mysqldump --opt -h$server -u$user -p$password $database | gzip >$filename\"); $mime_type = \'application/x-gzip\'; $now = gmdate(\'D, d M Y H:i:s\') . \' GMT\'; header(\'Content-Type: \' . $mime_type); header(\'Expires: \' . $now); header(\'Content-Disposition: inline; filename=\"\'. $export_filename . \'\"\'); header(\'Cache-Control: must-revalidate, post-check=0, pre-check=0\'); header(\'Pragma: public\'); echo $dump_buffer; ?> This does prompt me to save the file but the file is always empty so i\'m half way there! ;-) Any ideas why the file would be empty? it seems like the passthru isn\'t working but all the required variables have been set correctly and the export feature using phpmyadmin works on the same machine... Any help greatly appreciated :-)
  12. Hi, I\'d like to provide the administrators for some of the php / mysql websites i\'ve created recently with an option like that found in PhpMyAdmin, whereby they can click \'Backup the Database\' and it will dump the entire database into a gzip file and prompt them where they\'d like to save the file to etc... Does anyone know how this can be done? I know PhpMyAdmin creates the dump in the page tbl_dump.php Does anyone have a small sample of code that does the same thing? I know the answers are in tbl_dump.php somewhere but theres a lot of code there and a lot of shared values etc.... Any help greatly appreciated :-)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.