View Full Version : error message
I wrote a script to delete a database using php. I am getting any error message as follows:
headers: /www/e/epilepsybra2/htdocs/phptags.php[Fri Nov 23 16:27:24 2001] [error] [client 216.41.49.44] Premature end of script headers: /www/e/epilepsybra2/htdocs/db_dropdb.php
This is the code:
#!/usr/local/bin/php
<?$drop_db="epilepsybra2":
$connection = @mysql_connect("venus.powweb.com","epilepsybra2","#####") or die(couln't commect.");
$result = @mysql_drop_db($drop_db,$connection) or die (couldn't delete database.");
if ($result) {
$msg = "<P>Database has been deleted!</P>;
}$>
<HTML>
<HEAD>
<tITLE)dROP A mYsql DATABASE </TITLE>
</HEAD>
<BODY>
<? ECH "MSG"; ?>
</BODY>
</HTML>
Can anyone tell me why I am generating this error?
Did you make sure it was all uploaded in ANCII mode and chmoded to 755? Thats what I had to do to get it to work.
I made the change on the chmode to 755 and sure enough it runs but I am receiveing an error concerning parse. I realized that I had a : instead of a ; at the end of the first line but even after fixing it. I still receive the error.
What could it be now?
#!/usr/local/bin/php
<?php
$drop_db = "epilepsybra2";
$connection = @mysql_connect("venus.powweb.com","epilepsybra2","#####") or die("couldn't connect.");
$result = @mysql_drop_db($drop_db,$connection) or die ("couldn't delete database.");
if ($result) {
$msg = "<P>Database has been deleted!</P>";
}
?>
<HTML>
<HEAD>
<TITLE)DROP A MySQL DATABASE </TITLE>
</HEAD>
<BODY>
<? ECHO "MSG"; ?>
</BODY>
</HTML>
Hi, I don't do much php so I don't know if this will help, but I did notice that in the html you have a right parenthesis in title where a right angle bracket should be. I wondered if maybe this was keeping the server from parsing it properly?
~bud
from the land of Perl ;)
That was the problems. Thanks:)
It worked once and now as soon as I hit return at www.epilepsybrainsurgery.com/db_dropdb.php, the message cannot delete database pops up. this is my code.
#!/usr/local/bin/php
<?php
$drop_db = "epilepsybra2";
$connection = @mysql_connect("venus.powweb.com", "epilepsybra2", "#####") or die("couldn't connect.");
$result = @mysql_drop_db($drop_db,$connection) or die(couldn't delete database.");
if ($result) {
$msg = "<P>Database has been deleted!</P>;
}
?>
<HTML>
<HEAD>
<TITLE>DROP A MySQL DATABASE </TITLE>
</HEAD>
<BODY>
<? echo "$msg"; ?>
</BODY>
</HTML>
I need to delete the database because I have to run the installation a second time and it will not permit me to rerun it if the database already exist.
(I am going to do cart wheels when I get this to work.
:)
hotrats
11-25-01, 04:25 AM
I'm gonna give this a shot. I don't use the PowWeb mySQL setup yet since I am unsure if I can translate my knowledge from a Windows install of mySQL running on a Windows install of Apache. So correct me if I'm wrong.
I assume that when PowWeb sets up a mySQL user account for you that in effect IS the database. What you create within that database would be tables. Would you not be trying to delete a table rather than the database itself. After all the database is the account. If the server allows you to delete the account then you have nothing to work in. Perhaps what you want to do is create a delete_table form... or more accurately a drop_table form.
I see where you are coming from but the set up program tries to create a database. The ISP sets it up so that I can create a database. When the install program runs, it discovers that a database already exists so it can not go and creat another. Since it can't creat a database, it aborts. :(. that is why I must delete the database.
hotrats
11-25-01, 05:23 AM
and my assumption is that creation and deletion of databases is set as an admin privilege on the mySQL server at PowWeb ...
This is how I assume they control the mySQL accounts. You pay for setup and they create a database with your username and password. From there (again I assume since I have yet to activate a mySQL account) you create tables within the database. If this is the system which indeed PowWeb administers then deletion of the database would give you admin priviliges. Again I'm not sure of the system here ... I'm just saying that perhaps you are banging your head against a wall since you may not even have the "privilige" to perform a database deletion. After all your error does not show that you can't connect with your database it shows after the connection is made that you can't delete it.
Other than that I can only point out that your code here:
#!/usr/local/bin/php
<?php
$drop_db = "epilepsybra2";
$connection = @mysql_connect("venus.powweb.com", "epilepsybra2", "#####") or die("couldn't connect.");
$result = @mysql_drop_db($drop_db,$connection) or die(couldn't delete database.");
if ($result) {
$msg = "<P>Database has been deleted!</P>;
}
?>
would make more sense if it actually was thus:
#!/usr/local/bin/php
<?php
$drop_db = "DROP DATABASE [IF EXISTS] epilepsybra2";
$connection = mysql_connect("venus.powweb.com", "epilepsybra2", "#####") or die("couldn't connect.");
$result = mysql_query($drop_db,$connection) or die("Couldn't delete database.");
if (!$result) {
echo "<P>Could not delete data base!";
} else {
echo "<P>Data base has been deleted!" ;
}
?>
Again I am a user of a localhost setup but that's the way I would do it. This way you could perhaps trace better where the process drops you off. Just a wild shot.
Beautiful...........................The new worked. No more database! Thanks :)
hotrats
11-25-01, 03:37 PM
Perhaps your joy will be tempered if in fact what you have done is wipe your mySQL account. I am interested in learning the mySQL server structure at PowWeb for future use. I only hope for your sake that by wiping that database you have not destroyed the account. I am unaware of a mySQL structure that allows a database within a database but then I never set up mySQL as a service just a localhost development environment.
I did read in these forums that you could not rename the database account so my thinking led me to the conclusion that the built in PHP functions governing the root database itself were available as admin priviliges only. This would make sense to me in the fact that if one account was compromised then the others would retain a modest amount of security. A natural progression of that thinking would lead me to believe that deletion of the database would also be "admin only". Oh well, as the saying goes "Gone is gone!".
Powwew, allows the user to delete the database and then create a new one without affecting the account.
What would cause a header error as follows:
Warning: Cannot add header information - headers already sent by (output started at /www/e/epilepsybra2/htdocs/forum/functions.php:2) in /www/e/epilepsybra2/htdocs/forum/admin/index.php on line 49
This error seems to crop up repeated.
Thanks in advance
Tom
Again, I'm not very good with php, but from a perl perspective that warning would tell me that more than one file is trying to set a page header.
My guess is that one file is calling the other and they both contain header information. Only the calling file should set a header.
Hope this helps!
~bud
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.