1commander
Technical User
I am running a apache on my home computer and when I run the following code (PHP) I get the following error message when I try to submit my form which would update my database, 'jokes' it gives me an error message (follows).
php:
<?php
//connect to the datbase server
$dbcnx = @mysql_connect('localhost', 'root', '');
mysql_select_db('jokes', $dbcnx);
if (! @mysql_select_db('jokes') ) {
die( '<p>Unable to locate the joke ' .
'database at this time.</p>' );
}
$result = @mysql_query('SELECT JokeText FROM Jokes');
if (!$result) {
die('<p>Error performing query: ' .mysql_error(). '</p>');
} else {
echo('It worked!');
}
while ($row = mysql_fetch_array($result) ) {
echo('<p>' . $row['JokeText'] . '</p>');
}
if (isset ($_POST['submitjoke'])) {
$joketext = $_post['joketext'];
$sql = "INSERT INTO Jokes SET
JokeText = '$joketext';
JokeDate = CURDATE()";
if (@mysql_query($sql)) {
echo('<p>Your joke has been added</p>');
} else {
echo('Error submitting joke');
}
}
echo('<p><a href="' . $_SERVER['PHP_SELF'] .
'?addjoke=1">Add a joke!</a></p>');
?>
The error message is:
Forbidden
You don't have permission to access /Test Dynamic Site 2 - delete anytime/< on this server.
--------------------------------------------------------------------------------
Apache/2.0.58 (Win32) PHP/5.1.4 Server at localhost Port 80
I am pretty new but I think that you I typically need an .htaccess file for any sort of permissions switching to go on, I believe. I do not have an .htaccess file in my sites directory. This is also on my own computer, so I cant imagine that I dont have permissions. This happens anything I try to submit a form on my own computer/server pretty much.
Thanks for any help.
php:
<?php
//connect to the datbase server
$dbcnx = @mysql_connect('localhost', 'root', '');
mysql_select_db('jokes', $dbcnx);
if (! @mysql_select_db('jokes') ) {
die( '<p>Unable to locate the joke ' .
'database at this time.</p>' );
}
$result = @mysql_query('SELECT JokeText FROM Jokes');
if (!$result) {
die('<p>Error performing query: ' .mysql_error(). '</p>');
} else {
echo('It worked!');
}
while ($row = mysql_fetch_array($result) ) {
echo('<p>' . $row['JokeText'] . '</p>');
}
if (isset ($_POST['submitjoke'])) {
$joketext = $_post['joketext'];
$sql = "INSERT INTO Jokes SET
JokeText = '$joketext';
JokeDate = CURDATE()";
if (@mysql_query($sql)) {
echo('<p>Your joke has been added</p>');
} else {
echo('Error submitting joke');
}
}
echo('<p><a href="' . $_SERVER['PHP_SELF'] .
'?addjoke=1">Add a joke!</a></p>');
?>
The error message is:
Forbidden
You don't have permission to access /Test Dynamic Site 2 - delete anytime/< on this server.
--------------------------------------------------------------------------------
Apache/2.0.58 (Win32) PHP/5.1.4 Server at localhost Port 80
I am pretty new but I think that you I typically need an .htaccess file for any sort of permissions switching to go on, I believe. I do not have an .htaccess file in my sites directory. This is also on my own computer, so I cant imagine that I dont have permissions. This happens anything I try to submit a form on my own computer/server pretty much.
Thanks for any help.