SitePoint Sponsor |
|
User Tag List
Results 1 to 9 of 9
Thread: Guess Whoo!!!!
-
May 4, 2003, 08:53 #1
- Join Date
- Apr 2003
- Location
- United Kingdom
- Posts
- 94
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Guess Whoo!!!!
Firstly, I wanted to thank everyone for their help. It is really nice to know that there are some people out there that can help.
I am getting a wierd error that is saying I do not have access
I am running a script that creates a database. WHen I click on submit after entering the DB name I am getting the following error : -
Forbidden
You don't have permission to access /<br /><b>Notice</b>: Undefined variable: PHP_SELF in <b>D:/defaultWeb1/create_db.php</b> on line <b>13</b><br /> on this server.
--------------------------------------------------------------------------------
Apache/2.0.44 (Win32) Server at localhost Port 80
I am using Apache Server, on Windows XP with version 4.3.1 of PHP.
Any Idea..
Here is the code.
<?php $conn = @mysql_connect("localhost","root","")
or die("Sorry - could not connect to MySQL");
$rs1= @mysql_create_db($new_db);
$rs2= @mysql_list_dbs($conn);
$list= '';
for($row=0; $row < mysql_num_rows($rs2); $row++)
{ $list .= mysql_tablename($rs2, $row)." | "; }
?>
<html><head><title>Creating databases</title></head><body>
<form action="<?php echo($PHP_SELF); ?>" method="post">
Current databases: <?php echo($list); ?> <hr>
Nameinput type="text" name="new_db">
<input type="submit" value="Create database">
</form></body></html>
-
May 4, 2003, 09:02 #2
- Join Date
- Mar 2003
- Location
- Ireland
- Posts
- 134
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Im new but u could try:
<form action="<?=$_SERVER[PHP_SELF] ?>" method="post">
-
May 4, 2003, 11:21 #3
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Do you have the 'priveleges' in mysql to create a new database I wonder ?
If it's a local dev box you should be able to reset the 'priveleges' back to root user, or maybe your logging into mysql as a different user ?
-
May 5, 2003, 09:47 #4
- Join Date
- Apr 2003
- Location
- United Kingdom
- Posts
- 94
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I am logging on with root to MySQL which has access to everything. I can create the db manually in MySQL
-
May 5, 2003, 10:13 #5
- Join Date
- Nov 2001
- Location
- Atlanta, GA, USA
- Posts
- 5,011
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I'm 99% possitive mofu is correct that you need to use $_SERVER['PHP_SELF'] rather than $PHP_SELF.
Change that, and check back in. :-)Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?
-
May 5, 2003, 11:49 #6
- Join Date
- Apr 2003
- Location
- United Kingdom
- Posts
- 94
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ok I have now changed it and now when I press the submit button it does not create the db. Infact it does nothing.. Here is the code.
<?php $conn = @mysql_connect("localhost","root","")
or die("Sorry - could not connect to MySQL");
$rs1= @mysql_create_db($new_db);
$rs2= @mysql_list_dbs($conn);
$list='';
for($row=0; $row < mysql_num_rows($rs2); $row++)
{ $list .= mysql_tablename($rs2, $row)." | "; }
?>
<html><head><title>Creating databases</title></head><body>
<form action="<?php echo ($_SERVER['PHP_SELF']); ?>" method="post">
Current databases: <?php echo($list); ?> <hr>
Nameinput type="text" name="new_db">
<input type="submit" value="Create database">
</form></body></html>
-
May 5, 2003, 12:04 #7
- Join Date
- Jan 2003
- Location
- Calgary, Canada
- Posts
- 2,063
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Do you have register_globals turned on?
Who walks the stairs without a care
It shoots so high in the sky.
Bounce up and down just like a clown.
Everyone knows its Slinky.
-
May 5, 2003, 14:13 #8
- Join Date
- Nov 2001
- Location
- Atlanta, GA, USA
- Posts
- 5,011
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
In this case, "nothing" is a step in the right direction (away from the error)!
I'm guessing that there are more register globals issues. Here's the knee-jerk link on the subject: http://www.sitepoint.com/article/758
Just eyeballing it, $new_db probably needs to become $_POST['new_db']Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?
-
May 5, 2003, 22:18 #9
- Join Date
- Apr 2003
- Location
- United Kingdom
- Posts
- 94
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
samsm. You are correct. I changed it to read $_POST['new_db'] and it all works ok now... Thanks to all for the help
Bookmarks