Mysqldump Creates 0 Bytes File!?
i found some simple code for dumping mysql database but whatever i do (change path to mysqldump, change arguments, change functions) it generates 0 bytes file every time! why is this happening? how could i debug my code? Code:
View Complete Forum Thread with Replies
Related Forum Messages:
Mysqldump Creates Empty File
I have the following code running on a Windows PC (it actually needs to work in a Linux environment on live but still developing it). It seems to create the a.sql file but there is nothing in the a.sql file even though there is data in the database....
View Replies !
MySqldump Creates Empty File?
I am Trying to create a one click backup database script so non-geek office staff can do this, but so far I can only output empty files $db_user = "root"; $db_password = ""; $db_database = "or"; $db_server = "localhost"; $backup_path = "C:xampphtdocsopenrealadminackup"; $path_to_mysqldump = "C:xamppmysqlin"; $filename = "backup".date("YmdHis").".sql"; shell_exec ("mysqldump $db_database > $path_to_mysqldump.$filename --user=$db_user --password=$db_password"); I have tried various forms of this syntax with no content output?
View Replies !
Unable To Write A File In A Directory That My PHP Script Creates
I've a problem of being able to create and remove a directory but unable to write a file inside the created directory for some strange reason. I suspect that this problem could be vaguely linked to Safe mode being set to On since my site is using shared server hosting and probably insufficient/incorrect Unix file permission. Below is my test script that helps me narrow down the problem. -------------------------------------------------------------------------------------------- <html> <head> <title>File IO Test</title> </head> <body> <pre> <?php define("TEST_DIR", "./newsletter/2005_11"); define("TEST_FILE", "./newsletter/2005_11/file_io_test.txt"); echo "Make Directory"; if(mkdir(TEST_DIR, 0777)){ echo "<font color="green">OK</font> "; } else{ echo "<font color="red">Fail</font> "; } if(file_exists(TEST_DIR) && is_dir(TEST_DIR)){ echo TEST_DIR . " exists. "; } else{ echo TEST_DIR . " does not exists. "; } echo "<hr> "; // TEST FILE WRITE echo "Write Open File"; $file_handle = fopen(TEST_FILE, "w"); if($file_handle){ echo "OK"; } else{ echo "Fail"; } fwrite($file_handle, "This file is written at " . date("Y/m/d H:i:s") . " "); echo "Write Close File"; if(fclose($file_handle)){ echo "<font color="green">OK</font> "; } else{ echo "<font color="red">Fail</font> "; } echo "--- START FILE DUMP --- "; readfile(TEST_FILE); echo "--- END FILE DUMP --- "; echo "<hr>"; ?> </body> </html> -------------------------------------------------------------------------------------------- This script will report a success with the creation of the directory on my server, but fails to write a file inside the newly created directory. Originally, I only call mkdir without specifying any permission and it doesn't work. Thus I explicitly instruct mkdir to use 0777 to allow all write operation by everybody, in case PHP and Apache try to write files using "nobody" or "www" user account, instead of my shell login user account. Still it doesn't work. The owner of the created directory is called "www". When I login via SSH and check the permission, strangely, the permission is 775 instead, with Write permission for Others disabled, although I told mkdir to use 0777 instead. Is there any workaround, and what am I doing wrong here? Thanks for sharing with me any insight into this problem. I'm not quite sure what exactly is wrong here, whether because of PHP Safe mode, incorrect directory permission, incorrect file permission or the case of different UID or owner.
View Replies !
Distinguish Between A File Of 0 Bytes And FALSE
I want to use file_get_contents, which according to the documentation returns FALSE if it fails. However, it also fails if I read a file of 0 bytes in size. So I tried to use filesize to check first. Same problem, I seem not to be able to distinguish between a filesize of 0 bytes and FALSE. MexIT: http://johnbokma.com/mexit/ personal page: http://johnbokma.com/ Experienced programmer available: http://castleamber.com/ Happy Customers: http://castleamber.com/testimonials.html
View Replies !
Creates A Temporary Folder And A File Within The Folder.
I have a PHP script which creates a temporary folder and a file within the folder. I have a problem when trying to remove the file and folder using my FTP program. The ownership and group are set to NOBODY. I cannot change the permissions on either the file or the folder. I have tried chmod and chgrp and chown but for some reason I cannot change permissions.
View Replies !
Mysqldump...
Can anyone see why this snippet of code isnt dumping the databases using mysqldump ? All the credentials are correct (changed for the purpose of this post). $host = "localhost"; $user = "root"; $pass = "password"; $database = "database"; $dbname = array ("1","2","3","4","5"); $savepath = "c:/inetpub/sqlbackup"; $date = date("mdy-hia"); $link = mysql_connect($host, $user, $pass) or die("Could not connect"); mysql_select_db($database) or die("Could not select database"); for ($i=0;$i<sizeof($dbname);$i++) { $filename = "$savepath/$dbname[$i]-$date.sql"; passthru("c:/mysql/bin/mysqldump --opt -h$host -u$user -p$pass $dbname[$i][color=blue] >$filename");[/color] } mysql_free_result($result); mysql_close($link);
View Replies !
Mysqldump
mysqldump -h localhost --port=3306 -u phillip --password=password students blah | mysql -h localhost --port=3306 -u phillip --password=password -C archives Super simple thing.. I want to copy the students.blah table to the archives database. Whenever I do it, it creates 2 tables, "blah" and "students_archive", which isn't references. This even after "DROP DATABASE archives" it STILL does it! And no data is ever backed up from the original "blah" table (or the "student_archives" table for that matter).
View Replies !
Mysqldump?
Does mysqldump offer any formating options. When I look at the file of a dump it is very hard to read. I would like it to print each record on a new line.
View Replies !
Mysqldump Not Working
My hosting provider claims that this script worked when they ran it manually. They also mentioned that they had to remove some whitespace to get it to work. I cannot see any problem with the script now, but it still does not work when called directly from a browser. The script and the folder it is writing to are chmod'ed to 755: <?php $cmd1 = "/usr/bin/mysqldump -hsome.server.net -uusername -ppassword --all-databases > /home4/sub002/sc11883-LGVN/www/Backups/a.sql"; system($cmd1); echo "Done"; ?>
View Replies !
Backup With Mysqldump
I use Windows XP and Apache. I am trying to backup a database on my local computer with the following php code: $dbname = 'ol' $dbhost = 'localhost' $dbuser = 'root' $dbpass = 'password' $backupFile = $dbname .'-' .date("Y-m-d-H-i-s") . '.sql' $command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname > $backupFile"; if (!system($command, $retval)){die('Backup failed.);} It does produce a file like C:Program Filesxampphtdocs onlinelearningol-2007-06-20-13-31-09.sql, but it is empty. mysqldump.exe is at C:Program Filesxamppmysqlinmysqldump.exe and the script is sitting in the folder C:Program Filesxampphtdocs onlinelearning. When I put a copy of mysqldump.exe in the folder C:Program Filesxampp htdocsonlinelearning I get a black sreen saying 'Enter password:'. When I give the password I get a file like this: -- MySQL dump 10.10 -- -- Host: localhost Database: ol -- ------------------------------------------------------ -- Server version5.0.18 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; ---
View Replies !
Mysqldump Problem
i'm trying to backup my database using: (for example i have database 'test') shell> mysqldump --quick test | gzip > test.contents.gz it gives me an error: You have an error in your SQL syntax; check the manual ... to use near 'mysqldump --quick test | gzip > test.contents.gz'.
View Replies !
Mysqldump Syntax
I was wondering what I miss out below in mysqldump syntax mysql> mysqldump -u root -p dbaseName >file.sql; or mysql> mysqldump -u root dbaseName >file.sql; I connect as "root" and tehre is no password. In both cases I get errors.
View Replies !
Mysqldump From Php Script
I am trying to write a php script that will backup all my databases. However, this isn't working: <?php $host = 'myhost' $user = 'myuser' $pass = 'mypassword' $backupDir = "/home/user/www/mysqlbackups"; $backupFileName = "backup.sql"; $back = $backupDir.$backupFileName; system(sprintf("mysqldump --all-databases -h %s -u %s -p%s > %s",$host,$user,$pass,$back)); ?> I have also tried adding "or die (mysql_error());" to the end of the command, but I do not get any error message from this. However, if I try to echo something after the die statement, then it does echo. so I don't know what that means.
View Replies !
Load A Mysqldump
I have a mysql dump with table creates and data inserts all in a giant text file. What I want to do is to put all those tables into a specified database using PHP. My questions is what is the best way to this? mysql_query() can only do one command at a time.
View Replies !
Mysqldump Function
Does anyone know what is the simplest way to backup a database using the mysqldump function in php? I have googled a lot and the codes i have found are very hard to understand and most of them does not work.
View Replies !
Mysqldump Backup/restore
I have been trying to get a backup/restore Script working for some time but have had little luck. Is it possible that i can: 1) Have a script that will backup my database and structure to a file, i.e: backup_current_date_and time.sql 2) Make a PHP script that will let me view all the sql files in a directory on my webserver and restore the one i select?
View Replies !
Mysqldump Script Not Working
This script is not working to backup all the databases on my server: PHP Code: <?php $dbhost = 'localhost' $dbuser = 'myuser' $dbpass = 'mypass' $backupdir = '/home/user/www/mysqlbackups/' $command = "mysqldump --opt -h$dbhost -u$dbuser -p$dbpass --all-databases > $backupdir"; system($command) or die('could not backup'); ?> I have searched through countless examples of mysqldump scripts, yet I cannot see why my script isn't working. The only output that I get is "could not backup". Does anyone know if I have to specify a name for the dump file? If so, where in the script? Also, does my path to the backup directory seem ok? Do I need the forward slashes both at the beginning and end of the string? I think that this script should save the dump file on the server, in the directory specified by $backupdir. And I should be able to see the file online. Finally, is there anything extra that I would need to include in the script, since I am saving the dump file in a password protected directory?
View Replies !
Getting Separate Inserts In Mysqldump
I just moved an application to a client's in-house X-Serve, and now when I run mysqldump it delivers all the inserts for a table in a single string - i.e. insert into 'table' values (values), (more values), (more values) instead of separately: insert into 'table' values (values) insert into 'table' values (more values) insert into 'table' values (more values) I realize I don't have --opt enabled in the dump (which I usually do by default, but the previous host didn't support it). --opt includes something called "extended inserts", but from reading the manual, extended inserts is what I'm getting now (all run into a string). I also read these are "on" by default in more recent builds of mysql. what should I do to split the inserts into separate lines? If I don't, the results from some of the tables are so big they overload phpMyAdmin when doing a restore in those cases I split my uploads into multiple passes.
View Replies !
Mysqldump - Is This Correct Method?
I've been trying to get a mysqldump command to work but it just creates an empty file. $dbhost = "xxx"; $dbuser = "xxx"; $dbpass = "xxx"; $dbname = "xxx"; $backupFile = $dbname . date("Y-m-d") . '.gz' $command = "mysqldump --opt -h $dbhost -u $dbuser -p$dbpass $dbname | gzip > $backupFile"; can anyone see a reason why this doesn't work? or is there a better way of writing it?
View Replies !
My Insert Creates
I cannot figure how to fix it. That snippet should be used to grab an ID which it does fine Then insert that ID in a col named "member_web_address" As mentioned it does get the ID and insert it But not on the row where from the ID was taken . It does insert it on a new row created by the insert action Which due to the auto increment creates a new ID etc... How can I keep the original row and pass its ID # to the "member_web_address" col in the very same row <? $query = "select id from templates where username= '$username' and page= '$page' "; $result= mysql_query ($query); while($query_data=mysql_fetch_array($result)) { $member_web_address=($query_data["id"]); } $query = "select id from templates where username= '$username' and page= '$page' "; $result= mysql_query("insert INTO phplates (member_web_address) values ('$member_web_address')"); ?>
View Replies !
Creates The Session
i have a field in a database called Password. It is based on 'password' that a query on the rest of the database is run. The query uses sesions. I attempt to login to thru a login page with my 'email' and 'password'. This is the page which checks that the login details are correct and it creates the session Code:
View Replies !
Database Backup Using Exec & Mysqldump
Im trying to get a database backup using ... <?php exec("mysqldump -ulogin -ppassword database > file.sql"); ?> but the resulting file file.sql is written but is empty can anyone suggest where im going wrong.
View Replies !
Dynamically Creates Varibles
i have this script for that uses 7 pulldowns for the time of an event each day of the week that gets inserted in to a db. Instead of writing the script 7 times for taking the data from the pulldowns, creating a time based on the hour, minute and AM/PM -can i create something that dynamically creates varibles. Basically takes something like $hour1, $minute1 and automatically creates $hour2, $minute2 and so on. This is kinda difficult to explain, heres a snippit of code which i want to duplicate.
View Replies !
Fopen Creates Files?
According to the PHP documentation fopen will create a file that it is directed to open with write access if it doesn't exist... It may be my current host, or I may be doing it wrong, but it doesn't work. Code:
View Replies !
CURL Creates New Session
I currently have a curl session that can access hundreds of different pages on a site. One thing I noticed with it is that it is initiating a new session of the server that is accessing. I don't want it to create a million sessions, just use the one it currently has. I am going to guess that if curl_close($ch) is called, then it is is reinitiated curl_init, it restarts the session correct.
View Replies !
Cron Job Creates Php Files
I have a cron job that is running on my server. Its set to run every half hour. It works great, but it has an annoying little quirk. Everytime the cron job is run, it creates a php file in the root directory of my server. Since its running every 1/2 hour, I get a bucnh of files on my root directory and I have to manually delete them everyday. I've posted the code for my cron job below.
View Replies !
Mysqldump :: Under IIS 5.1 With Php 5 And Mysql Latest Stable Release
I'm trying this script under IIS 5.1 with php 5 and mysql latest stable release : <?php ob_start(); exec("mysqldump -u root -password=123456 mydatabase "); //if i use system() instead of exec() it will warining me Unable to Fork??? (seems it doesn't find the program) //so i tryed to update environment Variable PATH with Mysldump location //but nothing changed $dump = ob_get_contents(); echo $dump; ob_end_clean(); //The database dump now exists in the $dump variable... write it to a file using... $fp = fopen("dump.sql", "w"); fputs($fp, $dump); fclose($fp); ?> it seems correct but in dump.sql i find a an empty file....
View Replies !
Looking For Script That Creates List Of Referrers
I've been looking for a script that will create a real-time list of 'top referrers', similar to the links to sites you see on the left of the page at http://www.linkswarm.com. They also have a page http://www.linkswarm.com/referrers/referrers.php which shows all referrers. I'm assuming you'd be able to set filters. There is no signup required, you just link to the site and your site appears in the referrers list, but as a webmaster, you wouldn't want to include search engines for example.
View Replies !
Creates A Database On Any Server Via A Web Page.
I have basically an install script that creates a database and all the tables and fields. This works great on the local IIS I have on this machine, but that's because I have 1 password for all databases. THe database cannot be created when I run this on the server that hosts my websites (which is a remote server that I rent space on, it's not in my control). I'm trying to figure out if what I want to do is possible. I want to have a script that creates a database on any server via a web page.
View Replies !
Netscape Creates 2 Files For My Sessions
I am having a problem with Netscape when I try to create session variables on two different pages. Netscape produces two separate session temp files ... one with the Redirect.php session variables... one with the Results.php session variables... both have an unique sessionID. IE works fine (in that it creates one session temp file for all variables). Here is the code I am using: PHP Code:
View Replies !
Script Creates Owner As Apache
I am using a fantastic script called Photofolio from www.billwadman.com/photofolio and everything is awesome with it except that when you call the file "buildthumbnails.php" and it builds your thumbnail folders it creates them with the owner name as "apache" and permissions at 644. The problem here that you may suspect is that I cannot go in and delete those files in any of my FTP programs of DW because I am not the "owner". My hosting company says I will have to manually lodge a ticket each time to have the folders deleted. THis seems like a pain in the arse. could anyone offer any help into this situation? or will this really be the case that they will have to delete the files. The only other option I see is Bill Wadman creating some sort of script that will go in and delete the fies or folder directories for you.
View Replies !
Securing Code That Creates Images
I have a pretty nice php web site, that's also reasonably secure. However, I wrote some php code to create some dynamic images based on database data, but I can't figure out how to secure this script? when I reference the php code via img src="myimage.php", none of my session variables are available for use in the script. So, without my session variables, how am I suppose to ensure that the script is only run by a valid user, rather than just anyone who can blindly type in random parameters to my image creation script?
View Replies !
'exec' Creates Popup Windows
I'm running php under apache (I'm using the uniserv distribution) on Windows XP. Every time I execute an external command using backticks or exec or system, I get a cmd windows that pops up for the 1/4 second the command executes. This would all be fine, except that I'm deploying the server to run locally on the user's box, and needless to say, the popups are annoying. I've search everything I'm clever enough to understand and can't find a way to get the external commands to run in the 'background'. All of the input and output of the commands have been redirected, any shell command causes this behavious, and in all other respects it all seems to work great.
View Replies !
Verify Page Which Creates A Session
I am new to sessions and php and have been playing around with them - and would like to know why this is happening? Firstly I have a login page and it goes to a verify page which creates a session like so:
View Replies !
Creates A Cookie And Redirects It Automatically
i am migrating my ASP code to PHP and I have a problem with redirection i have a code here that creates a cookie and redirects it automatically but the problem is that... on the first event that a user visits the page... the cookie is created but it does not redirect automatically. on the second event that a user visited that page, it redirects the user to another page. Code:
View Replies !
Bytes Tranfered.
At the moment on my site i have an information bar at the bottom which gives information like page load time, number of sql queries, gzip status and load. I was looking at adding onother one ... bytes transfered. How would i go about this? I would like to show people how many bytes worth of information has been transfered to them.
View Replies !
Mcrypt And Key Bytes
I try use mcrypt but I want to use key in bytes, not in string. Encrypt text will be decrypt in Delphi with function where key is 16byte not string. How can I do this.
View Replies !
Bytes To Megabytes
I have a field in my table that is the file size in bytes. For example size is 59,059,812 bytes and is entered into my table as just 59059812 (int(9) unsigned). How can I use PHP to take that number and convert it to megabytes and print the result? I know the file is 56.3 MB .
View Replies !
Bytes Exhausted
i am getting this error: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 40 bytes) in db_fns.php on line 15 here is that section of the code: function db_result_to_array($result) { $res_array = array(); for ($count=0; $row = $result->fetch_assoc(); $count++) $res_array[$count] = $row; return $res_array; } If it didn't count it would it fix my problem? How could I fix this?
View Replies !
Creates Some Session Variables After Validating The User
I'm new to PHP... I wrote a php script for login page, which creates some session variables after validating the user... But it's not working... When i compile it... The compiler is giving me the following Warnings... ---------------------------------------------------------------------------------- PHP Warning: session_start(): open(/var/lib/php/session/sess_f207f20079897ad6f830fc632fa5e0c0, O_RDWR) failed: Permission denied (13) PHP Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/gana/public_html/login.php:4) PHP Warning: session_start(): Cannot send session cache limiter - headers already sent PHP Warning: Unknown(): open(/var/lib/php/session/sess_f207f20079897ad6f830fc632fa5e0c0, O_RDWR) failed: Permission denied (13) PHP Warning: Unknown(): Failed to write session data (files). (/var/lib/php/session)
View Replies !
|