DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 20th September 2008
18Googol2's Avatar
18Googol2 18Googol2 is offline
Real Name: whoami
Spam Deminer
 
Join Date: Apr 2008
Location: pwd
Posts: 283
Default Quick question about PHP script

2 hours ago, I absolutely have no idea how to program in PHP. I took a PHP crash course, because I need to back up my website database. The hosting provider doesnt provide any front end application, so I create a PHP script:

Code:
$sqlFile = $dbname . date(".d-m") . '.sql';
$zipFile = $sqlFile . '.zip';

$dumpCommand = "mysqldump -h$host -u$dbuser -p$dbpword $dbname > $sqlFile";

system($dumpCommand);
system("zip $zipFile $sqlFile");
I suspect there is something wrong with the last command (the zip one). Somehow it doesnt want to execute.

Pls shed some light. I have spent more than 1 hour, but havent worked out how to fix it
__________________
The power of plain text? It can control an entire OS
Reply With Quote
  #2   (View Single Post)  
Old 20th September 2008
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

for one thing, you might actually try checking for errors....

You've said nothing about your webhost, so there is nothing that anyone here can assume about the execution environment.


system() returns the last line of output on success, false on error. Also because of being a (server side) web scripting language, it has security that can be set up --- safe mode ! When safe mode is enabled, the command is escaped, killing shell specials (e.g. > becomes \>). Safe mode can also be used to restrict the commands that can be executed by PHP scripts.


If zip is failing, it's quite possible that either:

A.) zip/mysqldump is not installed,
B.) zip/mysqldump is not in your search path (or safe_mode_exec_dir),
C.) You do not have permission to execute the program(s),
D.) the arguments are wrong (e..g you can execute zip, but mysqldump args \> file failed)


I don't know MySQL enough to know what access controls may be placed on a user trying to mysqldump their own data, but if it's possible to restrict that, it could be set that way on your host.


When it comes to learning PHP, if you go to the documentation and read the 'Language Reference' section, you've learned most anything you need to know.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.

Last edited by TerryP; 20th September 2008 at 06:26 PM.
Reply With Quote
  #3   (View Single Post)  
Old 21st September 2008
18Googol2's Avatar
18Googol2 18Googol2 is offline
Real Name: whoami
Spam Deminer
 
Join Date: Apr 2008
Location: pwd
Posts: 283
Default

You are right, Terry. Looks like the zip function is disabled in my hosting server

http://www.w3schools.com/php/php_ref_zip.asp
__________________
The power of plain text? It can control an entire OS
Reply With Quote
Reply

Thread Tools
Display Modes

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick, simple tcsh tips for beginners anomie Guides 9 6th November 2014 03:55 PM
external drive partition question + fdisk question gosha OpenBSD General 15 15th June 2009 02:00 PM
Quick Ant Question disappearedng FreeBSD General 0 27th October 2008 06:20 AM
Networking: CLI quick reference anomie Other BSD and UNIX/UNIX-like 0 2nd October 2008 01:21 AM
quick question about optimizations in /etc/make.conf thevirtuesofxen FreeBSD Installation and Upgrading 7 15th July 2008 10:29 AM


All times are GMT. The time now is 10:39 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick